Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: how can I automatically lock screen everyday at specific times?

  1. #1
    Join Date
    Aug 2010
    Location
    wonderful land of OZ
    Beans
    73
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Arrow how can I automatically lock screen everyday at specific times?

    how can I automatically lock my desktop at pre-specified specific times everyday?
    Last edited by TooFreppaT; May 27th, 2013 at 08:37 PM. Reason: marked as solved

  2. #2
    Join Date
    May 2009
    Location
    Indiana
    Beans
    1,825
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: how can I automatically lock screen everyday at specific times?

    The command
    Code:
    gnome-screensaver-command -l
    locks the screen.

    You could probably incorporate that into crontab. (There's plenty of documentation on crontab, so do a little searching...)
    Jane, stop this crazy thing!

  3. #3
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    6,697
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: how can I automatically lock screen everyday at specific times?

    Hi TooFreppaT.

    This would be the command you need to run:
    Code:
    gnome-screensaver-command -l
    IMHO, the easiest way to automate the process would be to use cron.

    To edit your crontab run this:
    Code:
    crontab -e
    This entry would lock your screen every minute (good for testing):
    Code:
    */1 * * * * DISPLAY=:0 gnome-screensaver-command -l
    Hope it helps. Let us know how it goes.
    Regards.

  4. #4
    Join Date
    Jul 2012
    Location
    Moscow
    Beans
    70
    Distro
    Ubuntu

    Re: how can I automatically lock screen everyday at specific times?

    Code:
    gnome-screensaver-command -l
    + crontab -e

    i forgot to refresh my page )

  5. #5
    Join Date
    Aug 2010
    Location
    wonderful land of OZ
    Beans
    73
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: how can I automatically lock screen everyday at specific times?

    thankyou for your replies
    Quote Originally Posted by papibe View Post
    This entry would lock your screen every minute (good for testing):
    Code:
    */1 * * * * DISPLAY=:0 gnome-screensaver-command -l
    I found this help.ubuntu.com/community/CronHowto#GUI_Applications

    I wanted to find out more about the commands but from the link the only thing I can't understand is env DISPLAY=:0 and why you didn't use env in yours
    Last edited by TooFreppaT; May 25th, 2013 at 08:09 PM.

  6. #6
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    6,697
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: how can I automatically lock screen everyday at specific times?

    A few thoughts:
    • The cron environment is very efficient, but limited, so you need to include the variable DISPLAY in order to run GUI apps.
    • :0 is the reference to the default display and it will work on most cases.
    • When you have 2 monitors the syntax changes. :0.0 would reference the first one, and :0.1 the second one.
    • In the context of you want to do, either:
      Code:
      env DISPLAY=:0 cmd
      
      DISPLAY=:0 cmd
      produces the same result: modifiy the environment in which the command 'cmd' will run.

    • The command 'env' is a much powerful way to do that. For instance, you can set several variables:
      Code:
      env  PATH=/path/to/special/library:$PATH  DISPLAY=:0.1  cmd
      (that would modify the environment in which 'cmd' would run by adding an extra directory to the path, and set to run on the 2nd monitor).

    Does that help?
    Regards.

  7. #7
    Join Date
    Aug 2010
    Location
    wonderful land of OZ
    Beans
    73
    Distro
    Ubuntu 12.10 Quantal Quetzal

    Re: how can I automatically lock screen everyday at specific times?

    Thank you very much.

    If I could marke this as solved then I would but I can't find it anymore.

  8. #8
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    6,697
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: how can I automatically lock screen everyday at specific times?

    Quote Originally Posted by TooFreppaT View Post
    Thank you very much.
    Glad I could help
    Quote Originally Posted by TooFreppaT View Post
    If I could marke this as solved then I would but I can't find it anymore.
    It hasn't been set yet. Here's how to do it for now.

    Regards.

  9. #9
    Join Date
    May 2009
    Location
    Indiana
    Beans
    1,825
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: how can I automatically lock screen everyday at specific times?

    Quote Originally Posted by papibe View Post
    Glad I could help

    It hasn't been set yet. Here's how to do it for now.

    Regards.
    I get the impression that a lot of threads are going without being marked as solved because the only way to do it is a not-so-obvious workaround. Seems like it should be more of a priority... But then, I know nothing about managing the format of a forum site.
    Jane, stop this crazy thing!

  10. #10
    Join Date
    May 2013
    Beans
    6

    Re: how can I automatically lock screen everyday at specific times?

    Awesome. I love that it doesn't take much to do custom things like this in Ubuntu.

Page 1 of 2 12 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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