Is it possible to write a shell script that enables any user (may not be root) to set a message(e.g. "Download on progress do not turn off" etc.) which will be conveyed like pop-up message (zenity or notify-send) to all other users. If any user is not there at the time of throwing the message they must get it on login or unlocking their screen.
Nice question. Will give just an half answer... just a seed to see if someone can prepare something starting on this. I have tested this in my system, two users (ubuntu and romano, the two administrators).
I go to a VC and log in as ubuntu --- then I run
(the first sudo switch to superuser, the second sudo execute
from a virtual console, the message will appear in "romano" graphical environment.
I suppose that with a bit of mangling the output of
I see really difficult to do that without superuser privileges, tough.
If you don't find a direct solution, problems like this can be solved by creating a (simple, in this case) daemon program that runs with elevated privileges and runs when the system starts.
Then, a regular user user can put a file somewhere the daemon will see it or send the daemon a message and the daemon can then do whatever action required elevated privileges.
You just have to be careful what input the daemon accepts so you don't open any security holes in your system.
There is an almost unlimited variety of things that can happen when you pass an unedited character string to a bash script running with elevated privileges! For that reason alone, it would be much better if your daemon were written in a language such as Python where you can do whatever you want to an incoming string before the system gets any chance to interpret/execute its contents.
For users logging in, you can probably add a few lines to /etc/profile which tell the daemon to issue any messages the user needs to see. If you do that, you should probably also do something to avoid unnecessary repetitions when the user logs in again. That's more work, but will keep alerts from turning into nagware.
I think what I did is really a bad way to do things. Anyway it works upto a certain level. Any suggestion to improve the script or a better script is always welcome. I tried to do this with the help of the answers given by Rmano and Joe.
I have created a file at
and add this line "
change permission of