diff options
author | P. J. McDermott <pj@pehjota.net> | 2016-03-14 02:12:22 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2016-03-14 02:12:22 (EDT) |
commit | 069e68335ab88cb319071ff8fc432a6fecb7856b (patch) | |
tree | 001828d8df0c442a5cbd76759fbe40a57852645b | |
download | displayrc-069e68335ab88cb319071ff8fc432a6fecb7856b.zip displayrc-069e68335ab88cb319071ff8fc432a6fecb7856b.tar.gz displayrc-069e68335ab88cb319071ff8fc432a6fecb7856b.tar.bz2 |
Initial commit
-rwxr-xr-x | .displayinit | 65 | ||||
-rwxr-xr-x | .displayinit.d/fluxbox | 17 | ||||
-rw-r--r-- | .displayrc.common | 39 | ||||
-rw-r--r-- | .gitignore.d/displayrc | 18 |
4 files changed, 139 insertions, 0 deletions
diff --git a/.displayinit b/.displayinit new file mode 100755 index 0000000..3e96b6c --- /dev/null +++ b/.displayinit @@ -0,0 +1,65 @@ +#!/bin/sh + +run_parts() +{ + local level="${1}" + local action="${2}" + local i= + + if [ "x${level}" = 'x' ]; then + level="${HOME}/.displayinit.d/" + else + level="${HOME}/.displayrc.d/${level}" + fi + for i in "${level}"*; do + if [ -x "${i}" ]; then + if ! "${i}" "${action}"; then + return 1 + fi + fi + done + + return 0 +} + +main() +{ + local action= + + if [ ${#} -ne 1 ]; then + usage >&2 + return 1 + fi + action="${1}" + + # Enable services on first run. + if ! [ -d "${HOME}/.displayrc.d" ]; then + mkdir "${HOME}/.displayrc.d" + if ! run_parts 'enable'; then + return 1 + fi + fi + + # Start the session. + if ! run_parts "${action}"; then + return 1 + fi + + # Main loop. + rm -f ~/.displayrc.fifo + mkfifo -m 0600 ~/.displayrc.fifo + while read action; do + case "${action}" in + 'reload') + run_parts "${action}" + ;; + 'stop') + run_parts "${action}" + break + ;; + esac + done <~/.displayrc.fifo + rm -f ~/.displayrc.fifo +} + +main "${@}" diff --git a/.displayinit.d/fluxbox b/.displayinit.d/fluxbox new file mode 100755 index 0000000..75674b7 --- /dev/null +++ b/.displayinit.d/fluxbox @@ -0,0 +1,17 @@ +#!/bin/sh + +START=50 +STOP=50 + +start() +{ + fluxbox & + printf '%d\n' ${!} >"${HOME}/.display.run/fluxbox.pid" +} + +stop() +{ + kill $(cat "${HOME}/.display.run/fluxbox.pid") +} + +. "${HOME}/.displayrc.common" diff --git a/.displayrc.common b/.displayrc.common new file mode 100644 index 0000000..54a6dc3 --- /dev/null +++ b/.displayrc.common @@ -0,0 +1,39 @@ +#!/bin/sh +# TODO: Enable/disable actions + +type restart >/dev/null || +restart() +{ + stop + start +} + +type reload >/dev/null || +reload() +{ + stop + start +} + +usage() +{ + printf 'Usage: %s {start|stop|restart|reload}\n' "${0}" +} + +main() +{ + local action="${1}" + + case "${action}" in + 'start'|'stop'|'restart'|'reload');; + *) + usage >&2 + return 1 + ;; + esac + + "${action}" + return ${?} +} + +main "${@}" diff --git a/.gitignore.d/displayrc b/.gitignore.d/displayrc new file mode 100644 index 0000000..ac06328 --- /dev/null +++ b/.gitignore.d/displayrc @@ -0,0 +1,18 @@ +# Exclude all files +* + +# Include relevant files +!/.displayinit +!/.displayinit.d/ +!/.displayinit.d/**/* +!/.displayrc.common +# drc should be the UI to start/stop/restart/reload/enable/disable services. +!/bin/drc +!/.gitignore.d/ +!/.gitignore.d/displayrc + +# Exclude swap and backup files +*.s[a-w]? +*.vim +*~ +*.orig |