0

I'm into xmonad for a second day. I'm doing well so far. Got it installed on Ubuntu 12.4 from here, configured keyboard layouts, tweaked xmobar configs and etc.

For screen lock I'll use slock, and from my research, for power management (entering sleep on a desktop) I bet the best thing is to use /etc/acpi/sleep.sh directly.

So my question is, how can I call sleep.sh in a more fashionable way, without entering terminal and typing sudo /etc/acpi/sleep.sh? Maybe a shortcut? Or an interface button?

Also, solution should take into consideration sudo part, it would be nice to make my computer sleep without entering password.

Thank you very much!

  • Although I admit that this might be not a purely xmonad question, but more related to Linux itself. – B.I. Nov 3 '13 at 12:12
1

To put the computer to sleep without a password, you can use the "visudo" program (which you need to run with root privileges), and add an entry like:

your_username ALL = NOPASSWD: /etc/acpi/sleep.sh

where you should replace "your_username" with what you have in your system.

Then, you can bind a keyboard-shortcut in XMonad to run this command by extending the "myKeyBindings" in the config you are referring to, for example:

myKeyBindings =   [
    ...
    , ((0, 0x1008FF13), spawn "amixer -q set Master 10%+")
    -- SLEEP with Mod+Shift+s
    , ((myModMask .|. shiftMask, xK_s), spawn "sudo /etc/acpi/sleep.sh") ]

Also, don't forget to run "xmonad --recompile" to validate the config, and restart XMonad.

| improve this answer | |
  • Let me leave here my config for suspend and hibernate. Add following shortcuts to xmonad.hs myKeyBindings = [ -- sleep with Mod + Shift + s , ((myModMask .|. shiftMask, xK_s), spawn "systemctl suspend") -- hibernate with Mod + Shift + h , ((myModMask .|. shiftMask, xK_h), spawn "sudo systemctl hibernate") ] Also, you need to give permission to run hibernate command without entering password: sudo visudo and add the following line: username ALL=NOPASSWD: /bin/systemctl hibernate – B.I. Jan 31 '17 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.