The i3 FAQ has migrated to https://github.com/i3/i3/discussions. All content here is read-only.
Ask Your Question
1

[debian]Not able to get the reboot/suspend script work.

asked 2014-03-23 12:42:07 +0000

neo1691 gravatar image

Hi, I am trying to get the reboot/suspend script work from i3 control mode as follows. I have created a script called i3exit , and placed it in ~/bin/ directory, this directory is my PATH.

Here are the contents of the script.

#!/bin/sh
lock() {
    i3lock
}

case "$1" in
    lock)
        i3lock -d -i /home/neo1691/.i3/i3lock_screen.png -n
        ;;
    logout)
        i3-msg exit
        ;;
    suspend)
        sudo pm-suspend
        ;;
    hibernate)
        sudo pm-hibernate
        ;;
    reboot)
        sudo reboot
        ;;
    shutdown)
        sudo halt
        ;;
    *)
        echo "Usage: $0 {lock|logout|suspend|hibernate|reboot|shutdown}"
        exit 2
esac

Next in .i3/config I have added these lines,

set $mode_system System (l) lock, (e) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
mode "$mode_system" {
    bindsym l exec --no-startup-id i3exit lock, mode "default"
    bindsym e exec --no-startup-id i3exit logout, mode "default"
    bindsym s exec --no-startup-id i3exit suspend, mode "default"
    bindsym h exec --no-startup-id i3exit hibernate, mode "default"
    bindsym r exec --no-startup-id i3exit reboot, mode "default"
    bindsym Shift+s exec --no-startup-id i3exit shutdown, mode "default"  

    # back to normal: Enter or Escape
         bindsym Return mode "default"
             bindsym Escape mode "default"
             }
             bindsym $mod+Pause mode "$mode_system"

Now if I run i3exit suspend, then my laptop suspends properly. [After asking the password]. If I run i3exit lock, then my laptop gets locked, without asking for the password.

But when I press $mod+pause the control mod popups appears on the i3statusbar and if I press l (lock) nothing happens and the dialogue box disappears!

If I open up a terminal and echo $PATH, then my folder, ~/bin is seen there. But if I run this specific command: tr '\0' '\n' </proc/$(pidof i3)/environ | grep PATH then the $PATH doesn't have the concerned folder.

Also, will adding this line : neo1691 ALL=(ALL) ALL, NOPASSWD: /home/neo1691/bin/i3exit will stop asking passwords if I run i3exit. I just want to make sure of the syntax!

Any ideas will be appreciated. Thanks

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2014-04-01 08:45:47 +0000

neo1691 gravatar image

The problem was indeed related to the PATH variable, and in case of lightdm it so happens that the ~/.xsessionrc file is read.

So the simple solution was to export my $PATH in ~/.profile and source it in ~/.xsessionrc

edit flag offensive delete link more
0

answered 2014-03-23 20:10:36 +0000

joepd gravatar image

That was a long way of saying that the path set in the config file of your shell is not picked up by i3;) Depending on a few things with Debian and your setup, one of the following could help:

  • Export your newly set $PATH in the bash profile file, that also gets executed with a non-login shell
  • Maybe however the Shell that executes i3 is dash and not bash, not sure which config files it uses
  • Export it in ~/.xinitrc, before you launch i3, if your login manager uses that file. That would make this PATH available to all graphical applications as well.
  • Set the full path of the executable in your i3 config file.

Good luck!

edit flag offensive delete link more

Comments

I tried exporting the PATH variable as export PATH=${PATH}:/home/neo1691/bin in .xinitrc, .bash_profile as well as /etc/profile. But nothing seem to work. $SHELL says /bin/bash!

neo1691 gravatar imageneo1691 ( 2014-03-24 21:33:13 +0000 )edit

Question Tools

Stats

Asked: 2014-03-23 12:42:07 +0000

Seen: 1,476 times

Last updated: Apr 01 '14