Results 1 to 6 of 6
Hi - I want a system that locks my X display (using xscreensaver) when I remove my USB stick and automatically unlocks it when I remove my usb stick. I'm ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-26-2007 #1
Identify USB stick insert/removal and lock/unlock screen...
I'm planning to create a shell script running in constant loop and sleeping for a few seconds everytime in the end of loop - unless I have to use a way where that wont work...
The big problem is reacting to insert/removing the usb stick...
And then recognizing the usb stick to be the correct one without mounting it if possible - this way I guess it could be any USB device...
Smaller problem is how to unlock the xscreensaver... it could just be killed and restarted.
So far the best plan (and it's not that good) I have come up with is to watch fstab, as the usbstick's mount point and parameters are added there automatically when plugged in and removed when taken off and react according to it... It's very quick and dirty solution, but it get's worse...
To identify the usb-stick I don't know a way without mounting it and I dont want to mount it automatically, so I came up with another quick and dirty solution - when usb-stick is inserted it quickly mounts it, checks if certain data is saved there and unmounts it - and unlocks/kills&restarts the screensaver if it is the correct stick.
I would really wish to have a better solution than this, but it could work at least. Any help for not so... lame solution is highly appreciated!
- 09-26-2007 #2
The simple solution is loop&sleep a script filtering <lsusb> to grep certain identifiable info. That way you don't need to mount.
It's a dirty solution, but it works
To unlock just kill the screensaver. Be sure to have the sleep timer a LOT shorter when the USB is removed than when the USB is inserted. When you are away (USB removed) all your machine has to do is fanatically cycle through lsusb looking for your return (USB inserted).
I did the same on my machine, but instead of looking for a certain USB device it measures the distance to my mobile phone using Bluetooth. All I need to do to lock my computer is to walk away from it, and to unlock it I just have to come close againCan't tell an OS by it's GUI
- 09-26-2007 #3
Thank you - it's still a bit dirty, but much less than my plan... It will do, much thanks...
- 09-26-2007 #4
- Join Date
- Nov 2004
You could look at udev and see if you could create a rule for an application to run when a certain device is inserted. The problem may be that it is specific to a device, or that it may replace the automount of the device - but nonetheless udev is specifically designed for reacting to device plugging/unplugging.
- 09-26-2007 #5
It just seems that I owe you a big thanks, because I don't think there are many programs made for this particular purpose. You see, I got the idea for this when I bumped into a webpage with a program to do just that (lock/unlock by measuring bluetooth devices distance) and decided to do this. Certainly it must be your work that gave me the idea =) Small world!
- 09-27-2007 #6
Thnx! But I'm afraid I must decline the honor. Browsing the Gentoo wiki I found an article that gave me the inspiration for the said script. I'm afraid my dull understanding has yet to produce anything bright, pertinent or imaginative.
... as of yet, I add, as of yet ...Can't tell an OS by it's GUI