Spectrwm

From ArchWiki
Revision as of 12:53, 12 November 2009 by Aedit (Talk | contribs) (Starting scrotwm)

Jump to: navigation, search

scrotwm is a small dynamic tiling window manager for Xorg. It tries to stay out of the way so that valuable screen real estate can be used for much more important content. It has sane defaults and does not require one to learn a language to do any configuration. It was written by hackers for hackers and it strives to be small, compact and fast.

It is written in C and configured with a text configuration file. It is not the poster-boy for any minority language, either for programming or configuration.

Installation

scrotwm is not yet available in the main repositories.

Two PKGBUILDs are available in AUR: Template:Package AUR, the last snapshot release, and Template:Package AUR, the latest development repository.

The modkey (the main key to issue commands with) is set to Mod4, which is usually the Windows key.

scrotwm can make use of the dmenu package, so install that too:

# pacman -S dmenu

Template:Codeline is also useful:

# pacman -S xscreensaver

See Xdefaults for details of how to set up fonts, colours and other settings for Template:Codeline and Template:Codeline. Run Template:Codeline to select the animation (or blank) and display power management (recommended).

Configuration

scrotwm first tries to open the user specific file, Template:Filename. If that file is unavailable, it tries to open the global configuration file, Template:Filename. The initial configuration provides a good set of defaults.

Optionally, scrotwm can call Template:Filename (in the user's path), which should output a text status message to stdout for the status bar at the top of the screen.

Starting scrotwm

To start scrotwm via startx or the SLIM login manager, simply append the following to Template:Filename:

exec scrotwm

Starting scrotwm with CDM

For CDM, create Template:Filename like this:

logger "Starting scrotwm from /usr/bin/startscrotwm."
xrandr --dpi 96
xscreensaver -no-splash &
# and start the window manager
exec scrotwm

And add startscrotwm to Template:Filename:

...
wmbinlist=(startscrotwm ... )
...
wmdisplist=(Scrotwm ...)

Starting scrotwm with KDM

For KDM, create Template:Filename like this:

[Desktop Entry]
Type=XSession
Exec=/usr/bin/startwm scrotwm
TryExec=/usr/bin/startwm
Name=Scrotwm
Comment=The scrotwm window manager

Create Template:Filename like this, and set execute permission.

#!/bin/sh
$HOME/.xsession_$1

For each user create Template:Filename, and set execute permission.

logger "Starting scrotwm from ~/.xsession_scrotwm."
xrandr --dpi 96
xscreensaver -no-splash &
# and start the window manager
exec scrotwm

Log out and new entry "Scrotwm" will appear in KDM's list of window managers.

This technique can be used to run other window managers from KDM of course. Just create a Template:Filename file and a Template:Filename file for each one.

Statusbar configuration

There are two relevant items in Template:Filename. They are commented out by default.

bar_action              = baraction.sh
bar_delay               = 5

Place the following simple Template:Filename in a Template:Filename (or Template:Filename) directory which you have previously added to your $PATH in your ~/.bashrc file.

#!/bin/bash
# baraction.sh script for scrotwm status bar

SLEEP_SEC=5  # set bar_delay = 5 in /etc/scrotwm.conf
COUNT=0
#loops forever outputting a line every SLEEP_SEC secs
while :; do
	let COUNT=$COUNT+1
        echo -e "         Hello World! $COUNT"
        sleep $SLEEP_SEC
done

Here is a more useful example Template:Filename. Note it needs these packages, and whatever you need for WiFi:

pacman -S bc lm_sensors

You should configure lm_sensors.

#!/bin/bash
#baraction.sh for scrotwm status bar

SLEEP_SEC=5
#loops forever outputting a line every SLEEP_SEC secs
while :; do

	BAT_PRESENT=`awk '/present/ {print $2}' /proc/acpi/battery/BAT0/info`
	BAT_CHGSTATE=`awk '/charging state/     {print $3}' /proc/acpi/battery/BAT0/state`
	BAT_REMNG=`awk '/remaining capacity/ {print $3}' /proc/acpi/battery/BAT0/state`
	BAT_RATE=`awk '/present rate/       {print $3}' /proc/acpi/battery/BAT0/state`
	BAT_REMNG_WH=`echo "scale=1; a=($BAT_REMNG+50)/1000; print a" | bc -l`
	BAT_RATE_W=`echo "scale=1; a=($BAT_RATE+50)/1000; print a" | bc -l`

	BAT_LASTFULL=`awk '/last full capacity/ {print $4}' /proc/acpi/battery/BAT0/info`
	BCSCRIPT="scale=0; a=(100*$BAT_REMNG / $BAT_LASTFULL); print a"
	BAT_PCT=`echo $BCSCRIPT | bc -l`%

	case $BAT_PRESENT in
		no)
		POWER_STR="AC, NO BATTERY"
		;;
		yes)

		case $BAT_CHGSTATE in
			charged)
			#on ac
			AC_STATUS="ON AC"
			TIME_REMNG="N/A"
			POWER_STR="$AC_STATUS $BAT_CHGSTATE $BAT_PCT"
			;;
			charging)
			#on ac
			AC_STATUS="ON AC"
			BCSCRIPT="scale=1; a=(60*($BAT_LASTFULL - $BAT_REMNG) / $BAT_RATE); print a"
			TIMETOFULL_MIN=`echo $BCSCRIPT | bc -l`
			POWER_STR="$AC_STATUS $BAT_CHGSTATE $BAT_PCT C="$BAT_REMNG_WH"Wh Rate="$BAT_RATE_W"W TTF="$TIMETOFULL_MIN"min"
			;;
			discharging)
			AC_STATUS="ON BATT"
			TIME_REMNG_MIN=`echo "scale=0; a=(60*$BAT_REMNG / $BAT_RATE); print a" | bc -l`
			TIME_REMNG_HH=`echo "scale=0; a=($BAT_REMNG / $BAT_RATE); if (a<10) {print "0"; print a} else {print a}" | bc -l`

			TIME_REMNG_MM=`echo "scale=0; a=($TIME_REMNG_MIN-60*$TIME_REMNG_HH); if (a<10) {print "0"; print a} else {print a}" | bc -l`
			POWER_STR="$AC_STATUS $BAT_PCT C="$BAT_REMNG_WH"Wh P="$BAT_RATE_W"W R="$TIME_REMNG_HH":"$TIME_REMNG_MM
			;;
			*)
			POWER_STR=$BAT_CHGSTATE
			;;
		esac

		;;
		*)
		POWER_STR="error"
		;;
	esac

	#scrotwm bar_print can't handle UTF-8 characters, such as degree symbol
	#Core 0:      +67.0°C  (crit = +100.0°C)
	CORE0TEMP=`sensors 2>/dev/null | grep "Core 0" | sed s/[°+]//g | awk {'print $3'}`
	CORE1TEMP=`sensors 2>/dev/null | grep "Core 1" | sed s/[°+]//g | awk {'print $3'}`
	   FANSPD=`sensors 2>/dev/null | grep "fan1"                   | awk {'print $2'}`
	TEMP_STR="Tcpu=$CORE0TEMP,$CORE1TEMP F=$FANSPD"

	WLAN_ESSID=$(iwconfig wlan0 | awk -F "\"" '/wlan0/ { print $2 }')
	WLAN_QULTY=`awk '/wlan0/ {print $3}' /proc/net/wireless | sed s/[.]//g`
	BCSCRIPT="scale=0;a=100*$WLAN_QULTY/70;print a"
	WLAN_QPCT=`echo $BCSCRIPT | bc -l`
    	WLAN_SIGNL=`awk '/wlan0/ {print $4}' /proc/net/wireless | sed s/[.]//g`
	WLAN_NOISE=`awk '/wlan0/ {print $5}' /proc/net/wireless | sed s/[.]//g`
	WLAN_POWER=`iwconfig 2>/dev/null| grep "Tx-Power"| awk {'print $4'}|sed s/Tx-Power=//`
	WLAN_STR="$WLAN_ESSID: Q=$WLAN_QPCT% S/N="$WLAN_SIGNL"/"$WLAN_NOISE"dBm T="$WLAN_POWER"dBm"

	CPUFREQ_STR=`echo "Freq:"$(cat /proc/cpuinfo | grep 'cpu MHz' | sed 's/.*: //g; s/\..*//g;')`
	CPULOAD_STR="Load:$(uptime | sed 's/.*://; s/,//g')"

	eval $(awk '/^MemTotal/ {printf "MTOT=%s;", $2}; /^MemFree/ {printf "MFREE=%s",$2}' /proc/meminfo)
	MUSED=$(( $MTOT - $MFREE ))
	MUSEDPT=$(( ($MUSED * 100) / $MTOT ))
	MEM_STR="Mem:${MUSEDPT}%"

	echo -e "$POWER_STR  $TEMP_STR  $CPUFREQ_STR  $CPULOAD_STR  $MEM_STR  $WLAN_STR"
	sleep $SLEEP_SEC
done

Here are some other ideas for status bar items : ethernet, email notification, disk space, mounts.

Troubleshooting

  • Q: Help, I just logged in and all I see is a blank screen.
  • A: Press Shift + WindowsKey + Return and an xterm will start. Then read the manual (man scrotwm) to see the other default key bindings. Also check your configuration file.

See also

  • scrotwm - scrotwm's official website
  • dmenu - Simple application launcher from the developers of dwm