summaryrefslogtreecommitdiff
path: root/desktop/spectrwm/examples
diff options
context:
space:
mode:
authorLEVAI Daniel <leva@ecentrum.hu>2013-04-24 07:14:11 -0400
committerNiels Horn <niels.horn@slackbuilds.org>2013-04-28 12:30:03 -0300
commitdec4a7c0b052fe9181aa00af7f0ff5fa381128ec (patch)
tree7108c662fa198330834e2b10955147c3943fe79f /desktop/spectrwm/examples
parent16da631ccdfcd828c83ffeabe7eb57fd4604caf8 (diff)
downloadslackbuilds-dec4a7c0b052fe9181aa00af7f0ff5fa381128ec.tar.gz
desktop/spectrwm: Updated for version 2.2.0.
Signed-off-by: dsomero <xgizzmo@slackbuilds.org>
Diffstat (limited to 'desktop/spectrwm/examples')
-rw-r--r--desktop/spectrwm/examples/README31
-rw-r--r--desktop/spectrwm/examples/battery_status.sh30
-rw-r--r--desktop/spectrwm/examples/spectrwm.conf73
-rw-r--r--desktop/spectrwm/examples/spectrwm_baraction.sh98
-rw-r--r--desktop/spectrwm/examples/spectrwm_screenshot.sh21
-rw-r--r--desktop/spectrwm/examples/wifi_link_quality.sh10
6 files changed, 263 insertions, 0 deletions
diff --git a/desktop/spectrwm/examples/README b/desktop/spectrwm/examples/README
new file mode 100644
index 0000000000..f87f874257
--- /dev/null
+++ b/desktop/spectrwm/examples/README
@@ -0,0 +1,31 @@
+spectrwm_baraction.sh is the main script that can be set as the value for the
+bar_action option in spectrwm.conf.
+You can install it in your PATH and configure it like this (the values are just
+examples):
+bar_enabled = 1
+bar_font = -*-terminus-medium-*-*-*-14-*-*-*-*-*-*-*
+bar_action = spectrwm_baraction.sh
+
+This script uses the following utilities:
+o top(1) - installed on Slackware
+o free(1) - installed on Slackware
+o setxkbmap(1) - installed on Slackware
+o skb(1) - optional, can be used for alternative keyboard layout detection
+o battery_status.sh - optional
+ Needs the power_supply class in the /sys directory.
+o wifi_link_quality.sh - optional
+ Needs ip(8) from the iproute2 package and iwconfig(8) from the
+ wireless-tools package (both of which is installed on Slackware).
+
+
+spectrwm_screenshot.sh:
+This makes a screenshot of the actual X11 screen or optionally just a window.
+It needs the graphics/scrot package from the SBo repository.
+You can configure it in your spectrwm.conf like this:
+program[capture] = spectrwm_screenshot.sh full
+bind[capture] = MOD+c
+program[capture_w] = spectrwm_screenshot.sh window
+bind[capture_w] = MOD+Shift+c
+
+
+Needless to say, that these scripts must be in your PATH it the above cases.
diff --git a/desktop/spectrwm/examples/battery_status.sh b/desktop/spectrwm/examples/battery_status.sh
new file mode 100644
index 0000000000..2e0cc101a4
--- /dev/null
+++ b/desktop/spectrwm/examples/battery_status.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+
+PREF=/sys/class/power_supply/BAT0
+[ -r "${PREF}" ] || exit 1
+
+
+BATTERY_STATUS=$(< ${PREF}/status)
+
+typeset -i FULL_CAPACITY=$(< ${PREF}/charge_full)
+typeset -i WARNING_CAPACITY=$(( ${FULL_CAPACITY} * 20 / 100 ))
+typeset -i LOW_CAPACITY=$(( ${FULL_CAPACITY} * 10 / 100 ))
+typeset -i REMAINING_CAPACITY=$(< ${PREF}/charge_now)
+
+REMAINING_PERCENTAGE=$( echo "scale=1; ${REMAINING_CAPACITY} * 100 / ${FULL_CAPACITY}" |bc )
+
+
+case "${BATTERY_STATUS}" in
+ 'Full') # battery full
+ printf "AC"
+ ;;
+ 'Discharging') # battery discharging
+ printf "${REMAINING_PERCENTAGE}%%"
+ ;;
+ 'Charging') # battery charging
+ printf "AC^${REMAINING_PERCENTAGE}%%"
+ ;;
+esac
+
+exit 0
diff --git a/desktop/spectrwm/examples/spectrwm.conf b/desktop/spectrwm/examples/spectrwm.conf
new file mode 100644
index 0000000000..d4c4734480
--- /dev/null
+++ b/desktop/spectrwm/examples/spectrwm.conf
@@ -0,0 +1,73 @@
+# Spectrwm example script for SBo slackbuild.
+# See spectrwm(1) for information about the configuration options,
+# and examples/spectrwm_orig.conf under the package's documentation directory
+# for the original example configuration file which contains more options and
+# descriptions.
+
+# A rather long and informative bar with a custom date and time display.
+# Feel free to play around with the switches - after you've read the
+# spectrwm(1) man page ;)
+bar_enabled = 1
+bar_font = -*-terminus-medium-*-*-*-14-*-*-*-*-*-*-*
+bar_action = /home/daniell/bin/spectrwm_baraction.sh
+stack_enabled = 1 # current stacking algorithm
+clock_enabled = 1
+clock_format = %Y.%m.%d[%V] %a %H:%M.%S
+title_name_enabled = 1 # current window's title
+title_class_enabled = 1 # current window's class name
+window_name_enabled = 1 # current window's name
+urgent_enabled = 1 # information about the workspace's urgency hints
+verbose_layout = 0 # workspace's master and stack values
+
+focus_mode = default # default, follow, manual
+
+disable_border = 1 # remove window border when bar is disabled and
+ # there's only one window on a workspace
+
+#modkey = Mod4 # Win
+modkey = Mod1 # Alt
+
+# These will be started when spectrwm(1) starts.
+#autorun = ws[1]:urxvt
+#autorun = ws[1]:firefox
+#autorun = ws[2]:Thunar
+#autorun = ws[3]:liferea
+#autorun = ws[4]:audacious
+#autorun = ws[6]:libreoffice
+#autorun = ws[7]:skype
+
+# Custom window manager settings for specific programs
+quirk[mplayer2:gl] = FLOAT + FULLSCREEN
+quirk[mplayer2:xv] = FLOAT + FULLSCREEN
+quirk[ioquake3.i386:ioquake3.i386] = FLOAT
+quirk[openarena.i386:openarena.i386] = FLOAT
+quirk[Firefox-bin:firefox-bin] = TRANSSZ + FLOAT
+quirk[Firefox:Navigator] = TRANSSZ
+quirk[Firefox:Browser] = FLOAT
+quirk[Firefox:Toolkit] = FLOAT
+quirk[Firefox:Download] = FLOAT
+quirk[Firefox:Extension] = FLOAT
+quirk[Chrome:chrome] = TRANSSZ
+quirk[Gimp:gimp] = NONE
+
+
+# These are custom bindings:
+# See example/keybindings/spectrwm_*.conf under the package' documentation
+# directory for more information.
+#keyboard_mapping = ~/.spectrwm.binds
+
+# executes this on bind[term]
+#spawn_term = /usr/bin/urxvt
+
+# Example key bindings (see spectrwm(1) and the 'keyboard_mapping' option above):
+program[capture] = spectrwm_screenshot.sh full
+bind[capture] = MOD+c
+program[capture_w] = spectrwm_screenshot.sh window
+bind[capture_w] = MOD+Shift+c
+
+program[lock] = xlock -mode blank -bg black -fg white
+bind[lock] = MOD+Control+l
+bind[lock] = XF86Sleep
+
+program[media] = audacious
+bind[media] = XF86Media
diff --git a/desktop/spectrwm/examples/spectrwm_baraction.sh b/desktop/spectrwm/examples/spectrwm_baraction.sh
new file mode 100644
index 0000000000..eed84c15b3
--- /dev/null
+++ b/desktop/spectrwm/examples/spectrwm_baraction.sh
@@ -0,0 +1,98 @@
+#!/bin/sh
+
+
+typeset -i USED=0
+typeset -i AVAIL=0
+typeset -i FREE=0
+typeset -i CACHED=0
+_mem() {
+ case "${OS}" in
+ 'OpenBSD')
+ TOP_OUT=$(top -b -1 -d 1 |egrep ^Memory:)
+ USED=$(echo ${TOP_OUT} |cut -d' ' -f3 |cut -d/ -f1 |tr -d M)
+ AVAIL=$(echo ${TOP_OUT} |cut -d' ' -f3 |cut -d/ -f2 |tr -d M)
+ FREE=$(echo ${TOP_OUT} |cut -d' ' -f6 |tr -d M)
+ CACHED=$(echo ${TOP_OUT} |cut -d' ' -f8 |tr -d M)
+ ;;
+ 'Linux')
+ FREE_OUT=$(free -m |egrep ^Mem: |tr -s ' ')
+ USED=$(echo ${FREE_OUT} |cut -d' ' -f3)
+ AVAIL=$(echo ${FREE_OUT} |cut -d' ' -f2)
+ FREE=$(echo ${FREE_OUT} |cut -d' ' -f4)
+ CACHED=$(echo ${FREE_OUT} |cut -d' ' -f7)
+ ;;
+ esac
+
+ MEM_OUTPUT="U: ${USED}/${AVAIL} C: ${CACHED} - ${FREE}"
+}
+
+typeset -i USER=0
+typeset -i NICE=0
+typeset -i SYS=0
+typeset -i IO=0
+typeset -i IDLE=0
+_cpu() {
+ case "${OS}" in
+ 'OpenBSD')
+ TOP_OUT=$(top -b -1 -s 1 -d 2 |egrep '^All CPUs' |tail -n1 |tr -d '[a-z %]' |cut -d: -f2-)
+ NICE=$(echo ${TOP_OUT} |cut -d, -f2 |cut -d. -f1)
+ SYS=$(echo ${TOP_OUT} |cut -d, -f3 |cut -d. -f1)
+ IO=$(echo ${TOP_OUT} |cut -d, -f4 |cut -d. -f1)
+ IDLE=$(echo ${TOP_OUT} |cut -d, -f5 |cut -d. -f1)
+ USER=$(echo ${TOP_OUT} |cut -d, -f1 |cut -d. -f1)
+ ;;
+ 'Linux')
+ # using top(1)
+ TOP_OUT=$(top -b -d 0.1 -n 2 |egrep ^Cpu |tail -n1 |tr -d '%usynidwaht ' |cut -d: -f2-)
+ NICE=$(echo ${TOP_OUT} |cut -d, -f3 |cut -d. -f1)
+ SYS=$(echo ${TOP_OUT} |cut -d, -f2 |cut -d. -f1)
+ IO=$(echo ${TOP_OUT} |cut -d, -f5 |cut -d. -f1)
+ IDLE=$(echo ${TOP_OUT} |cut -d, -f4 |cut -d. -f1)
+ USER=$(echo ${TOP_OUT} |cut -d, -f1 |cut -d. -f1)
+
+ # using iostat(1)
+ #IOSTAT_OUT=$(iostat -c 1 2 |tail -n2 |head -n1 |tr -s ' ' |tr ' ' '|')
+ #NICE=$(echo ${IOSTAT_OUT} |cut -d\| -f3 |cut -d, -f1)
+ #SYS=$(echo ${IOSTAT_OUT} |cut -d\| -f4 |cut -d, -f1)
+ #IO=$(echo ${IOSTAT_OUT} |cut -d\| -f5 |cut -d, -f1)
+ #IDLE=$(echo ${IOSTAT_OUT} |cut -d\| -f7 |cut -d, -f1)
+ #USER=$(echo ${IOSTAT_OUT} |cut -d\| -f2 |cut -d, -f1)
+ ;;
+ esac
+
+ CPU_OUTPUT="U: ${USER} S: ${SYS} N: ${NICE} I: ${IO} - ${IDLE}"
+}
+
+_xkb_layout() {
+ # this won't work with "XkbLayout" "us,hu" like setups:
+ CURRENT_LAYOUT=$(setxkbmap -query |awk '/^layout:/ {print $2}')
+
+ # ... but if you have skb(1)
+ #CURRENT_LAYOUT=$(skb -1)
+
+ XKB_LAYOUT_OUTPUT="[${CURRENT_LAYOUT}]"
+}
+
+_battery() {
+ BAT_OUTPUT=$(battery_status.sh)
+}
+
+_wifi() {
+ WIFI_OUTPUT=$(wifi_link_quality.sh)
+}
+
+
+OS=$(uname -s)
+CPU_OUTPUT=''
+MEM_OUTPUT=''
+XKB_LAYOUT_OUTPUT=''
+WIFI_OUTPUT=''
+BAT_OUTPUT=''
+while :;do
+ _cpu; echo -n "${CPU_OUTPUT} "
+ _mem; echo -n "${MEM_OUTPUT} "
+ _xkb_layout; echo -n "${XKB_LAYOUT_OUTPUT} "
+ _wifi; echo -n "${WIFI_OUTPUT} "
+ _battery; echo -n "${BAT_OUTPUT} "
+ echo
+done
diff --git a/desktop/spectrwm/examples/spectrwm_screenshot.sh b/desktop/spectrwm/examples/spectrwm_screenshot.sh
new file mode 100644
index 0000000000..6a01fd67a6
--- /dev/null
+++ b/desktop/spectrwm/examples/spectrwm_screenshot.sh
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+
+SCROT=$(which scrot)
+[ -x "${SCROT}" ] || exit 1
+
+screenshot() {
+ case $1 in
+ full)
+ "${SCROT}" --multidisp
+ ;;
+ window)
+ sleep 0.5
+ "${SCROT}" --select
+ ;;
+ *)
+ ;;
+ esac;
+}
+
+screenshot $1
diff --git a/desktop/spectrwm/examples/wifi_link_quality.sh b/desktop/spectrwm/examples/wifi_link_quality.sh
new file mode 100644
index 0000000000..30c189b0c3
--- /dev/null
+++ b/desktop/spectrwm/examples/wifi_link_quality.sh
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+
+wlan_int=wlan0
+
+/sbin/ip link show dev ${wlan_int} >/dev/null 2>&1 || exit 1
+/sbin/ip link show dev ${wlan_int} 2>&1 |fgrep -q -e"state DOWN" && exit 1
+
+LINK_QUALITY=$( /sbin/iwconfig "${wlan_int}" 2>&1 |fgrep -e'Link Quality' |tr -s ' ' |cut -d' ' -f3 |cut -d= -f2 )
+echo "{${LINK_QUALITY}}"