Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why sudo pm-suspend does not work in i3 tiling window manager? [closed]

Tags:

bash

I have a little problem with the i3 tiling window manager's ~/.i3/config file. I am trying to set the pm-suspend utility as a key-binding of Mod4 (the windows key) + p (the p char).

I have this bash script called suspendandlock in /usr/bin/:

#!/bin/bash
sudo pm-suspend | i3lock -i /home/antony/unity-desk.png -p default -d -n 

I previously modified the /etc/sudoers file with visudo, adding this line:

%users ALL = NOPASSWD: /usr/sbin/pm-suspend

So that no one needs the password to execute pm-suspend utility.

Then I have my i3 config file, where I added this:

bindsym $mod+p exec suspendandlock

Where $mod is the Mod4 key. The script works fine from gnome-terminal when I type the suspendandlock command -> it suspends the system and blocks the screen as expected.

But when I type Mod4+p from keyboard it only blocks the screen without executing pm-suspend. Why does it not work?

Does anyone knows where I am wrong?

like image 346
tonix Avatar asked Dec 01 '13 14:12

tonix


People also ask

How do I close windows on i3?

To close an window, press Alt+Shift+Q. This tells i3 to send a regular "close window" command to the application, that is, shutting it down gracefully.

How to logout in i3 wm?

To logout, press Mod+shift+e (like exit).


1 Answers

It looks like OP solved the problem, but for anyone else who needed to fix it (myself included), just run:

sudo usermod -aG users `whoami`
which pm-suspend || sudo apt-get install pm-utils #make sure you have pm-suspend command, install it if you don't

run sudo visudo and add:

%users ALL = NOPASSWD: /usr/sbin/pm-suspend

and then add:

bindsym $mod+p exec "sudo pm-suspend | i3lock"

to ~/.i3/config. Running $mod+p will now lock and then suspend your computer.

like image 183
stonewareslord Avatar answered Oct 20 '22 04:10

stonewareslord