Added 'Custom Desktop' helper scripts
authorAndrew Sichevoi <k@thekondor.net>
Sun, 22 Jul 2012 14:42:36 +0000 (18:42 +0400)
committerAndrew Sichevoi <k@thekondor.net>
Sun, 22 Jul 2012 14:42:36 +0000 (18:42 +0400)
custom-desktop/custom-desktop.foundation [new file with mode: 0644]
custom-desktop/run-conky [new file with mode: 0755]
custom-desktop/set-random-wallpaper [new file with mode: 0755]
custom-desktop/set-timeout-lock [new file with mode: 0755]

diff --git a/custom-desktop/custom-desktop.foundation b/custom-desktop/custom-desktop.foundation
new file mode 100644 (file)
index 0000000..c1e639c
--- /dev/null
@@ -0,0 +1,32 @@
+###
+### This script is distributed in the terms of GNU GPL v3.0+
+### (c) Andrew Sichevoi, http://thekondor.net
+###
+### Name: custom-desktop.foundation
+### Description: foundation code to launch lightweight desktop applications
+### Notes: Every 'custom-desktop' application must define unique CD_APPNAME variable
+###        before inclusion of this file.
+###
+###        Settings of the foundation could be overridden through ~/.config/custom-desktop.settings file.
+###
+
+CUSTOM_DESKTOP_SETTINGS_FILE_EXTENSION=settings
+CUSTOM_DESKTOP_SETTINGS_DIRECTORY=${HOME}/.config
+CUSTOM_DESKTOP_SETTINGS_OVERRIDE=${CUSTOM_DESKTOP_SETTINGS_DIRECTORY}/custom-desktop.settings
+
+if [ -e "${CUSTOM_DESKTOP_SETTINGS_OVERRIDE}" ]; then
+  . ${CUSTOM_DESKTOP_SETTINGS_OVERRIDE}
+fi
+
+if [ -z "${CD_APPNAME}" ]; then
+  echo "CustomDesktop error: required variable 'CD_APPNAME' is not set"
+  exit 1
+fi
+
+### format: settings-directory/app-name.settings-extension
+### e.g.: /home/user/.config/bindkeys.settings
+CD_APP_SETTINGS_FILE=${CUSTOM_DESKTOP_SETTINGS_DIRECTORY}/${CD_APPNAME}.${CUSTOM_DESKTOP_SETTINGS_FILE_EXTENSION}
+
+if [ -e "${CD_APP_SETTINGS_FILE}" ]; then
+  . ${CD_APP_SETTINGS_FILE}
+fi
diff --git a/custom-desktop/run-conky b/custom-desktop/run-conky
new file mode 100755 (executable)
index 0000000..0edff3a
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+###
+### This script is distributed in the terms of GNU GPL v3.0+
+### (c) Andrew Sichevoi, http://thekondor.net
+###
+### Name: run-conky
+### Description: Helper script to run Conky
+### Notes: Extra environment allows to run Conky in locale differ from the system's one
+###
+###        Conky configuration file must provide disabled 'daemon' mode.
+###
+### Arguments:
+###   none
+###
+
+CONKY_EXTRA_ENVIRONMENT=
+CONKY_EXTRA_ARGUMENTS="-u 30"
+CONKY_THEME=default
+
+### <foundation>
+CD_APPNAME=conky
+. /usr/local/bin/custom-desktop.foundation
+### </foundation>
+
+CONKY_THEME_FILE=~/.conky/themes/${CONKY_THEME}/conkyrc
+
+(eval "${CONKY_EXTRA_ENVIRONMENT}"; setsid /usr/bin/conky -c ${CONKY_THEME_FILE} ${CONKY_EXTRA_ARGUMENTS})
diff --git a/custom-desktop/set-random-wallpaper b/custom-desktop/set-random-wallpaper
new file mode 100755 (executable)
index 0000000..ebff646
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+###
+### This script is distributed in the terms of GNU GPL v3.0+
+### (c) Andrew Sichevoi, http://thekondor.net
+###
+### Name: set-random-wallpaper
+### Description: Helper script to set random wallpapers through FEH
+### Notes: This script is based on the source listed on https://wiki.archlinux.org/index.php/Feh
+###
+###        Notification hook is introduced as a w/a to refresh conky with infrequent refresh interval.
+###
+### Arguments:
+###   none
+###
+
+### Default values
+WALLPAPER_DIRECTORY=${HOME}/.wallpapers
+ROTATE_TIME=15m
+NOTIFICATION_HOOK=
+
+### <foundation>
+CD_APPNAME=wallpaper
+. /usr/local/bin/custom-desktop.foundation
+### </foundation>
+
+shopt -s nullglob
+while true; do
+       files=()
+       for i in ${WALLPAPER_DIRECTORY}/*.jpg ${WALLPAPER_DIRECTORY}/*.png; do
+               [[ -f $i ]] && files+=("$i")
+       done
+       range=${#files[@]}
+
+       ((range)) && feh --bg-scale "${files[RANDOM % range]}"
+        if [ ! -z "${NOTIFICATION_HOOK}" ]; then
+          ${NOTIFICATION_HOOK}
+        fi
+
+       sleep ${ROTATE_TIME}
+done
diff --git a/custom-desktop/set-timeout-lock b/custom-desktop/set-timeout-lock
new file mode 100755 (executable)
index 0000000..ac1938c
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+###
+### This script is distributed in the terms of GNU GPL v3.0+
+### (c) Andrew Sichevoi, http://thekondor.net
+###
+### Name: set-timeout-lock
+### Description: Helper script to launch user-specified lock application by timeout
+### Notes: Lock application should NOT be a daemon
+###
+###        Time out is specified in minutes.
+###
+### Arguments:
+###   none
+###
+
+LOCK_APPLICATION=/usr/bin/slock
+LOCK_TIMEOUT=10
+
+### <foundation>
+CD_APPNAME=timeout-lock
+. /usr/local/bin/custom-desktop.foundation
+### </foundation>
+
+/usr/bin/xautolock -time ${LOCK_TIMEOUT} -locker "${LOCK_APPLICATION}"