Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Blogs > Whaling the FOSS
User Name


The experiences of an Australian student who uses Linux.

Cover all topics from shell scripts to monopolies and reviews to political comments.
Rate this Entry

Dumping the Desktop Environment

Posted 07-04-2011 at 01:10 AM by William (Dthdealer)
Updated 07-04-2011 at 01:11 AM by William (Dthdealer) (Categories)

A while ago I started using a proper desktop environment ( as opposed to independent window managers ). I did this with the false beliefs that it would make my life easier and that it would encourage more of my friends to try out free operating systems when they saw me using my computer.

Slowly I realised this was not true. Then I read this, and it sealed my fate:

I threw my DE away. No longer do I have to wait for a heavy environment to load, use the festering Gnome Login manager nor even have to deal with the uncertainty of how my environment will look in a few months time ( case in point: Gnome 3 ).

Although there is little activity regarding styles, fluxbox is my window manager of choice. It has multiple selling points, including its speed, tabbing functionality, easy configuration of everything via plain text files and its graphical minimalism. The one thing no window-manager can get right, it does perfectly - window shading.

Honestly, when I shade a window, I do not want to have resize handles and a bottom border rendered below the now floating title bar. XFCE's wm is a big culprit here, and its resize handles do nothing while the window is shaded other than hang there and look pretty ( you can't use them ).

I have yet to see another window manager that has the ease or range of customisability that Fluxbox has in simple old-fashioned plain text files. Any window manager that requires Gconf might as well require the windows registry. As far as my use of a computer goes, Gconf does nothing but complicate the procedure of doing anything. Why do I need to put every application's configuration in a central database? What is wrong with text files?

The Gnome Login Manager ( GDM ) used to be great, but has recently become a horrible thing to work with. Since GDM3 full-screen themes do not work and a multitude of customisation options have disappeared. GDM also defaults to a horrible GTK theme if the rest of Gnome is not installed. It also suffers a horrible startup time on my computer because for some reason it needs to start Xorg, stop Xorg, and then start it again before it greets me.

My computer now greets me with a completely customised SLiM login screen. Seeing as my main computer is a laptop, I now have my contact information backed into the login screen in case I lose the device and a good soul ( ie not a federal politician ) picks it up.

Although SLiM is run as root and can change the system runlevel ( to shutdown, reboot etc ), neither I nor my window manager know how to exploit this functionality. As a compromise, I have written this useful little script:


#	Zdown	-  Shutdown options GUI using Zenity and Gksudo

# Copyright William Hales 2011

#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    GNU General Public License for more details.
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <>.

################################ Lockfile


# Check to see if this program is already running via its lockfile
if [ -f $lockfile ]
	echo "$0: Lockfile found, this program is already running"
	echo "$0: To manually bypass/fix, delete $lockfile"
	exit 2;

# Create the lockfile
touch $lockfile

################################ User interface

# Ask what action the user wants to take
request=$( zenity --list --title "Power level change" --text "A power level change has been requested.\nChoose an operation:" --column "Action"  Poweroff Reboot Suspend Hibernate --height 256 )

if [ $? -ne 0 ]
	# user has pressed cancel, delete the lockfile and exit
	rm $lockfile
	echo "$0: User hit cancel, exiting with code 1"
	exit 1

# Choose appropiate command and description for each option
case $request in

	Poweroff  )	action="poweroff"; 	desc="de-energize ${HOSTNAME}'s dilithium crystals"  ;;
	Reboot    )	action="reboot";	desc="regumboot $HOSTNAME"   ;;
	Suspend   )	action="pm-suspend";	desc="suspend $HOSTNAME from school"   ;;
	Hibernate )	action="pm-hibernate";	desc="take $HOSTNAME into bear mode" ;;


# From here on the user cannot open another copy of this program unless they cancel
# at the gksudo prompt.  In either case, we don't want the lockfile anymore
rm $lockfile

# Gain root to perform the action
gksudo -m "Authentication is required to ${desc}.  Please enter your password to permit this action." $action

if [ $? -ne 0 ]
	# User hit cancel or gksudo failed
	echo "$0: gksudo returned code $?"
It uses Zenity to ask the user what action they want to take and then gets the elevated credentials required to perform it. A few things are assumed when you use this script:
  • You have bash, sudo, zenity and gksudo installed
  • Your system supports hibernation and suspension ( using the pm-suspend and pm-hibernate commands )
  • /dev/shm is a folder that exists and is writable by the current user
  • The current user is permitted the use of sudo for power-related commands

Remember, my script is open source and easily editable, so if something does not work you can fix it, and if you do not like something you can change it. Most of all you can learn how to write your own similar script by looking at my source.

Expect more soon.

Regards, William
Views 5706 Comments 2
« Prev     Main     Next »
Total Comments 2


  1. Old Comment
    Great post. I think I may give FluxBox a try on my Netbook to start.
    Posted 07-11-2011 at 06:39 AM by blingham blingham is offline
  2. Old Comment
    Originally Posted by blingham View Comment
    Great post. I think I may give FluxBox a try on my Netbook to start.
    Thanks Blingham,

    Be warned however Fluxbox has no in-built battery or power related features. You will have to use other tools to monitor your battery level and/or give instructions to force a hibernate when power is low, otherwise your computer will hang on until the last minute.

    XScreenSaver has features to to suspend/hibernate after a period of inactivity, but it does not offer anything else.

    I will probably write a script that monitors the power level myself and post it to my blog soon along with ( if I finish it ) a login manager written in shell scripts.

    Regards, William
    Posted 07-11-2011 at 07:24 PM by William (Dthdealer) William (Dthdealer) is offline
    Updated 07-11-2011 at 07:27 PM by William (Dthdealer)


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

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