Welcome!
Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

[SOLVED] i3 wm shutdown commands for SysV

Help for Current Versions of MX
Message
Author
User avatar
mikeswifty
Forum Novice
Forum  Novice
Posts: 48
Joined: Wed Jul 26, 2017 9:39 pm

[SOLVED] i3 wm shutdown commands for SysV

#1 Post by mikeswifty » Wed Nov 07, 2018 9:52 pm

I could use a little help. Just started using the i3 tiling window manager with mx linux a couple of days ago and I really like it. However, the commands to logout, suspend, hibernate, reboot, and shutdown the system are intended to be used in distros using systemd. As such, when I go to shutdown my system, nothing happens. Could anyone tell me what the appropriate sysv commands are? Here's the config:

Code: Select all

set $Locker i3lock && sleep 1

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 $Locker, mode "default"
    bindsym e exec --no-startup-id i3-msg exit, mode "default"
    bindsym s exec --no-startup-id $Locker && systemctl suspend, mode "default"
    bindsym h exec --no-startup-id $Locker && 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+Pause mode "$mode_system"
Last edited by mikeswifty on Thu Nov 08, 2018 9:47 pm, edited 3 times in total.

User avatar
timkb4cq
Forum Veteran
Forum Veteran
Posts: 4482
Joined: Wed Jul 12, 2006 4:05 pm

Re: i3 wm shutdown commands for SysV

#2 Post by timkb4cq » Wed Nov 07, 2018 11:11 pm

From the userguide.html doc file from the Jessie backport version (prior to debian going to systemd)

Code: Select all

You can make i3 reload its configuration file with reload. You can also restart i3 inplace with the restart command to get it out of some weird state (if that should ever happen) or to perform an upgrade without having to restart your X session. To exit i3 properly, you can use the exit command, however you don’t need to (simply killing your X session is fine as well).

Examples:

bindsym $mod+Shift+r restart
bindsym $mod+Shift+w reload
bindsym $mod+Shift+e exit
sudo halt will power off
sudo pm-suspend suspends
sudo pm-hibernate hibernates
sudo pm-suspend-hybrid and sudo pm-powersave are also available.
That should give you a starting point at least.
MSI 970A-G43 MB, AMD FX-6300 (six core), 16GB RAM, GeForce 730, Samsung 850 EVO 250GB SSD, Seagate Barracuda XT 3TB

User avatar
mikeswifty
Forum Novice
Forum  Novice
Posts: 48
Joined: Wed Jul 26, 2017 9:39 pm

Re: i3 wm shutdown commands for SysV

#3 Post by mikeswifty » Thu Nov 08, 2018 9:25 am

Yes, and ending the i3 session takes you back to the login screen. But I want to shutdown or reboot the computer from within the i3 session. I don't want the extra step of typing in a code to log out of the i3 session and then going to the power icon on the login screen and hitting that in order to shutdown or reboot the computer. I guess I could just launch the terminal every time to type the command from within the i3 session. I DID try "poweroff" and "halt" from the terminal within the i3 session and got the message "must be superuser". But I thought "poweroff" was one of the commands in the sudoers file in /etc/sudoers. Shouldn't that mean I can run it from the regular terminal without sudo? If so, then my problem is (also) that when i3 is started it is not looking at the sudoers file. Tried just putting "halt" in the config on the poweroff line but that doesn't do anything either.

User avatar
v3g4n
Forum Guide
Forum Guide
Posts: 1792
Joined: Sat Jan 16, 2016 8:20 pm

Re: i3 wm shutdown commands for SysV

#4 Post by v3g4n » Thu Nov 08, 2018 10:55 am

There are a few options provided in this article. Whichever option you choose you should then just have to bind the command to a keyboard shortcut.
https://unix.stackexchange.com/question ... ormal-user

User avatar
dolphin_oracle
Forum Veteran
Forum Veteran
Posts: 10052
Joined: Sun Dec 16, 2007 1:17 pm

Re: i3 wm shutdown commands for SysV

#5 Post by dolphin_oracle » Thu Nov 08, 2018 11:02 am

mikeswifty wrote:
Thu Nov 08, 2018 9:25 am
Yes, and ending the i3 session takes you back to the login screen. But I want to shutdown or reboot the computer from within the i3 session. I don't want the extra step of typing in a code to log out of the i3 session and then going to the power icon on the login screen and hitting that in order to shutdown or reboot the computer. I guess I could just launch the terminal every time to type the command from within the i3 session. I DID try "poweroff" and "halt" from the terminal within the i3 session and got the message "must be superuser". But I thought "poweroff" was one of the commands in the sudoers file in /etc/sudoers. Shouldn't that mean I can run it from the regular terminal without sudo? If so, then my problem is (also) that when i3 is started it is not looking at the sudoers file. Tried just putting "halt" in the config on the poweroff line but that doesn't do anything either.
if its in the sudoers file then it depends on how its in the sudoers file. poweroff and halt for instance are in there so they don't ask for passwords, but they do need to be invoked with sudo still.
http://www.youtube.com/runwiththedolphin
lenovo ThinkPad T530 - MX-17
lenovo s21e & 100s - antiX-17, MX17(live-usb)
FYI: mx "test" repo is not the same thing as debian testing repo.

User avatar
mikeswifty
Forum Novice
Forum  Novice
Posts: 48
Joined: Wed Jul 26, 2017 9:39 pm

Re: i3 wm shutdown commands for SysV

#6 Post by mikeswifty » Thu Nov 08, 2018 3:02 pm

Yeah, looks like the methods suggested in the unix.stackexchange link just make it so you are not asked for a password. I tried the first and third ones from that webpage with no luck. Couldn't shut down with the i3 keybindings, so I went to the terminal and entered "poweroff". I got the same message that I had to be a superuser. So I guess the config I have for i3 is intended for systemd only and will not work with SysV (at least the part I posted regarding shutdown--everything else that I didn't post is working fine). For now, I'll just open terminal as root in order to reboot or poweroff.
Last edited by mikeswifty on Thu Nov 08, 2018 3:56 pm, edited 1 time in total.

User avatar
mikeswifty
Forum Novice
Forum  Novice
Posts: 48
Joined: Wed Jul 26, 2017 9:39 pm

Re: i3 wm shutdown commands for SysV

#7 Post by mikeswifty » Thu Nov 08, 2018 3:56 pm

I just had a thought: Since the procedures from unix.stackexchange.com make it so you won't need to enter a password, couldn't I use gksudo in the config file and make it work? I tried creating a new file under /etc/sudoers.d and named it 'shutdown' as they instructed. It contains:

Code: Select all

# Allows me to shutdown the system without a password

yourUserName ALL = NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff
After that, I went to the i3 config file and changed the poweroff line like this:

Code: Select all

bindsym s exec --no-startup-id gksudo poweroff
I got a popup telling me that the action was performed without a password, but instead of shutting down the computer it just logged me out. Don't know where to go from here.

[EDIT] I just tried it again and think it may be a part of the error handling for the config file. The popup opened again and this time I just waited... nothing happened until I closed the popup and started typing something else in another window and then it logged me out of i3. Weird.

User avatar
fehlix
Forum Guide
Forum Guide
Posts: 2395
Joined: Wed Apr 11, 2018 5:09 pm

Re: i3 wm shutdown commands for SysV

#8 Post by fehlix » Thu Nov 08, 2018 4:43 pm

Well, let's summarize the provided solutions given above:

You'll need to change i3-keybindings for a running i3 booting in SysVinit with MX17.1 Linux as such:

Code: Select all

bindsym $mod+Pause mode "$mode_system"

set $Locker i3lock && sleep 1

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 $Locker, mode "default"
    bindsym e exec --no-startup-id i3-msg exit, mode "default"
    bindsym s exec --no-startup-id $Locker && sudo /usr/sbin/pm-suspend , mode "default"
    bindsym h exec --no-startup-id $Locker && sudo /usr/sbin/pm-hibernate, mode "default"
    bindsym r exec --no-startup-id sudo /sbin/reboot, mode "default"
    bindsym Shift+s exec --no-startup-id sudo /sbin/poweroff, mode "default"  

    # back to normal: Enter or Escape
    bindsym Return mode "default"
    bindsym Escape mode "default"
}

bindsym $mod+Pause mode "$mode_system"
In addtion from the command line you would run as normal user
( e.g in a terminal as normal user - no root user needed )

to halt / poweroff

Code: Select all

sudo poweroff
# or

Code: Select all

sudo halt
to reboot:

Code: Select all

sudo reboot
No password shall be needed to run these commands in MX Linux.
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
fehlix
Forum Guide
Forum Guide
Posts: 2395
Joined: Wed Apr 11, 2018 5:09 pm

Re: i3 wm shutdown commands for SysV

#9 Post by fehlix » Thu Nov 08, 2018 4:46 pm

mikeswifty wrote:
Thu Nov 08, 2018 3:56 pm
I tried creating a new file under /etc/sudoers.d and named it 'shutdown' as they instructed. It contains:

Code: Select all

# Allows me to shutdown the system without a password
Better don't touch sudoers files, you can block you system if done wrongly
You do not need this, this is already setup in MX Linux!
See my last post! above
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
mikeswifty
Forum Novice
Forum  Novice
Posts: 48
Joined: Wed Jul 26, 2017 9:39 pm

Re: i3 wm shutdown commands for SysV

#10 Post by mikeswifty » Thu Nov 08, 2018 6:41 pm

Thanks for the summary, fehlix. Looks like I wasn't following the syntax correctly. Unfortunately, I just did a copy/paste of your code into the i3 config, restarted i3, and tried to poweroff. Nothing happened. I'll follow your advice and remove the file from the sudoers.d folder as it doesn't appear to be part of the solution.

Post Reply

Return to “MX Help”