USB to Authorize unlock/lock of computer

Hello, I’m trying to do this:

Lock / Unlock Ubuntu Desktop using USB drive

but of course in opensuse 12.3. I get into trouble when I try to do

touch **/home/vidyadhar/**autoUnlock

in terminal. It says

touch: cannot touch ‘/vidyadhar/autoUnlock’: No such file or directory

I will post more later, but right now I don’t have much time. Thank you to anyone that is willing to help:)

You need to use your username, not in the article…

touch ~/autoUnlock


touch /home/<your_username>/autoUnlock

Do you have a bluetooth phone, maybe look at the blueproximity package to lock/unlock?

Did you not notice that Vidyadharwas the author’s name?


:~ >  touch ~/autoUnlock’


To be more clear,

  1. Did you forget to create the file?
  2. Replace the author’s name with your own or use the tilde to indicate <your> User home direcotry


Wow! I’m really surprised by number of good replies.

Basically, how I interpreted from the instructions was that I was supposed to create the vidyadhar folder. Since I wasn’t able to create the file with the ‘touch’ command, I decided to create it manually using gedit. I put it under here: /home/sean/Pictures/Screenshot from 2013-03-25 13:52:17.png .

I recreated a blank file with the same name “autoUnlock” here: /home/sean/Pictures/Screenshot from 2013-03-25 14:09:18.png . I don’t even know if I have to create the file using the ‘touch’ command or if I can just create it myself.

Also, when I type in the touch command with the advised text in the replies above, the cursor just moves to the next line as if its ready for me to type in a new command. Here’s the picture: /home/sean/Pictures/Screenshot from 2013-03-25 14:14:26.png .

I’m also very to opensuse, and just Linux in general. Started just last week.

—I just realized that my images aren’t being put onto my post, how do you post images on this forum. I’ve been able to do this with other forums flawlessly.—

This is a reply to show where I put my files.
The first one, using gedit, was put under /home/vidyadhar/autoUnlock
The blank file I made was put under /home/sean/autoUnlock

OK. I believe I’m up to the point in the instructions to where it says I need to restart the crontab. I can input the instructions

          • bash /home/vidyadhar/autoUnlock & >/dev/null 2>&1

into the crontab perfectly. I just don’t know where or how to put in

/etc/init.d/cron restart

in order to restart it. Can anyone enlighten me?

The command to edit your crontab as your user from a terminal is;

crontab -e

press i (to insert) to add your command
then press <esc> then press <shift>: then enter wq <enter> to save

Else look for a GUI crontab editor if your not sure for the command line…

Then you need to restart cron, since your new, a reboot will do it, else open a terminal as your user, then;

su -
systemctl restart cron.service

On 2013-03-26 02:56, Sean P wrote:
> /etc/init.d/cron restart
> in order to restart it. Can anyone enlighten me?

Now I’m lost. Why do you want to restart cron? The changes you write
into crontab files will be used as soon as you do them, no need to
restart cron. How else could a user do a cron job? He can not restart
cron himself.

Cheers / Saludos,

Carlos E. R.
(from 12.1 x86_64 “Asparagus” at Telcontar)

Thanks. your information really helped me solve my issue on the cron front.

So I logged out and back in, and then I pulled out my USB, but it never locked. Since the code that Vidyadharwas made to put in the file “autoUnlock” was for Ubuntu, and not for opensuse, I’m guessing that some of it might have to be edited to work with opensuse. Here’s the code if anyone wants to help me:

*#!/bin/bash* *
# A simple shell to lock / unlock your Desktop* *
# Ubuntu* *
# ----------------------------------------------------------------------------* *
# Original Script by Echowrap* *
# Modified by Vidyadhar D S <>* *
#* *
# ----------------------------------------------------------------------------* *
#Replace with the ID of your USB device* 
id="ID 058f:6387 Alcor Micro Corp. Transcend JetFlash Flash Drive" 
#runs every 2 seconds* **
for** **(****(**i=0; i**<**=30; i++**)****)** **
do** **
if** **** -z "`lsusb | grep "$id"`" **]** **
    **echo** "Device is NOT plugged in" 
    **if** **** -n "`DISPLAY=:0.0 gnome-screensaver-command --query | grep "is active"`" **]** 
    **if** **** -e **/**tmp**/**autoUnlock.lock **]** 
    *#stop locking the screen* 
    **rm** **/**tmp**/**autoUnlock.lock 
elif** **** -e **/**tmp**/**autoUnlock.lock **]** **
    DISPLAY=:0.0 notify-send -t 5000 âicon=dialog-info "Device Disconnected""Bye!" 
    *#lock the desktop* 
    DISPLAY=:0.0 gnome-screensaver-command --lock 
    **rm** **/**tmp**/**autoUnlock.lock 
fi** **
    **echo** "USB Plugged In" 
    **if** **** **!** -e **/**tmp**/**autoUnlock.lock **]** 
    DISPLAY=:0.0 gnome-screensaver-command --deactivate 
    DISPLAY=:0.0 notify-send -t 5000 --icon=dialog-info "Device Connected" "Welcome Back!" 
    **touch** **/**tmp**/**autoUnlock.lock 
    *#Uncomment the 3 following lines if you would like your computer to remind you if you lock your screen without disconnecting the device* 
    **echo** "Don't forget your device!" **>** **/**tmp**/**usbReminder 
    DISPLAY=:0 festival --tts **/**tmp**/**usbReminder 
    **rm** **/**tmp**/**usbReminder 
fi** **
sleep** 2 **

The code works for me if I run it manually but not from crontab.

when scripts which run from the command line fail as a cron job, it’s usually the PATH

so at the command line do
echo $PATH

and then add at the top of the script

export PATH=/blah:/blah