LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   i3wm "mode_system" i3exit reboot/shutdown script inaction. (https://www.linuxquestions.org/questions/linux-newbie-8/i3wm-mode_system-i3exit-reboot-shutdown-script-inaction-4175623765/)

globetrotterdk 02-15-2018 03:38 AM

i3wm "mode_system" i3exit reboot/shutdown script inaction.
 
In reference to the comments in this post, I am trying to create a "mode_system" i3exit script that fits my basic needs. Unfortunately, without any success. I am using the i3wm on Devuan Jessie.

Here is the code that I am using for my i3 config file:
Code:

set $mode_system System (r) reboot, (s) shutdown
mode "$mode_system" {
    bindsym r exec --no-startup-id ~/.i3/i3exit reboot, mode "default"
    bindsym s exec --no-startup-id ~/.i3/i3exit shutdown, mode "default"

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

Here is my script, which is my first bash script:
Code:

#!/bin/sh
case "$1" in

    reboot)
bindsym $mod+Ctrl+r exec dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
        ;;
    shutdown)
bindsym $mod+Ctrl+s exec dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
        ;;
    *)
        echo "Usage: $0 {reboot|shutdown}"
        exit 2
esac

exit 0

I have made sure to run chmod +x on the i3exit script to make it executable. Not really sure where to go from here...

ondoho 02-15-2018 01:57 PM

the second is a shell script: i don't think it can make any sense of the i3 syntax you are using.

fwiw, i have this snippet in my i3 config:
Code:

# exit i3 (logs you out of your X session)
set $System System (l) logout, (s) suspend, (h) hibernate, (r) reboot, (Shift+s) shutdown
mode "$System" {
    bindsym l exec --no-startup-id i3-msg exit, mode "default"
    bindsym s exec --no-startup-id systemctl suspend, mode "default"
    bindsym h exec --no-startup-id systemctl hibernate, mode "default"
    bindsym r exec --no-startup-id systemctl reboot, mode "default"
    bindsym Shift+s exec --no-startup-id systemctl poweroff -i, mode "default" 

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}
bindsym $mod+Shift+q mode "$System"


globetrotterdk 02-16-2018 09:49 AM

Thanks, but Devuan is systemd free. The dbus commands work by themselves in the i3 config file:
Code:

Reboot !! NO WARNING !!
bindsym $mod+Ctrl+r exec dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
Shutdown !! NO WARNING !!
bindsym $mod+Ctrl+s exec dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop

I would therefore assume that there is either something wrong with the "set mode_system" command or the i3exit script.

ondoho 02-17-2018 03:53 AM

Quote:

Originally Posted by globetrotterdk (Post 5820418)
Thanks, but Devuan is systemd free.

up to you to rewrite or not use that snippet then.

Quote:

I would therefore assume that there is either something wrong with the "set mode_system" command or the i3exit script.
i already told you, that script contains invalid syntax:
Quote:

Originally Posted by ondoho (Post 5820239)
the second is a shell script: i don't think it can make any sense of the i3 syntax you are using.


globetrotterdk 02-17-2018 06:21 AM

Quote:

Originally Posted by ondoho (Post 5820745)
i already told you, that script contains invalid syntax:

I do not consider a dbus based command, when my system does not use systemd, to be "invalid syntax". The script which my i3 config snippet refers to, contains dbus based commands that do the same thing. The reference to "systemctl" in your script, refers to systemd. From the Arch wiki:
Quote:

The main command used to introspect and control systemd is systemctl.

ondoho 02-17-2018 02:27 PM

forget about systemd, i'm taklking about this shell script:
Quote:

Originally Posted by globetrotterdk (Post 5820027)
Here is my script, which is my first bash script:
Code:

#!/bin/sh
case "$1" in

    reboot)
bindsym $mod+Ctrl+r exec dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
        ;;
    shutdown)
bindsym $mod+Ctrl+s exec dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
        ;;
    *)
        echo "Usage: $0 {reboot|shutdown}"
        exit 2
esac

exit 0


i don't know how many more ways i can say this, but you are using commands that only i3 can understand. it MUST fail:
Code:

bindsym
bash: bindsym: command not found

btw, if you think this is a bash script, you should use the bash shebang:
#!/bin/bash


All times are GMT -5. The time now is 04:42 AM.