Results 1 to 8 of 8

Thread: command line lock screen for gnome and KDE

  1. #1

    Default command line lock screen for gnome and KDE

    Do have this right for common linux installations of KDE and Gnome?

    Another method for gnome.

    Code:
    xdg-screensaver lock
    Code:
                   #lock screen
                   if [[ "$LockScreenCommand" == '1' ]];then
                        #printf "Desktop:  %s\n" $XDG_CURRENT_DESKTOP
                        if [[ $(wmctrl -m | grep KWin) ]]; then
                             loginctl unlock-session 1
                        fi
                        if [[ $(wmctrl -m | grep GNOME) ]]; then     
                             gnome-screensaver-command --lock
                        fi
                   fi

  2. #2
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,698
    Blog Entries
    15

    Default Re: command line lock screen for gnome and KDE

    Hi
    For gnome, nope not in current versions... look at the gsettings schema, keys and settings, seems a bit intrusive over riding a user desktop setup choice?
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  3. #3

    Default Re: command line lock screen for gnome and KDE

    Quote Originally Posted by malcolmlewis View Post
    Hi
    For gnome, nope not in current versions... look at the gsettings schema, keys and settings, seems a bit intrusive over riding a user desktop setup choice?
    ?? It's detecting the current desktop and executing the right command.

    https://askubuntu.com/questions/9877...d-ubuntu-17-10

    Code:
    dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
    Code:
                   #lock screen
                   if [[ "$LockScreenCommand" == '1' ]];then
                        #printf "Desktop:  %s\n" $XDG_CURRENT_DESKTOP
                        if [[ $(wmctrl -m | grep KWin) ]]; then
                             loginctl unlock-session
                        fi
                        if [[ $(wmctrl -m | grep GNOME) ]]; then     
                  dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock 
                       fi
                        fi
    If not this method then which method?

  4. #4
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,698
    Blog Entries
    15

    Default Re: command line lock screen for gnome and KDE

    Quote Originally Posted by lord_valarian View Post
    ?? It's detecting the current desktop and executing the right command.

    https://askubuntu.com/questions/9877...d-ubuntu-17-10

    Code:
    dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
    Code:
                   #lock screen
                   if [[ "$LockScreenCommand" == '1' ]];then
                        #printf "Desktop:  %s\n" $XDG_CURRENT_DESKTOP
                        if [[ $(wmctrl -m | grep KWin) ]]; then
                             loginctl unlock-session
                        fi
                        if [[ $(wmctrl -m | grep GNOME) ]]; then     
                  dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock 
                       fi
                        fi
    If not this method then which method?
    Hi
    Shouldn't you ask the end user (as in check their preferences) before invoking something that may have been disabled, or an option to disable in your code? I have screenlock disabled....
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  5. #5

    Default Re: command line lock screen for gnome and KDE

    Quote Originally Posted by malcolmlewis View Post
    Hi
    Shouldn't you ask the end user (as in check their preferences) before invoking something that may have been disabled, or an option to disable in your code? I have screenlock disabled....
    Err, that should be '=0'. Screenlock is off by default. The screenlock function works for KDE.

    background scan
    screen lock [option]
    suspend or power off

    Again, do I have that right for gnome? If don't get an answer here, I'll have to rely gnome users to tell me if it works.

  6. #6
    Join Date
    Jun 2008
    Location
    Podunk
    Posts
    29,698
    Blog Entries
    15

    Default Re: command line lock screen for gnome and KDE

    Quote Originally Posted by lord_valarian View Post
    Err, that should be '=0'. Screenlock is off by default. The screenlock function works for KDE.

    background scan
    screen lock [option]
    suspend or power off

    Again, do I have that right for gnome? If don't get an answer here, I'll have to rely gnome users to tell me if it works.
    Hi
    There are multiple ways to implement screen locking in GNOME, the method you used works, then there is super+L and gsettings. What I'm saying is that your section of code potentially overrides a user setting/workflow. If you start doing lots of coded checks, especially for different desktops, it is probably more efficient to add and source a user config file, start with some defaults that the user can override if wanting to?
    Cheers Malcolm °¿° SUSE Knowledge Partner (Linux Counter #276890)
    SUSE SLE, openSUSE Leap/Tumbleweed (x86_64) | GNOME DE
    If you find this post helpful and are logged into the web interface,
    please show your appreciation and click on the star below... Thanks!

  7. #7

    Default Re: command line lock screen for gnome and KDE

    Quote Originally Posted by malcolmlewis View Post
    Hi
    There are multiple ways to implement screen locking in GNOME, the method you used works, then there is super+L and gsettings. What I'm saying is that your section of code potentially overrides a user setting/workflow. If you start doing lots of coded checks, especially for different desktops, it is probably more efficient to add and source a user config file, start with some defaults that the user can override if wanting to?
    scanvirus was always designed from the start to not use any windowed environment (desktop). The three functions are only extras. You can use scanvirus without ever using these extra functions. Also, you can do these functions manually. Again, these commands are extra shortcuts.


    I should separate the suspend and power off from send command to background. These functions are limited and are that way for a reason.

    Adding the commands into the config file creates security issues.

  8. #8

    Default Re: command line lock screen for gnome and KDE

    Quote Originally Posted by malcolmlewis View Post
    Hi
    There are multiple ways to implement screen locking in GNOME, the method you used works, then there is super+L and gsettings. What I'm saying is that your section of code potentially overrides a user setting/workflow. If you start doing lots of coded checks, especially for different desktops, it is probably more efficient to add and source a user config file, start with some defaults that the user can override if wanting to?
    I have checks for both gnome and kde. The config settings allows on/off of screen locking on power off and suspend.

    All are optional shortcuts for KDE and Gnome. scanvirus can be used on a server with no desktop interface.

    scanvirus -vf [open virus vault folder]
    scanvirus -l s linux scan - suspend on complete
    scanvirus -m s msin scan - suspend on complete

    CFG file
    Suspend or power-off then lock screen - GNOME KDE
    LockScreenCommand= 0

    Due to how the commands function this is easiest way for users to operate it.

    If you have better way, I like to hear it.

Tags for this Thread

Posting Permissions

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