#StackBounty: #gnome #dbus dbus-monitoring loop exits automatically

Bounty: 50

I’m trying to execute a bash command on screen lock/unlock.

Following tutorials & StackExchange questions, I came up with the following code:

#!/bin/bash
while true; then #added to try to solve the issue, but alas it did not
    dbus-monitor --session "type='signal',interface='org.gnome.ScreenSaver'" |
    while read sign; do
        case "$sign" in
            *"boolean false"*) echo "Screen unlocked";;
            *"boolean true"*) echo "Screen locked";;
        esac
    done
done

I launch the program with the folloing command:

nohup myprogram.sh &

Everything works well at start, but after a while (several hours), there is no more echoed output when screen is locked/unlocked.

Checking the output of ps aux | grep mycommand, I have the following result at start:

user  <pid1> 0.0 0.0 <number> <number> pts/2 S 13:01   0.00 /bin/bash myprogram.sh
user  <pid2> 0.0 0.0 <number> <number> pts/2 S 13:01   0.00 /bin/bash myprogram.sh

After it breaks and does not emit messages anymore, then the ps output only show one line.

I’m using CentOS 6.5, with Gnome 2.28.

Would you have any insight about what could be happening?


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.