I have not yet made this work, but I wanted to add what I have tried, and how it failed so far, in case this will make someone else see what I am doing wrong.
everything is based on the comment by c0rp, via this link (thanks)
I have created two bash script files like this:
1) /sbin/my_loginscript.sh
(used to "log in", and open two computers)
#!/bin/bash
#
# Script to loging to my other computers when I login, save some time
#
echo "UNLocking laptop and desktop"
ssh -X myuser@192.168.12.22 "export DISPLAY=:0; gnome-screensaver; gnome-screensaver-command -d;"
ssh -X myuser@192.168.12.203 "export DISPLAY=:0; gnome-screensaver; gnome-screensaver-command -d;"
echo "Now get some back to work"
2) /sbin/my_logoutscript.sh
(used to "log out" and close two computers)
#!/bin/bash
#
# Script to loging to my other computers when I login, save some time
#
echo "Locking laptop and desktop"
ssh -X myuser@192.168.12.22 "export DISPLAY=:0; gnome-screensaver; gnome-screensaver-command -l;"
ssh -X myuser@192.168.12.203 "export DISPLAY=:0; gnome-screensaver; gnome-screensaver-command -l;"
echo "Now get some rest"
Both these scripts works fairly well, and when I run them directly the two extra desktop computers "open and close" and I can use synergy
to control them, this in itself is much faster than logging in manually to the two extra computers.
Now I try to automate this, and this is where I have problems.
when I log in to computer (have to log out for this to work)
I create a new file '/etc/xdg/autostart/my_script.desktop'
it looks like this:
[Desktop Entry]
Type=Application
Name=global login
Exec=sudo /sbin/my_loginscript.sh
Icon=system-run
X-GNOME-Autostart-enabled=true
and this actually works.. when I log in, the two other screens unlock like I want.
Todo: how to close it when I log out?
but also, I almost NEVER log out from my PC, I only LOCK
it and UNLOCK
it, so that is what I really want to fix, and this is how I have tried.
I create a new file called '/etc/pm/sleep.d/99_resume.sh`
and it looks like this:
#!/bin/bash
case "$1" in
thaw|resume)
/sbin/my_loginscript.sh 2> /var/log/wakeup.log
;;
suspend|hibernate)
/sbin/my_logoutscript.sh 2> /var/log/wakeup.log
;;
esac
but this does not seem to work at all, and i have a hard time troubleshooting it. if anyone have any hints or tips here, that would be very nice.
edit: Based on the comment from C0rp below, I have edited his scrip, and it can be found (edited) here:
basically after you clone or otherwise create the event_catcher.sh
file, you first copy my two files my_logoutscript.shand
my_logoutscript.shas described earlier, to the
/sbinfolder. Then start the daemon by running this
./event_catcher.sh start`.
next time you hit Ctrl Alt L
your computer will lock and also your other PCs will lock.
PS: I have assumed that you use ssh-copy-id
to enable login on those PCs with out password.
so, I consider the question solved now, but I will wait a bit for c0rp to see if he want to create a very quick answer (instead of only comments), and if he does that I will give him the credit. Thanks again c0rp!