From 27d38e2d940508af89865e2ddbd9853b60ce6ba3 Mon Sep 17 00:00:00 2001 From: Andrew Sichevoi Date: Sun, 22 Jul 2012 18:42:36 +0400 Subject: [PATCH] Added 'Custom Desktop' helper scripts --- custom-desktop/custom-desktop.foundation | 32 ++++++++++++++++++ custom-desktop/run-conky | 28 ++++++++++++++++ custom-desktop/set-random-wallpaper | 42 ++++++++++++++++++++++++ custom-desktop/set-timeout-lock | 25 ++++++++++++++ 4 files changed, 127 insertions(+) create mode 100644 custom-desktop/custom-desktop.foundation create mode 100755 custom-desktop/run-conky create mode 100755 custom-desktop/set-random-wallpaper create mode 100755 custom-desktop/set-timeout-lock diff --git a/custom-desktop/custom-desktop.foundation b/custom-desktop/custom-desktop.foundation new file mode 100644 index 0000000..c1e639c --- /dev/null +++ b/custom-desktop/custom-desktop.foundation @@ -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 index 0000000..0edff3a --- /dev/null +++ b/custom-desktop/run-conky @@ -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 + +### +CD_APPNAME=conky +. /usr/local/bin/custom-desktop.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 index 0000000..ebff646 --- /dev/null +++ b/custom-desktop/set-random-wallpaper @@ -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= + +### +CD_APPNAME=wallpaper +. /usr/local/bin/custom-desktop.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 index 0000000..ac1938c --- /dev/null +++ b/custom-desktop/set-timeout-lock @@ -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 + +### +CD_APPNAME=timeout-lock +. /usr/local/bin/custom-desktop.foundation +### + +/usr/bin/xautolock -time ${LOCK_TIMEOUT} -locker "${LOCK_APPLICATION}" -- 2.20.1