0

I wrote a simple script which runs when I'm shutting down my computer. I placed the script under /etc/init.d/ directory and link it back to /etc/rc0.d/. The link is soft link and its name is K99checkout-reminder.

Here's the result from listing files under /etc/rc0.d/:

lrwxrwxrwx 1 root root 24 Nov 17 18:10 K99checkout-reminder -> ../init.d/alert_checkout

Here's the content of alert_checkout:

#!/bin/bash
export DISPLAY=:0.0
if zenity --question --text="I guess you have a nice working day?"; then
    zenity --info --text="Gr8! Now please
          _______

               |
               |
               |
               v

DO NOT forget to CHECKOUT your working time at door.\n\nSee you next day!"
else
    zenity --info --text="Thats really sad.\n\nGo checkout your time to finish your working.\n\nHave good dinner, go sleep early and have a nice day!"
fi

I tried to run the script under root privilege and it works fine:

$ /etc/rc0.d $ sudo ./K99checkout-reminder

Got an alert box appeared!

Is there anything that I'm missing here?

Thank you.

0

Try changing the owner maybe if it works after that its a permissions thing. Permissions can be tricky even if given full access sometimes.

1
  • Thank you for your answer but it doesn't work. – petwho Nov 20 '14 at 6:09
0

try to add \ symbol before line endings in the zenity text, like this:

#!/bin/bash
export DISPLAY=:0.0
if zenity --question --text="I guess you have a nice working day?"; then
zenity --info --text="Gr8! Now please \
      _______\
\
               |\
               |\
               |\
               v\
\
DO NOT forget to CHECKOUT your working time at door.\n\nSee you next day!";
else
zenity --info --text="Thats really sad.\n\nGo checkout your time to finish your         working.\n\nHave good dinner, go sleep early and have a nice day!"
fi

or replace new line symbols with \n escapes.

0

Please note that there's a difference between running under root privileges and running under the root user. If you tried to run it like this:

sudo ./alert_checkout

then it worked, becouse the Real UID was still set to your user, with only the Effective UID being changed to root. However, when running as a init.d script, it is executed under the root user, so both UIDs are set to root.

This is consfusing for zenity as it needs to display the message inside your user sesssion. Therefore it needs the Real ID to match your user.

If you only need this to work for a particular user account, then simply edit the script and run zenity under su <user> -c <zenity cmd>.

0

I think the link you are showing is a symbolic link or symlink.

When the system is shutting down, I think it runs the Kill inits in Numerical order, so that

K01... is run before k02...

If you are running this script as K99...

Then wouldn't the window manager already be shut down?

Have you tried running your script as:

K01checkout-reminder 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.