LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-15-2018, 04:38 AM   #1
globetrotterdk
Member
 
Registered: Nov 2006
Posts: 205

Rep: Reputation: 14
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...
 
Old 02-15-2018, 02:57 PM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 13,223
Blog Entries: 9

Rep: Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617
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"
 
Old 02-16-2018, 10:49 AM   #3
globetrotterdk
Member
 
Registered: Nov 2006
Posts: 205

Original Poster
Rep: Reputation: 14
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.
 
Old 02-17-2018, 04:53 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 13,223
Blog Entries: 9

Rep: Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617
Quote:
Originally Posted by globetrotterdk View Post
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 View Post
the second is a shell script: i don't think it can make any sense of the i3 syntax you are using.
 
Old 02-17-2018, 07:21 AM   #5
globetrotterdk
Member
 
Registered: Nov 2006
Posts: 205

Original Poster
Rep: Reputation: 14
Quote:
Originally Posted by ondoho View Post
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.

Last edited by globetrotterdk; 02-17-2018 at 07:28 AM.
 
Old 02-17-2018, 03:27 PM   #6
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 13,223
Blog Entries: 9

Rep: Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617Reputation: 3617
forget about systemd, i'm taklking about this shell script:
Quote:
Originally Posted by globetrotterdk View Post
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
 
1 members found this post helpful.
  


Reply

Tags
devuan


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Used to shutdown/reboot from CLI but since systemd replaced init "shutdown" cmnd broke? Beagleburt Debian 10 09-24-2019 08:49 PM
What is the difference between "reboot" and "shutdown -r now" dlugasx Linux - Server 3 09-19-2014 09:13 PM
[FYI] "last -f <old wtmp> -x reboot shutdown" incorrect for last reboot and shutdown catkin Linux - General 1 03-26-2010 12:52 AM
"shutdown" and "halt" symlinks: poweroff, reboot. sud_crow Linux From Scratch 11 10-18-2006 12:03 AM
Removing "shutdown" and "reboot" in logout window nearfar Red Hat 1 10-07-2003 12:33 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration