Shutdown and reboot commands for IceWM.

Everything about X, Gnome, KDE, ... and everything running on it

Shutdown and reboot commands for IceWM.

Postby secipolla » 2010-12-04 19:11

Formerly I used to set "sudo halt" and "sudo reboot" to shutdown/reboot icewm but I noticed this last time I installed the cited window manager that those commands left some processes running that had to be forcedly killed during shutdown, even taking some time for that.
So thanks to Connochaet OS I found apparently clean shutdown/reboot commands for IceWM.
~/.icewm/preferences:
Code: Select all
#  Command to shutdown the system
ShutdownCommand="dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop"

#  Command to reboot the system
RebootCommand="dbus-send --system --print-reply --dest=\"org.freedesktop.ConsoleKit\" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart"
secipolla
 
Posts: 1127
Joined: 2010-06-21 14:20

Re: Shutdown and reboot commands for IceWM.

Postby canci » 2010-12-05 15:03

Sweet! I found that a while ago when I ran Openbox on Arch. I also made zenity scripts that I bound
to my keys.

WARNING: The lines between then and else that start with dbus-send must be in 1 line. The browser will probably
break the lines depending on your browser window size.


Shutdown:

Code: Select all
#!/bin/bash
zenity --question --text="Shutdown?"

if [ $? == 0 ]
then
  dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop
else
  exit
fi



Reboot:

Code: Select all
#!/bin/bash
zenity --question --text="Restart?"

if [ $? == 0 ]
then
  dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart
else
  exit
fi



Suspend:

Code: Select all
#!/bin/bash
zenity --question --text="Suspend?"

if [ $? == 0 ]
then
  dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0
else
  exit
fi



Hibernate:

Code: Select all
#!/bin/bash
zenity --question --text="Hibernate?"

if [ $? == 0 ]
then
  dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate
else
  exit
fi



You will need the package zenity for this.

I am not sure anymore whether suspend and hibernate need HAL, but I'd guess they do, since they hint to it in the commands.
Someone please correct me if it's wrong.
I ken hez kinvulf beck? I ken hez riesnible modereyshn? Kthnxbai!

No need to discuss this topic? Offended by this signature? Remove it:

Mez wrote:You can easily just disable viewing signatures

Click here - and set "Display Signatures" to No
User avatar
canci
 
Posts: 1705
Joined: 2006-09-24 11:28
Location: Bosnia & Herzegovina

Re: Shutdown and reboot commands for IceWM.

Postby Lou » 2010-12-05 17:25

secipolla wrote:Formerly I used to set "sudo halt" and "sudo reboot" to shutdown/reboot icewm but I noticed this last time I installed the cited window manager that those commands left some processes running that had to be forcedly killed during shutdown, even taking some time for that.


After reading this i fired up icewm (it's my backup wm) and it took 6 seconds for a complete stop.

This is what i got in my .icewm/preferences for shutting down/rebooting:
Code: Select all
ShutdownCommand="sudo shutdown -h now"
RebootCommand="sudo shutdown -r now"


My way to shutdown my box is (after using a PII for years):
1. I close all apps one by one.
2. Ctrl+ space bar gives me blank space on the taskbar, and i write:
Code: Select all
sudo shutdown -h now


for rebooting i type: "sudo shutdown -r now"

and that's it :)
Last edited by Lou on 2010-12-06 00:14, edited 1 time in total.
Devuan Jessie - IceWM - vimperator - no DM
KISS - Keep It Simple, Stupid
Lou
 
Posts: 1775
Joined: 2006-05-08 02:15

Re: Shutdown and reboot commands for IceWM.

Postby canci » 2010-12-05 17:42

@Lou: I think the main advantage (or disadvantage? Depends on how you look at it) of the dbus approach over the usual one
is that you don't need to authenticate with sudo or become root.
I ken hez kinvulf beck? I ken hez riesnible modereyshn? Kthnxbai!

No need to discuss this topic? Offended by this signature? Remove it:

Mez wrote:You can easily just disable viewing signatures

Click here - and set "Display Signatures" to No
User avatar
canci
 
Posts: 1705
Joined: 2006-09-24 11:28
Location: Bosnia & Herzegovina

Re: Shutdown and reboot commands for IceWM.

Postby aspnair » 2010-12-05 17:47

is that you don't need to authenticate with sudo or become root

You could avoid it by adding a custom rule for "admin" users to use shutdown without password.

Code: Select all
%admin ALL=NOPASSWD: /sbin/shutdown, /sbin/poweroff, /sbin/reboot

create a group named "admin" and include the required uses to that group
Compressed Air Energy Storage, Entropy and Efficiency
http://saurorja.org/2012/06/18/compress ... fficiency/
User avatar
aspnair
 
Posts: 1247
Joined: 2009-06-18 12:27
Location: Twitter: @anand_sivaram

Re: Shutdown and reboot commands for IceWM.

Postby canci » 2010-12-05 18:04

I wonder which way is more secure... Can anyone expand on that?
I ken hez kinvulf beck? I ken hez riesnible modereyshn? Kthnxbai!

No need to discuss this topic? Offended by this signature? Remove it:

Mez wrote:You can easily just disable viewing signatures

Click here - and set "Display Signatures" to No
User avatar
canci
 
Posts: 1705
Joined: 2006-09-24 11:28
Location: Bosnia & Herzegovina

Re: Shutdown and reboot commands for IceWM.

Postby secipolla » 2010-12-05 18:09

@Lou
It depends on how you login.
If you use regular xsession or if you use a custom xinitrc, for instance.

Here, when shutting down it hung with icewm-session-experimental related tasks like ssh and maybe dbus itself (I didn't write them down). That happened even if I called 'killall icewm-session-experimental && sudo halt'.

Through the posted commands it shutdowns and reboots cleanly.
secipolla
 
Posts: 1127
Joined: 2010-06-21 14:20

Re: Shutdown and reboot commands for IceWM.

Postby Lou » 2010-12-06 00:03

@canci: i use sudo with no passwd.
Code: Select all
macondo ALL = NOPASSWD : ALL
giovi ALL = NOPASSWD: /sbin/halt, /sbin/reboot


@secipolla: i use a regular .xinitrc, i try to KISS everything.
Code: Select all
#!/bin/sh

setxkbmap -option terminate:ctrl_alt_bksp
xsetroot -solid black
xrdb -merge .Xdefaults
unclutter -idle 2 &
numlockx &
#conky &
#ratpoison
icewm


PS: I forgot to mention that to shutdown the machine i have this in my .icewm/keys:
Code: Select all
key "Super+Pause" sudo shutdown -h now


IOW, by pressing the Windows key and holding it down, and then pressing the Pause key, shuts the machine down.
Devuan Jessie - IceWM - vimperator - no DM
KISS - Keep It Simple, Stupid
Lou
 
Posts: 1775
Joined: 2006-05-08 02:15

Re: Shutdown and reboot commands for IceWM.

Postby secipolla » 2011-04-21 17:03

There's an all-in-one logout dialog based on a openbox logout script but using the commands we posted here.
One needs python-gtk2 for it to work.
Image
http://pastebin.com/p7Lp6CKD
secipolla
 
Posts: 1127
Joined: 2010-06-21 14:20

Re: Shutdown and reboot commands for IceWM.

Postby secipolla » 2011-05-02 17:49

I think it may be better to strip the Logout from that script, leaving only Shutdown, Reboot, Suspend and Hibernate. It's better to use the built-in IceWM logout because just calling 'killall icewm-session' may leave some processes runing (like keyring) depending on what's used.
secipolla
 
Posts: 1127
Joined: 2010-06-21 14:20

Re: Shutdown and reboot commands for IceWM.

Postby dystrenf » 2012-01-10 10:29

hi. i know this is an old post but maybe someone will be able to help.
i am trying to use the suggestion in the original post in order to shutdown a machine running icewm on wheezy using dbus without sudo.
when i add the ShutdownCommand as suggested, nothing happens when i press shutdown after alt+ctrl+del.
when i run the command in terminal as regular user i get 'Error org.freedesktop.ConsoleKit.Manager.NotPriveleged: Not Authorized'
when i run the command as root the machine halts.
any help would be much appreciated.
thanks
dystrenf
 
Posts: 1
Joined: 2012-01-10 10:05

Re: Shutdown and reboot commands for IceWM.

Postby secipolla » 2012-07-21 12:32

dystrenf wrote:hi. i know this is an old post but maybe someone will be able to help.
i am trying to use the suggestion in the original post in order to shutdown a machine running icewm on wheezy using dbus without sudo.
when i add the ShutdownCommand as suggested, nothing happens when i press shutdown after alt+ctrl+del.
when i run the command in terminal as regular user i get 'Error org.freedesktop.ConsoleKit.Manager.NotPriveleged: Not Authorized'
when i run the command as root the machine halts.
any help would be much appreciated.
thanks

In case other people have the same problem..
I'm not even using Debian right now so I can't deepen on this but that error is probably due to consolekit not running.
Most display managers (slim, lxdm, lightdm etc.) should take care of that automatically, but if starting the session with xinit (startx) then consolekit must be started with the proper command in ~/.xinitrc
secipolla
 
Posts: 1127
Joined: 2010-06-21 14:20


Return to Desktop & Multimedia

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable