Window Manager or Desktop Environment Independent End Session Script
Friday, January 8, 2010 8:12:50 PM
I have been working on my Arch Linux box for a while now and have found that I could run Compiz-Fusion Standalone.
It is up and running great!
The only issue I had was finding a way to log out (or log off) of my current session gracefully.
It seems everyone who is running Fusion Standalone has simply been killing their Xserver.
This isn't graceful and can lead to data loss, from what I've read. So, I did something about it.
I wrote this simple bash script to do a log off regardless of what WM or DE you are using.
Thus far, it works great!
First things first, my standard warning, this does require root privleges, and as such, can cause irreversible damage to your system. I take no responsibility for such. If you can follow simple instructions though, you should have no issues.
Ok then, now, we need to open up your favorite editor as root:
(remember, replace nano with your editor of choice)
Next, copy the below into the file and save it:
Now we need to make it executable:
All that's left to do is create a shortcut to this file on your panel/desktop/shortcut key (whatever you prefer) and give it an icon if you like.
(As a side note, you don't have to use /usr/bin/endsession - the file can be called whatever you want, just make sure it's in your user's $PATH. If on a multi user system, the location I mentioned should be good.)
Hope this simple bash script comes in handy for other users as well and fuels the Fusion Revolution
Happy Hacking
~PiklesOnFire~
It is up and running great!
The only issue I had was finding a way to log out (or log off) of my current session gracefully.
It seems everyone who is running Fusion Standalone has simply been killing their Xserver.
This isn't graceful and can lead to data loss, from what I've read. So, I did something about it.
I wrote this simple bash script to do a log off regardless of what WM or DE you are using.
Thus far, it works great!
First things first, my standard warning, this does require root privleges, and as such, can cause irreversible damage to your system. I take no responsibility for such. If you can follow simple instructions though, you should have no issues.
Ok then, now, we need to open up your favorite editor as root:
sudo nano /usr/bin/endsession
(remember, replace nano with your editor of choice)
Next, copy the below into the file and save it:
#!/bin/bash
##
## WM/DE independent Session Ender
## Rationale: I was using a Fusion Standalone session
## and quickly realized there was no way to log out
## of my current session without killing the X server.
## This script allows us to do that, regardless of WM/DE.
##
## By: PiklesOnFire
## User Defined Locations:
## Location of Zenity:
ZenLoc="/usr/bin/zenity"
## Location of Xmessage:
XmesLoc="/usr/bin/xmessage"
## End Editable Content
## Do not edit Below this line unless you are fixing a bug
## Or adding/changing functionality
function Quit {
exit 0
}
function Error {
exit 1
}
## This cleanly ends only the current user's session:
function EndSession {
skill -TERM -u $(whoami)&
sleep 5 &&
skill -KILL -u $(whoami) &&
## Following line only added for bash compatibility
Quit
}
## Check for Zenity, if fail, check for Xmessage,
## if fail, exit with error
function CheckLoc {
if [ -f $ZenLoc ]; then
ZenPrompt
else
if [ -f $XmesLoc ]; then
XPrompt
else
Error
fi
fi
}
## Use Xmessage to confirm:
function XPrompt {
answer=$(xmessage "Are you sure you want to shutdown? " \
-buttons yes,no -print)
if [ $answer = "yes" ]; then
EndSession
else
Quit
fi
}
## Use Zenity to confirm:
function ZenPrompt {
zenity --question --title "Log Off Confirmation" \
--text "Are you sure you want to end your current session?"
if [ "$?" -eq "0" ]; then
EndSession
else
Quit
fi
}
CheckLoc
Now we need to make it executable:
sudo chmod a+x /usr/bin/endsession
All that's left to do is create a shortcut to this file on your panel/desktop/shortcut key (whatever you prefer) and give it an icon if you like.
(As a side note, you don't have to use /usr/bin/endsession - the file can be called whatever you want, just make sure it's in your user's $PATH. If on a multi user system, the location I mentioned should be good.)
Hope this simple bash script comes in handy for other users as well and fuels the Fusion Revolution
Happy Hacking
~PiklesOnFire~















Unregistered user # Friday, July 30, 2010 7:07:54 AM
PiklesOnFire # Friday, August 20, 2010 8:04:22 PM
I have since linked this, a hibernate, a suspend, a shutdown and a restart button all in mygtkmenu. gotta love compiz standalone xD
Unregistered user # Tuesday, November 23, 2010 6:17:19 AM