Results 1 to 10 of 10

Thread: Just want to check I'm not doing anything stupid

  1. #1

    Question Just want to check I'm not doing anything stupid

    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.
    Code:
    powersave -U
    Then I discovered that you could lock the screen with
    Code:
    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!):
    Code:
    gnome-screensaver ; gnome-screensaver-command -l ; powersave -U
    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
    Code:
    #! /bin/sh
    
    kcminit style
    to
    Code:
    #! /bin/sh
    
    gnome-screensaver
    
    gnome-screensaver-command -l
    
    powersave -U
    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?
    Many Thanks
    Ben

  2. #2

    Default Re: Just want to check I'm not doing anything stupid

    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.

    Code:
    #!/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.
    #

  3. #3

    Default Re: Just want to check I'm not doing anything stupid

    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...

  4. #4
    Join Date
    Jun 2008
    Location
    Groningen, Netherlands
    Posts
    19,806
    Blog Entries
    14

    Default Re: Just want to check I'm not doing anything stupid

    This makes my day. KJ44, I agree 100 %. Must say it's attitude like this that brought us linux, and the desktops.
    ° Appreciate my reply? Click the star and let me know why.

    ° Perfection is not gonna happen. No way.

    https://en.opensuse.org/openSUSE:Board#Members
    http://en.opensuse.org/User:Knurpht
    http://nl.opensuse.org/Gebruiker:Knurpht

  5. #5
    palladium NNTP User

    Default Re: Just want to check I'm not doing anything stupid

    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?

    --
    palladium

  6. #6

    Default Re: Just want to check I'm not doing anything stupid

    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)

  7. #7
    Chris Maaskant NNTP User

    Default Re: Just want to check I'm not doing anything stupid

    bendare wrote:

    > 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.

    --
    Chris Maaskant

  8. #8

    Default Re: Just want to check I'm not doing anything stupid

    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.

  9. #9
    palladium NNTP User

    Default Re: Just want to check I'm not doing anything stupid

    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..

    more: on paths http://tinyurl.com/ydbwssh

    --
    palladium

  10. #10

    Default Re: Just want to check I'm not doing anything stupid

    I was wanting a command like that. Thanks, that's helpful, should stop me bouncing too much between the terminal and the file manager.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •