Hi guys, and thanks in advance for reading this. And I don’t mean to patronise anyone with the detail I put (or forgot!), I just want to show my understanding of what I’ve done.
My question is whether what I did below is likely to lead me into problems.
Just for info, I’m running:
OS: Linux 2.6.27.42-0.1-default i686
System: openSUSE 11.1 (i586)
GNOME: 2. … not sure
KDE: 4.1.3 (KDE 4.1.3) “release 4.11.1”
Icewm-gnome: 1.2.36-1.20-i586
Anyhow. I’ve been working in Icewm as I like the light running. Trouble was I couldn’t get it to lock the screen when I suspended to disk — which I was doing via … in xterm.
powersave -U
Then I discovered that you could lock the screen with
gnome-screensaver-command -l
But seeing as gnome-screensaver wouldn’t normally be running I had to run that first. So I ended up putting this in the command line (and it had to be one line or the screen would lock before I could command it to suspend… I felt like I had just shut the door behind me without a key!):
Now that’s ok, just quite long winded, so I wanted to make a shortcut. So then I find out that apparently I want to make a shell script for it (so I’m told, I have little clue about them).
So I went to /usr/bin/, where all the shell scripts live, made a copy of the simplest one there to use as a template, and renamed it ‘lock’. Then I edited the file from
Now just entering ‘lock’ in xterm locks screen and suspends to disk, and boots up to a password prompt. Lovely. Then just a key bind of Ctrl+Alt+l gives me a keyboard shortcut. Ace.
But I was wondering, that was a bit of hack job.
Did I miss a really obvious way of doing it more simply?
Is this a really bad habit and I was lucky I didn’t blow up my computer?
Many Thanks
Ben
It’s refreshing to see someone using Linux, unix-style as intended, composing programs to solve a problem, instead of bleating about why some functionality they need is missing.
I do something similar, powering down my monitor while my desktop does big sums.
#!/bin/bash
#
# Dell monitor DPMS.
#
if test -z $1 ; then
# Support for Autostart.
$0 enable
else
case $1 in
(disable)
xset -dpms
;;
(enable)
xset +dpms
xset dpms 600 1200 1800
;;
(off)
zenity --question --timeout=10 --title "Alert" --text "Power Off Dell Monitor?"
if $? == 0 || $? == 5 ]] ; then
case $(basename $WINDOWMANAGER) in
(gnome|gnome-session)
gnome-screensaver-command --lock &
;;
esac
sleep 3
xset dpms force off
fi
;;
(*)
;;
esac
fi
exit 0
#
# Done.
#
Well I have to say that one beats mine square out of the water. But thanks, I’m glad it was vaguely sensible. Just have to think up what else I would love to happen at the press of a button…
I knew there was a good reason I switched over, linux is cool. Thanks for the encouragement too.
Next job is to try and get it to kill the gnome-scrnsvr on resume. And apparently in the pref. config file it already gave a command for lockign the screen with xscreensaver, or something the like.
I wonder why there’s no suspend option in IceWM? They must have had a good reason, maybe going back to before it was used stand-alone… (if I’ve got my history right)
bendare wrote:
> So I went to /usr/bin/, where all the shell scripts live, made a copy
> of the simplest one there to use as a template, and renamed it ‘lock’.
did you check first to see if there was another ‘lock’ in the path?
what if there was one?
> Now just entering ‘lock’ in xterm locks screen and suspends to disk,
> and boots up to a password prompt. Lovely. Then just a key bind of
> Ctrl+Alt+l gives me a keyboard shortcut. Ace.
> But I was wondering, that was a bit of hack job.
> 1) Did I miss a really obvious way of doing it more simply?
> 2) Is this a really bad habit and I was lucky I didn’t blow up my
> computer?
I don’t see anything wrong with it, but to keeps things clear i would put
the script in /usr/local/bin so it’s easyer to find your own script.
Also i woud give the script a more unique name like lock-bendare just to
make sure it isn’t conflicting with an existing command named lock.
Palladium - I kind of checked, when I renamed the file it was in the /usr/bin/ folder so I assumed konqueror would tell me if there was a name conflict. But I probably should have checked first, I don’t know what would happen with a name conflict if I was using the command line.
Chris Maaskant - They both sound like sensible suggestions. I had not thought of a local folder.
Thanks to both.
bendare wrote:
> But I probably should have checked first, I don’t know
> what would happen with a name conflict if I was using the command line.
if there were two different programs/scripts in the path, that one
which was found first would be executed…
one way to check if a (say) “lock-it” already exists in the path would
be to use the “which” command…
you should now be able to go to a command line and enter
which lock
and, find where you put it…
but, if you enter
which lock-it
it should answer “no lock-it in [path]”
incidentally, you (as a regular user) and root (as a superuser) have
different paths…so, you might want to switch user [su - root] and
also issue a ‘which’ to search root’s path…