It should work without sudo or anything - if you have systemd. Here is a 
snippet from my config where I set up a dmenu for the various options of 
this kind:

Key([mod, 'control'], 'x', lazy.run_extension(CommandSet(
    commands={
        'shutdown': 'systemctl poweroff',
        'reboot': 'systemctl reboot',
        'suspend': 'systemctl suspend',
        'hibernate': 'systemctl hibernate',  # NOTE: A few things need to 
be set up in advance for this to work.
        'logout': 'loginctl terminate-session $XDG_SESSION_ID',
        'switch user': 'dm-tool switch-to-greeter',  # "dm-tool" is 
probably part of something other than systemd
        'lock': 'loginctl lock-session',
    },
    dmenu_prompt='session>',
    **dmenu_theme  # you can just leave this out if you don't have your own 
dmenu-theme
)), desc='List options to quit the session.'),

On Wednesday, 2 September 2020 at 06:55:28 UTC+2 [email protected] wrote:

> Do you need help with the binding, or the command to make it sleep?
>
> For the command, if you're using systemd, try something like:
>
>   systemctl start suspend.target
>
> You probably need sudo or polkit or something to get the right privileges.
>
> On Tue, Sep 1, 2020 at 9:39 PM [email protected] <[email protected]> 
> wrote:
>
>> This seems like a dumb question, but I'm having a hard time figuring out 
>> how to set up a keyboard shortcut to put my computer to sleep.  Anyone done 
>> this successfully with qtile?  
>>
>>  - Kovas
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "qtile-dev" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/qtile-dev/c6aed11a-6b52-4905-96d7-59cb7eb3ae28n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/qtile-dev/c6aed11a-6b52-4905-96d7-59cb7eb3ae28n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"qtile-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qtile-dev/2e3754eb-48e4-437b-9928-1c05af1c6fe9n%40googlegroups.com.

Reply via email to