1

So, I have 3PC on my desk, all running ubuntu 14.04 64bit. and all running the latest version of Synergy, so that I only use one keyoard and one mouse to control 3 PCs and 4 monitors. this works great! but, one problem.

every time I login (unlock), I have to log in 3 times. and every time I lock the computer I have to lock it 3 times. (well, I have to lock, and log in to each of the 3 PCs individually).

so far synergy do not have a system for this in their code, but I was thinking maybe I can solve this with a ssh script? does anyone have any ideas how I could do this? is it even possible?

edit: I got one hint, in comment below, and have tried some things (see my own answer, as to what I have tried so far), this problem is still not solved, so please read my own answer below, and see if maybe you can help me find out why this does not work, or maybe come up with a totally different solution.

Sverre
  • 326

1 Answers1

3

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 synergyto 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.shandmy_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!

Sverre
  • 326
  • 1
    I wrote script for you. Here is Readme – c0rp Oct 09 '14 at 12:42
  • Thanks again c0rp! this script, worked in the end.. I had some problems in the start, but I changed one line to make your "status" work (you did not have the parameter to that check_if_daemon_alive function), and suddenly it started to work for me.. not sure what was the reason it did not work right away. if you answer this question, I will be more than happy to give you the credit. – Sverre Oct 10 '14 at 05:22
  • 1
    @c0rp, wow, this is amazing. any way to do a similar thing with a ubuntu/win64 combo? – Serban Tanasa Jan 05 '15 at 18:16