Showing
27 changed files
with
1852 additions
and
0 deletions
keymanagement.sh
0 → 100644
1 | +SSH_KEYGEN="/usr/bin/ssh-keygen" | |
2 | +SSH_ADD="/usr/bin/ssh-add" | |
3 | + | |
4 | +export SSH_KEYGEN SSH_ADD | |
5 | + | |
6 | +IDENTITY_FILE="/mnt/auth/ghopp/.ssh/ident" | |
7 | +SSH_AGENT_FILE="${HOME}/.ssh/agent.info" | |
8 | + | |
9 | +GPG_TTY=$(tty) | |
10 | + | |
11 | +export IDENTITY_FILE SSH_AGENT_FILE GPG_TTY | |
12 | + | |
13 | +alias ssh_init_github="ssh-add /mnt/auth/ghopp/.ssh/ident-github ~/.ssh/getcred_github.sh" | |
14 | + | |
15 | +function ssh-keygen() { | |
16 | + ident="${1:-${IDENTITY_FILE}}" | |
17 | + ${SSH_KEYGEN} -f "${ident}" "$@" | |
18 | +} | |
19 | + | |
20 | +function ssh-add() { | |
21 | + ident="${1:-${IDENTITY_FILE}}" | |
22 | + ask_pass="${2:-${HOME}/.ssh/getcred.sh}" | |
23 | + | |
24 | + if [ '-' != "${ident:0:1}" ] | |
25 | + then | |
26 | + DISPLAY=:0.0 SSH_ASKPASS="${ask_pass}" \ | |
27 | + ${SSH_ADD} ${ident} 2>/dev/null </dev/null | |
28 | + else | |
29 | + ${SSH_ADD} "$@" | |
30 | + fi | |
31 | +} | |
32 | + | |
33 | +function ssh-init-agent() { | |
34 | + local CAT="/bin/cat" | |
35 | + local PS="/bin/ps" | |
36 | + local ECHO="/bin/echo" | |
37 | + local SSH_AGENT="/usr/bin/ssh-agent" | |
38 | + | |
39 | + test -e "${SSH_AGENT_FILE}" && eval `${CAT} "${SSH_AGENT_FILE}"` >/dev/null | |
40 | + | |
41 | + if [ "x" != x${SSH_AGENT_PID} ] | |
42 | + then | |
43 | + if [ "ssh-agent" = "`${PS} -p ${SSH_AGENT_PID} -o comm=`" ] | |
44 | + then | |
45 | + return | |
46 | + fi | |
47 | + fi | |
48 | + | |
49 | + ${ECHO} -n "start ssh-agent ... " | |
50 | + ${SSH_AGENT} >"${SSH_AGENT_FILE}" | |
51 | + if [ 0 -eq $? ] | |
52 | + then | |
53 | + eval `${CAT} "${SSH_AGENT_FILE}"` >/dev/null | |
54 | + ${ECHO} "OK" | |
55 | + ssh-add | |
56 | + else | |
57 | + ${ECHO} "FAILED" | |
58 | + fi | |
59 | +} | |
60 | + | |
61 | +function gpg-init-agent() { | |
62 | + local FUSER="/bin/fuser" | |
63 | + local CAT="/bin/cat" | |
64 | + local PS="/bin/ps" | |
65 | + local ECHO="/bin/echo" | |
66 | + local CUT="/usr/bin/cut" | |
67 | + local GPG_AGENT="/usr/bin/gpg-agent --daemon --allow-preset-passphrase" | |
68 | + local GPG_PRESET="/usr/libexec/gpg-preset-passphrase" | |
69 | + local CREDDIR="/mnt/auth/ghopp/gnupg/" | |
70 | + local KEYGRIP="D17D6099DA4F7CF580991F6525BAC9DB841C9B30" | |
71 | + local SUBKEYGRIP="BE4A9914142B488736792B9CBE01AE3A94D96E7A" | |
72 | + | |
73 | + if ${FUSER} ${HOME}/.gnupg/S.gpg-agent >/dev/null 2>&1 | |
74 | + then | |
75 | + return | |
76 | + else | |
77 | + ${ECHO} -n "start gpg-agent ... " | |
78 | + ${GPG_AGENT} | |
79 | + if [ 0 -eq $? ] | |
80 | + then | |
81 | + ${ECHO} "OK" | |
82 | + ${CAT} "${CREDDIR}/gpg.pw" | ${GPG_PRESET} --preset ${KEYGRIP} | |
83 | + ${CAT} "${CREDDIR}/gpg.pw" | ${GPG_PRESET} --preset ${SUBKEYGRIP} | |
84 | + else | |
85 | + ${ECHO} "FAILED" | |
86 | + fi | |
87 | + fi | |
88 | +} | |
89 | + | |
90 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tmp.sh
0 → 100644
1 | +#!/bin/bash -x | |
2 | + | |
3 | +TMPDIR="/tmp/${USER}/" | |
4 | + | |
5 | +test -d ${TMPDIR} || mkdir ${TMPDIR} | |
6 | +for dir in \ | |
7 | + ".cache" \ | |
8 | + ".adobe" \ | |
9 | + ".macromedia" \ | |
10 | + ".mozilla/firefox" \ | |
11 | + ".pentadactyl" \ | |
12 | + ".scummvm/logs" | |
13 | +do | |
14 | + test -d "${TMPDIR}${dir}" || mkdir -p "${TMPDIR}${dir}" | |
15 | +done | |
16 | + | |
17 | +for file in \ | |
18 | + ".dmenu_cache" \ | |
19 | + ".scummvm/logs/scummvm.log" | |
20 | +do | |
21 | + test -f "${TMPDIR}${file}" || touch "${TMPDIR}${file}" | |
22 | +done | |
23 | + | |
24 | +FF_PROFILE='default' | |
25 | +FF_DIR="${HOME}/.mozilla/firefox/" | |
26 | +FF_PROFILE_DIR="${FF_DIR}${FF_PROFILE}/" | |
27 | +if [ ! -e "${FF_PROFILE_DIR}" ] | |
28 | +then | |
29 | + mkdir -p "${FF_PROFILE_DIR}" | |
30 | + cat >${FF_DIR}/profiles.ini <<-END | |
31 | + [General] | |
32 | + StartWithLastProfile=1 | |
33 | + | |
34 | + [Profile0] | |
35 | + Name=default | |
36 | + IsRelative=1 | |
37 | + Path=${FF_PROFILE} | |
38 | + END | |
39 | + | |
40 | + for element in ${HOME}/.mozilla/persistent/* | |
41 | + do | |
42 | + test "${element}" == "${HOME}/.mozilla/persistent/*" && break | |
43 | + ln -s "${element}" "${FF_PROFILE_DIR}${element##*/}" | |
44 | + done | |
45 | +fi | |
46 | + | |
47 | +source .functions | |
48 | + | |
49 | +# vim: set ts=4 sw=4: | ... | ... |
tools.sh
0 → 100644
1 | +source ${HOME}/scripts/init/tools/rand_printable | |
2 | +source ${HOME}/scripts/init/tools/diff_no_links | |
3 | +source ${HOME}/scripts/init/tools/tardiff | |
4 | +source ${HOME}/scripts/init/tools/background | |
5 | +source ${HOME}/scripts/init/tools/gcal | |
6 | +source ${HOME}/scripts/init/tools/coltest | |
7 | +source ${HOME}/scripts/init/tools/i3task | |
8 | +source ${HOME}/scripts/init/tools/lxc-start | |
9 | +source ${HOME}/scripts/init/tools/lxc-snapshot | ... | ... |
tools/background
0 → 100755
1 | +#!/bin/bash | |
2 | + | |
3 | +## | |
4 | +# This one generates a background image for all active xrandr displays | |
5 | +# and sets it via ImageMagick display. The intermediate image will | |
6 | +# be removed as soon as the background ist set. | |
7 | +# | |
8 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
9 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
10 | +# Version: 1.0.0 | |
11 | +# | |
12 | + | |
13 | +function rand() { | |
14 | + local DD="/bin/dd" | |
15 | + local OD="/usr/bin/od" | |
16 | + local SED="/bin/sed" | |
17 | + | |
18 | + ${DD} if=/dev/urandom bs=2 count=1 2>/dev/null | \ | |
19 | + ${OD} -i | ${SED} '2d;s/^0\+ \+//' | |
20 | +} | |
21 | + | |
22 | +function background() { | |
23 | + local SED="/bin/sed" | |
24 | + local XRANDR="/usr/bin/xrandr" | |
25 | + local TEMPFILE="/bin/tempfile" | |
26 | + local IDENTIFY="/usr/bin/identify" | |
27 | + local CONVERT="/usr/bin/convert" | |
28 | + local SETROOT="/usr/bin/xsri" | |
29 | + local ECHO="/bin/echo" | |
30 | + local EXPR="/usr/bin/expr" | |
31 | + local WC="/usr/bin/wc" | |
32 | + local LS="/bin/ls" | |
33 | + | |
34 | + local BGDIR="${BGDIR:-${HOME}/images/backgrounds}" | |
35 | + local MYDISP="${DISPLAY:-:0}" | |
36 | + | |
37 | + local XRANDR_EXP=' | |
38 | + /^Screen/{ | |
39 | + s/ //g | |
40 | + s/^.*ent\([0-9x]*\).*$/\1/ | |
41 | + } | |
42 | + / conn/s/^.*cted \([^ ]*\).*$/\1/ | |
43 | + t | |
44 | + d' | |
45 | + | |
46 | + local RESOLUTIONS="`DISPLAY=${MYDISP} ${XRANDR} | ${SED} "${XRANDR_EXP}"`" | |
47 | + local WHOLE="`${ECHO} "${RESOLUTIONS}" | ${SED} '1p;d'`" | |
48 | + local SCREENS="`${ECHO} "${RESOLUTIONS}" | ${SED} '2,$p;d'`" | |
49 | + | |
50 | + local BGS="`${LS} -1b "${BGDIR}"`" | |
51 | + local N_BGS=`${ECHO} "${BGS}" | ${WC} -l` | |
52 | + | |
53 | + local res img size ofs ofs_x ofs_y screen_asp image_asp image_geom cmd | |
54 | + | |
55 | + cmd="-size ${WHOLE} xc:black" | |
56 | + | |
57 | + for res in ${SCREENS} | |
58 | + do | |
59 | + img=`rand` | |
60 | + img=`${EXPR} ${img} % ${N_BGS} + 1` | |
61 | + img="${BGDIR}/`${ECHO} "${BGS}" | ${SED} ${img}'p;d'`" | |
62 | + | |
63 | + size=${res%%+*} | |
64 | + ofs=${res#*+*} | |
65 | + ofs_x=${ofs%%+*} | |
66 | + ofs_y=${ofs##*+} | |
67 | + | |
68 | + screen_asp=`eval ${EXPR} ${size/x/ '\*' 100 \/ }` | |
69 | + image_asp=`eval "${IDENTIFY} -format \"%w '\*' 100 \/ %h\" ${img}"` | |
70 | + image_asp=`eval ${EXPR} $image_asp` | |
71 | + | |
72 | + # decide wheter to scale up to screen height or width | |
73 | + # based on previously computed asp's | |
74 | + if [ ${image_asp} -lt ${screen_asp} ] | |
75 | + then | |
76 | + # scale on height! | |
77 | + image_geom="x${size##*x}" | |
78 | + else | |
79 | + # scale on width! | |
80 | + image_geom="${size%%x*}x" | |
81 | + fi | |
82 | + | |
83 | + image_geom=`eval "${CONVERT} -scale ${image_geom} ${img} jpeg:- | \ | |
84 | + ${IDENTIFY} -format \"%wx%h\" jpeg:-"` | |
85 | + | |
86 | + ofs_x=`${EXPR} $ofs_x + \( \( ${size%%x*} - ${image_geom%%x*} \) / 2 \)` | |
87 | + ofs_y=`${EXPR} $ofs_y + \( \( ${size##*x} - ${image_geom##*x} \) / 2 \)` | |
88 | + | |
89 | + cmd="${cmd} ${img} -geometry ${image_geom}+${ofs_x}+${ofs_y} -composite" | |
90 | + done | |
91 | + | |
92 | + img=`${TEMPFILE} -s '.jpg'` | |
93 | + eval "${CONVERT} ${cmd} ${img}" | |
94 | + DISPLAY=${MYDISP} ${SETROOT} --emblem="${img}" --set 2>/dev/null | |
95 | + rm ${img} | |
96 | +} | |
97 | + | |
98 | +test "X$(basename -- "$0")" = "Xbackground" && background "$@" | |
99 | + | |
100 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/coltest
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +function coltest() { | |
4 | + local ECHO="/bin/echo" | |
5 | + | |
6 | + if [ $# -lt 1 ] | |
7 | + then | |
8 | + ${ECHO} "coltest 256fg-col [256bg-col]" | |
9 | + return | |
10 | + fi | |
11 | + | |
12 | + ${ECHO} -en "\033[38;5;${1}m" | |
13 | + [ "$2" ] && ${ECHO} -en "\033[48;5;${2}m" | |
14 | + ${ECHO} -n "test" | |
15 | + ${ECHO} -e "\033[00m" | |
16 | +} | |
17 | + | |
18 | +test "X$(basename -- "$0")" = "Xcoltest" && coltest "$@" | |
19 | + | |
20 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/dates
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +## | |
4 | +# various functions and aliases that make gcal more convinient | |
5 | +# | |
6 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
7 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
8 | +# Version: 1.0.0 | |
9 | +# | |
10 | + | |
11 | +alias gcal='LC_MESSAGES=de_DE.UTF-8 /usr/bin/gcal -K -s Monday' | |
12 | +alias hollidays='gcal -qde_hh -n' | |
13 | +alias dates='gcal -c' | |
14 | +alias mdates='gcal -cm' | |
15 | +alias tcomingf='tcoming | sed '\''1!d'\' | |
16 | +alias ttomorrowf='ttomorrow | sed '\''1!d'\' | |
17 | + | |
18 | +function terms() { | |
19 | + _terms "all" 1 "$@" | |
20 | +} | |
21 | + | |
22 | +function tcoming() { | |
23 | + _terms "coming" 1 | |
24 | +} | |
25 | + | |
26 | +function tpast() { | |
27 | + _terms "past" 1 | |
28 | +} | |
29 | + | |
30 | +function ttomorrow() { | |
31 | + _terms "all" 0 -ct | |
32 | +} | |
33 | + | |
34 | +function _terms() { | |
35 | + local modifier=${1:-all} | |
36 | + local color=${2:-0} | |
37 | + local current_time=`date +%H:%M` | |
38 | + shift 2 | |
39 | + | |
40 | + #dates "$@" | sed '1,/^Fixed date/d; /^$/d; s/[^:]*: //' | |
41 | + dates "$@" | awk -v ctime="${current_time}" -v mod="${modifier}" \ | |
42 | + -v col=${color} -v format=${DATES_FORMAT} ' | |
43 | + BEGIN { | |
44 | + chour = ctime; gsub(/:.*/, "", chour); | |
45 | + cminute = ctime; gsub(/.*:/, "", cminute); | |
46 | + ctime = chour * 60 + cminute | |
47 | + } | |
48 | + | |
49 | + NR == 1, /^Fixed date/ {next} | |
50 | + /^$/ {next} | |
51 | + | |
52 | + { | |
53 | + gsub(/^[^:]*: /, ""); | |
54 | + FS=" "; | |
55 | + hour=$1; gsub(/:.*/, "", hour); | |
56 | + minute=$1; gsub(/.*:/, "", minute); | |
57 | + time = hour * 60 + minute | |
58 | + | |
59 | + color="" | |
60 | + if (format == "i3bar") { | |
61 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
62 | + color="\"color\":\"#00FF00\","; | |
63 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
64 | + color="\"color\":\"#FFFF00\","; | |
65 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
66 | + color="\"color\":\"#FF0000\","; | |
67 | + } | |
68 | + else { | |
69 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
70 | + color="\033[38;5;82m"; | |
71 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
72 | + color="\033[38;5;190m"; | |
73 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
74 | + color="\033[38;5;124m"; | |
75 | + } | |
76 | + | |
77 | + if ((mod == "all") || | |
78 | + (mod == "coming" && (time+5 >= ctime || time == 0)) || | |
79 | + (mod == "past" && (time < ctime || time == 0))) { | |
80 | + | |
81 | + gsub(/\\/, "", $0); | |
82 | + if (format == "i3bar") { | |
83 | + gsub(/"/, "\\\"", $0); | |
84 | + out = color "\"full_text\":\"" $0 "\"" | |
85 | + } | |
86 | + else { | |
87 | + out = color $0 "\033[00m" | |
88 | + } | |
89 | + print out | |
90 | + } | |
91 | + } | |
92 | + | |
93 | + END { | |
94 | + if ("" == out) { | |
95 | + if (format == "i3bar") { | |
96 | + print "\"full_text\":\"none\"" | |
97 | + } | |
98 | + else { | |
99 | + print "none" | |
100 | + } | |
101 | + } | |
102 | + }' | |
103 | +} | |
104 | + | |
105 | +test "X$(basename -- "$0")" = "Xgcal" && gcal "$@" | |
106 | +test "X$(basename -- "$0")" = "Xhollidays" && hollidays "$@" | |
107 | +test "X$(basename -- "$0")" = "Xdates" && dates "$@" | |
108 | +test "X$(basename -- "$0")" = "Xmdates" && mdates "$@" | |
109 | +test "X$(basename -- "$0")" = "Xtcomingf" && tcomingf "$@" | |
110 | +test "X$(basename -- "$0")" = "Xttomorrowf" && ttomorrowf "$@" | |
111 | +test "X$(basename -- "$0")" = "Xtcoming" && tcoming "$@" | |
112 | +test "X$(basename -- "$0")" = "Xtpast" && tpast "$@" | |
113 | +test "X$(basename -- "$0")" = "Xttomorrow" && ttomorrow "$@" | |
114 | +test "X$(basename -- "$0")" = "Xterms" && terms "$@" | |
115 | + | |
116 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/diff_no_links
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +function diff_no_links() { | |
4 | + local FIND="/usr/bin/find" | |
5 | + local SED="/bin/sed" | |
6 | + local CAT="/bin/cat" | |
7 | + local TR="/usr/bin/tr" | |
8 | + local SORT="/usr/bin/sort" | |
9 | + | |
10 | + local SRC=$1 | |
11 | + local DST=$2 | |
12 | + | |
13 | + local SRC_SYMS="${FIND} \"${SRC}\" -type l -exec basename {} \;" | |
14 | + local DST_SYMS="${FIND} \"${DST}\" -type l -exec basename {} \;" | |
15 | + local ALL_SYMS="${CAT} <(${SRC_SYMS}) <($DST_SYMS) | ${SORT} -u" | |
16 | + | |
17 | + local EXCLUDES="${ALL_SYMS} | ${SED} 's/^/ -x /' | ${TR} -d '\n'" | |
18 | + | |
19 | + diff -Naur `eval ${EXCLUDES}` "${SRC}" "${DST}" | |
20 | + return $? | |
21 | +} | |
22 | + | |
23 | +test "X$(basename -- "$0")" = "Xdiff_no_links" && diff_no_links "$@" | |
24 | + | |
25 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/execalias
0 → 100755
tools/gcal
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +## | |
4 | +# various functions and aliases that make gcal more convinient | |
5 | +# | |
6 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
7 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
8 | +# Version: 1.0.0 | |
9 | +# | |
10 | + | |
11 | +alias gcal='LC_MESSAGES=de_DE.UTF-8 /usr/bin/gcal -K -s Monday' | |
12 | +alias hollidays='gcal -qde_hh -n' | |
13 | +alias dates='gcal -c' | |
14 | +alias mdates='gcal -cm' | |
15 | +alias tcomingf='tcoming | sed '\''1!d'\' | |
16 | +alias ttomorrowf='ttomorrow | sed '\''1!d'\' | |
17 | + | |
18 | +function terms() { | |
19 | + _terms "all" 1 "$@" | |
20 | +} | |
21 | + | |
22 | +function tcoming() { | |
23 | + _terms "coming" 1 | |
24 | +} | |
25 | + | |
26 | +function tpast() { | |
27 | + _terms "past" 1 | |
28 | +} | |
29 | + | |
30 | +function ttomorrow() { | |
31 | + _terms "all" 0 -ct | |
32 | +} | |
33 | + | |
34 | +function _terms() { | |
35 | + local modifier=${1:-all} | |
36 | + local color=${2:-0} | |
37 | + local current_time=`date +%H:%M` | |
38 | + shift 2 | |
39 | + | |
40 | + #dates "$@" | sed '1,/^Fixed date/d; /^$/d; s/[^:]*: //' | |
41 | + dates "$@" | awk -v ctime="${current_time}" -v mod="${modifier}" \ | |
42 | + -v col=${color} -v format=${DATES_FORMAT} ' | |
43 | + BEGIN { | |
44 | + chour = ctime; gsub(/:.*/, "", chour); | |
45 | + cminute = ctime; gsub(/.*:/, "", cminute); | |
46 | + ctime = chour * 60 + cminute | |
47 | + } | |
48 | + | |
49 | + NR == 1, /^Fixed date/ {next} | |
50 | + /^$/ {next} | |
51 | + | |
52 | + { | |
53 | + gsub(/^[^:]*: /, ""); | |
54 | + FS=" "; | |
55 | + hour=$1; gsub(/:.*/, "", hour); | |
56 | + minute=$1; gsub(/.*:/, "", minute); | |
57 | + time = hour * 60 + minute | |
58 | + | |
59 | + color="" | |
60 | + if (format == "i3bar") { | |
61 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
62 | + color="\"color\":\"#00FF00\","; | |
63 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
64 | + color="\"color\":\"#FFFF00\","; | |
65 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
66 | + color="\"color\":\"#FF0000\","; | |
67 | + } | |
68 | + else { | |
69 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
70 | + color="\033[38;5;82m"; | |
71 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
72 | + color="\033[38;5;190m"; | |
73 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
74 | + color="\033[38;5;124m"; | |
75 | + } | |
76 | + | |
77 | + if ((mod == "all") || | |
78 | + (mod == "coming" && (time+5 >= ctime || time == 0)) || | |
79 | + (mod == "past" && (time < ctime || time == 0))) { | |
80 | + | |
81 | + gsub(/\\/, "", $0); | |
82 | + if (format == "i3bar") { | |
83 | + gsub(/"/, "\\\"", $0); | |
84 | + out = color "\"full_text\":\"" $0 "\"" | |
85 | + } | |
86 | + else { | |
87 | + out = color $0 "\033[00m" | |
88 | + } | |
89 | + print out | |
90 | + } | |
91 | + } | |
92 | + | |
93 | + END { | |
94 | + if ("" == out) { | |
95 | + if (format == "i3bar") { | |
96 | + print "\"full_text\":\"none\"" | |
97 | + } | |
98 | + else { | |
99 | + print "none" | |
100 | + } | |
101 | + } | |
102 | + }' | |
103 | +} | |
104 | + | |
105 | +test "X$(basename -- "$0")" = "Xgcal" && gcal "$@" | |
106 | +test "X$(basename -- "$0")" = "Xhollidays" && hollidays "$@" | |
107 | +test "X$(basename -- "$0")" = "Xdates" && dates "$@" | |
108 | +test "X$(basename -- "$0")" = "Xmdates" && mdates "$@" | |
109 | +test "X$(basename -- "$0")" = "Xtcomingf" && tcomingf "$@" | |
110 | +test "X$(basename -- "$0")" = "Xttomorrowf" && ttomorrowf "$@" | |
111 | +test "X$(basename -- "$0")" = "Xtcoming" && tcoming "$@" | |
112 | +test "X$(basename -- "$0")" = "Xtpast" && tpast "$@" | |
113 | +test "X$(basename -- "$0")" = "Xttomorrow" && ttomorrow "$@" | |
114 | +test "X$(basename -- "$0")" = "Xterms" && terms "$@" | |
115 | + | |
116 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/hollidays
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +## | |
4 | +# various functions and aliases that make gcal more convinient | |
5 | +# | |
6 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
7 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
8 | +# Version: 1.0.0 | |
9 | +# | |
10 | + | |
11 | +alias gcal='LC_MESSAGES=de_DE.UTF-8 /usr/bin/gcal -K -s Monday' | |
12 | +alias hollidays='gcal -qde_hh -n' | |
13 | +alias dates='gcal -c' | |
14 | +alias mdates='gcal -cm' | |
15 | +alias tcomingf='tcoming | sed '\''1!d'\' | |
16 | +alias ttomorrowf='ttomorrow | sed '\''1!d'\' | |
17 | + | |
18 | +function terms() { | |
19 | + _terms "all" 1 "$@" | |
20 | +} | |
21 | + | |
22 | +function tcoming() { | |
23 | + _terms "coming" 1 | |
24 | +} | |
25 | + | |
26 | +function tpast() { | |
27 | + _terms "past" 1 | |
28 | +} | |
29 | + | |
30 | +function ttomorrow() { | |
31 | + _terms "all" 0 -ct | |
32 | +} | |
33 | + | |
34 | +function _terms() { | |
35 | + local modifier=${1:-all} | |
36 | + local color=${2:-0} | |
37 | + local current_time=`date +%H:%M` | |
38 | + shift 2 | |
39 | + | |
40 | + #dates "$@" | sed '1,/^Fixed date/d; /^$/d; s/[^:]*: //' | |
41 | + dates "$@" | awk -v ctime="${current_time}" -v mod="${modifier}" \ | |
42 | + -v col=${color} -v format=${DATES_FORMAT} ' | |
43 | + BEGIN { | |
44 | + chour = ctime; gsub(/:.*/, "", chour); | |
45 | + cminute = ctime; gsub(/.*:/, "", cminute); | |
46 | + ctime = chour * 60 + cminute | |
47 | + } | |
48 | + | |
49 | + NR == 1, /^Fixed date/ {next} | |
50 | + /^$/ {next} | |
51 | + | |
52 | + { | |
53 | + gsub(/^[^:]*: /, ""); | |
54 | + FS=" "; | |
55 | + hour=$1; gsub(/:.*/, "", hour); | |
56 | + minute=$1; gsub(/.*:/, "", minute); | |
57 | + time = hour * 60 + minute | |
58 | + | |
59 | + color="" | |
60 | + if (format == "i3bar") { | |
61 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
62 | + color="\"color\":\"#00FF00\","; | |
63 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
64 | + color="\"color\":\"#FFFF00\","; | |
65 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
66 | + color="\"color\":\"#FF0000\","; | |
67 | + } | |
68 | + else { | |
69 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
70 | + color="\033[38;5;82m"; | |
71 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
72 | + color="\033[38;5;190m"; | |
73 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
74 | + color="\033[38;5;124m"; | |
75 | + } | |
76 | + | |
77 | + if ((mod == "all") || | |
78 | + (mod == "coming" && (time+5 >= ctime || time == 0)) || | |
79 | + (mod == "past" && (time < ctime || time == 0))) { | |
80 | + | |
81 | + gsub(/\\/, "", $0); | |
82 | + if (format == "i3bar") { | |
83 | + gsub(/"/, "\\\"", $0); | |
84 | + out = color "\"full_text\":\"" $0 "\"" | |
85 | + } | |
86 | + else { | |
87 | + out = color $0 "\033[00m" | |
88 | + } | |
89 | + print out | |
90 | + } | |
91 | + } | |
92 | + | |
93 | + END { | |
94 | + if ("" == out) { | |
95 | + if (format == "i3bar") { | |
96 | + print "\"full_text\":\"none\"" | |
97 | + } | |
98 | + else { | |
99 | + print "none" | |
100 | + } | |
101 | + } | |
102 | + }' | |
103 | +} | |
104 | + | |
105 | +test "X$(basename -- "$0")" = "Xgcal" && gcal "$@" | |
106 | +test "X$(basename -- "$0")" = "Xhollidays" && hollidays "$@" | |
107 | +test "X$(basename -- "$0")" = "Xdates" && dates "$@" | |
108 | +test "X$(basename -- "$0")" = "Xmdates" && mdates "$@" | |
109 | +test "X$(basename -- "$0")" = "Xtcomingf" && tcomingf "$@" | |
110 | +test "X$(basename -- "$0")" = "Xttomorrowf" && ttomorrowf "$@" | |
111 | +test "X$(basename -- "$0")" = "Xtcoming" && tcoming "$@" | |
112 | +test "X$(basename -- "$0")" = "Xtpast" && tpast "$@" | |
113 | +test "X$(basename -- "$0")" = "Xttomorrow" && ttomorrow "$@" | |
114 | +test "X$(basename -- "$0")" = "Xterms" && terms "$@" | |
115 | + | |
116 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/i3odcnt
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +alias i3active='task i3active 2>/dev/null | sed '\''4!d'\''' | |
4 | +alias i3next='task i3next 2>/dev/null | sed '\''4!d'\''' | |
5 | +alias i3overdue='task i3overdue 2>/dev/null | sed '\''4!d'\''' | |
6 | +alias odcnt='task overdue 2>/dev/null | sed '\''$!d;s/task.*/overdue/'\''' | |
7 | + | |
8 | +function i3odcnt() { | |
9 | + echo "\"color\":\"#FF0000\",\"full_text\":\"$(odcnt)\"" | |
10 | +} | |
11 | + | |
12 | +function i3tasko() { | |
13 | + _i3print "$(i3overdue)" | |
14 | +} | |
15 | + | |
16 | +function i3task() { | |
17 | + local TASK="$(i3active)" | |
18 | + | |
19 | + test -z "${TASK}" && TASK="$(i3next)" | |
20 | + | |
21 | + _i3print "${TASK}" | |
22 | +} | |
23 | + | |
24 | +function _taskdate() { | |
25 | + local TDATE | |
26 | + | |
27 | + TDATE="$(echo "${1}" | sed 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3-\2-\1/')" | |
28 | + test "${TDATE}" == "${1}" && TDATE="3000-12-12" | |
29 | + echo "${TDATE}" | |
30 | +} | |
31 | + | |
32 | +function _taskmsg() { | |
33 | + echo "${1}" | sed 's/^[0-9.]* *//' | |
34 | +} | |
35 | + | |
36 | +function _taskcol() { | |
37 | + local ACTIVE_COL="#4040FF" | |
38 | + local ONEDAY_COL="#FFFF00" | |
39 | + local OVERDUE_COL="#FF0000" | |
40 | + local COLOR="#00FF00" | |
41 | + | |
42 | + test "$(i3active)" == "${1}" && { | |
43 | + echo "${ACTIVE_COL}" | |
44 | + return | |
45 | + } | |
46 | + | |
47 | + # add one day to due date as the due date has also 24 hours | |
48 | + local DUE=$(($(date -d "$(_taskdate "${1}")" +%s)+(24*60*60))) | |
49 | + local NOW=$(date +%s) | |
50 | + | |
51 | + test ${DUE} -le $((${NOW}+(24*60*60))) && COLOR="${ONEDAY_COL}" | |
52 | + test ${DUE} -le ${NOW} && COLOR="${OVERDUE_COL}" | |
53 | + | |
54 | + echo "${COLOR}" | |
55 | +} | |
56 | + | |
57 | +function _i3print() { | |
58 | + printf "\"color\":\"%s\",\"full_text\":\"%s\"" \ | |
59 | + "$(_taskcol "${1}")" \ | |
60 | + "$(_taskmsg "${1}")" | |
61 | +} | |
62 | + | |
63 | +test "X$(basename -- "$0")" = "Xi3task" && i3task "$@" | |
64 | +test "X$(basename -- "$0")" = "Xi3overdue" && i3tasko "$@" | |
65 | +test "X$(basename -- "$0")" = "Xi3odcnt" && i3odcnt "$@" | |
66 | + | |
67 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/i3overdue
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +alias i3active='task i3active 2>/dev/null | sed '\''4!d'\''' | |
4 | +alias i3next='task i3next 2>/dev/null | sed '\''4!d'\''' | |
5 | +alias i3overdue='task i3overdue 2>/dev/null | sed '\''4!d'\''' | |
6 | +alias odcnt='task overdue 2>/dev/null | sed '\''$!d;s/task.*/overdue/'\''' | |
7 | + | |
8 | +function i3odcnt() { | |
9 | + echo "\"color\":\"#FF0000\",\"full_text\":\"$(odcnt)\"" | |
10 | +} | |
11 | + | |
12 | +function i3tasko() { | |
13 | + _i3print "$(i3overdue)" | |
14 | +} | |
15 | + | |
16 | +function i3task() { | |
17 | + local TASK="$(i3active)" | |
18 | + | |
19 | + test -z "${TASK}" && TASK="$(i3next)" | |
20 | + | |
21 | + _i3print "${TASK}" | |
22 | +} | |
23 | + | |
24 | +function _taskdate() { | |
25 | + local TDATE | |
26 | + | |
27 | + TDATE="$(echo "${1}" | sed 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3-\2-\1/')" | |
28 | + test "${TDATE}" == "${1}" && TDATE="3000-12-12" | |
29 | + echo "${TDATE}" | |
30 | +} | |
31 | + | |
32 | +function _taskmsg() { | |
33 | + echo "${1}" | sed 's/^[0-9.]* *//' | |
34 | +} | |
35 | + | |
36 | +function _taskcol() { | |
37 | + local ACTIVE_COL="#4040FF" | |
38 | + local ONEDAY_COL="#FFFF00" | |
39 | + local OVERDUE_COL="#FF0000" | |
40 | + local COLOR="#00FF00" | |
41 | + | |
42 | + test "$(i3active)" == "${1}" && { | |
43 | + echo "${ACTIVE_COL}" | |
44 | + return | |
45 | + } | |
46 | + | |
47 | + # add one day to due date as the due date has also 24 hours | |
48 | + local DUE=$(($(date -d "$(_taskdate "${1}")" +%s)+(24*60*60))) | |
49 | + local NOW=$(date +%s) | |
50 | + | |
51 | + test ${DUE} -le $((${NOW}+(24*60*60))) && COLOR="${ONEDAY_COL}" | |
52 | + test ${DUE} -le ${NOW} && COLOR="${OVERDUE_COL}" | |
53 | + | |
54 | + echo "${COLOR}" | |
55 | +} | |
56 | + | |
57 | +function _i3print() { | |
58 | + printf "\"color\":\"%s\",\"full_text\":\"%s\"" \ | |
59 | + "$(_taskcol "${1}")" \ | |
60 | + "$(_taskmsg "${1}")" | |
61 | +} | |
62 | + | |
63 | +test "X$(basename -- "$0")" = "Xi3task" && i3task "$@" | |
64 | +test "X$(basename -- "$0")" = "Xi3overdue" && i3tasko "$@" | |
65 | +test "X$(basename -- "$0")" = "Xi3odcnt" && i3odcnt "$@" | |
66 | + | |
67 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/i3task
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +alias i3active='task i3active 2>/dev/null | sed '\''4!d'\''' | |
4 | +alias i3next='task i3next 2>/dev/null | sed '\''4!d'\''' | |
5 | +alias i3overdue='task i3overdue 2>/dev/null | sed '\''4!d'\''' | |
6 | +alias odcnt='task overdue 2>/dev/null | sed '\''$!d;s/task.*/overdue/'\''' | |
7 | + | |
8 | +function i3odcnt() { | |
9 | + echo "\"color\":\"#FF0000\",\"full_text\":\"$(odcnt)\"" | |
10 | +} | |
11 | + | |
12 | +function i3tasko() { | |
13 | + _i3print "$(i3overdue)" | |
14 | +} | |
15 | + | |
16 | +function i3task() { | |
17 | + local TASK="$(i3active)" | |
18 | + | |
19 | + test -z "${TASK}" && TASK="$(i3next)" | |
20 | + | |
21 | + _i3print "${TASK}" | |
22 | +} | |
23 | + | |
24 | +function _taskdate() { | |
25 | + local TDATE | |
26 | + | |
27 | + TDATE="$(echo "${1}" | sed 's/^\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3-\2-\1/')" | |
28 | + test "${TDATE}" == "${1}" && TDATE="3000-12-12" | |
29 | + echo "${TDATE}" | |
30 | +} | |
31 | + | |
32 | +function _taskmsg() { | |
33 | + echo "${1}" | sed 's/^[0-9.]* *//' | |
34 | +} | |
35 | + | |
36 | +function _taskcol() { | |
37 | + local ACTIVE_COL="#4040FF" | |
38 | + local ONEDAY_COL="#FFFF00" | |
39 | + local OVERDUE_COL="#FF0000" | |
40 | + local COLOR="#00FF00" | |
41 | + | |
42 | + test "$(i3active)" == "${1}" && { | |
43 | + echo "${ACTIVE_COL}" | |
44 | + return | |
45 | + } | |
46 | + | |
47 | + # add one day to due date as the due date has also 24 hours | |
48 | + local DUE=$(($(date -d "$(_taskdate "${1}")" +%s)+(24*60*60))) | |
49 | + local NOW=$(date +%s) | |
50 | + | |
51 | + test ${DUE} -le $((${NOW}+(24*60*60))) && COLOR="${ONEDAY_COL}" | |
52 | + test ${DUE} -le ${NOW} && COLOR="${OVERDUE_COL}" | |
53 | + | |
54 | + echo "${COLOR}" | |
55 | +} | |
56 | + | |
57 | +function _i3print() { | |
58 | + printf "\"color\":\"%s\",\"full_text\":\"%s\"" \ | |
59 | + "$(_taskcol "${1}")" \ | |
60 | + "$(_taskmsg "${1}")" | |
61 | +} | |
62 | + | |
63 | +test "X$(basename -- "$0")" = "Xi3task" && i3task "$@" | |
64 | +test "X$(basename -- "$0")" = "Xi3overdue" && i3tasko "$@" | |
65 | +test "X$(basename -- "$0")" = "Xi3odcnt" && i3odcnt "$@" | |
66 | + | |
67 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/lxc-snapshot
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +function lxc-snapshot() | |
4 | +{ | |
5 | + local BTRFS=/sbin/btrfs | |
6 | + local CHMOD=/bin/chmod | |
7 | + local CHOWN=/bin/chown | |
8 | + local CUT=/usr/bin/cut | |
9 | + local ECHO=/bin/echo | |
10 | + local GREP=/bin/grep | |
11 | + local ID=/usr/bin/id | |
12 | + local LXC_USERNSEXEC=/usr/bin/lxc-usernsexec | |
13 | + local MKDIR=/bin/mkdir | |
14 | + local SED=/bin/sed | |
15 | + local TEST=/usr/bin/test | |
16 | + | |
17 | + local SOURCE=$1 | |
18 | + local TARGET=$2 | |
19 | + local IP=$3 | |
20 | + | |
21 | + local SUBUIDS=$(${GREP} ${USER} /etc/subuid) | |
22 | + local SUBGIDS=$(${GREP} ${USER} /etc/subgid) | |
23 | + local SUID_START=$(${ECHO} "${SUBUIDS}" | ${CUT} -d: -f2) | |
24 | + local SGID_START=$(${ECHO} "${SUBGIDS}" | ${CUT} -d: -f2) | |
25 | + | |
26 | + local HUID=$(${ID} -u) | |
27 | + local HGID=$(${ID} -g) | |
28 | + | |
29 | + ${MKDIR} "${HOME}/.local/share/lxc/${TARGET}" | |
30 | + ${CHMOD} 770 "${HOME}/.local/share/lxc/${TARGET}" | |
31 | + ${SED} 's/'${SOURCE}'/'${TARGET}'/;/lxc.network.ipv4 *=/s/= *.*/= '${IP//\//\\/}'/' \ | |
32 | + "${HOME}/.local/share/lxc/${SOURCE}/config" >"${HOME}/.local/share/lxc/${TARGET}/config" | |
33 | + ${LXC_USERNSEXEC} -m 'u:0:'${SUID_START}':1' -m 'g:0:'${SGID_START}':1' \ | |
34 | + -m 'u:'${HUID}':'${HUID}':1' -m 'g:'${HGID}':'${HGID}':1' -- \ | |
35 | + ${CHOWN} 0 "${HOME}/.local/share/lxc/${TARGET}" | |
36 | + ${LXC_USERNSEXEC} -m 'u:0:'${SUBUIDS#*:} -m 'g:0:'${SUBGIDS#*:} -- \ | |
37 | + ${BTRFS} subvolume snapshot \ | |
38 | + "${HOME}/.local/share/lxc/${SOURCE}/rootfs" \ | |
39 | + "${HOME}/.local/share/lxc/${TARGET}/rootfs" | |
40 | +} | |
41 | + | |
42 | +export -f lxc-snapshot | |
43 | + | |
44 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/lxc-start
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +function lxc-start() | |
4 | +{ | |
5 | + local LXC_START=/usr/bin/lxc-start | |
6 | + local TEST=/usr/bin/test | |
7 | + local ECHO=/bin/echo | |
8 | + local MKDIR=/bin/mkdir | |
9 | + local CHOWN=/bin/chown | |
10 | + local SUDO=/usr/bin/sudo | |
11 | + local TEE=/usr/bin/tee | |
12 | + | |
13 | + ( | |
14 | + PID=$(exec /bin/sh -c 'echo $PPID') | |
15 | + for ctrl in /sys/fs/cgroup/* | |
16 | + do | |
17 | + ${TEST} ${ctrl##*/} = 'openrc' && continue | |
18 | + | |
19 | + if ${TEST} ! -d ${ctrl}/${USER} | |
20 | + then | |
21 | + ${TEST} ${ctrl##*/} = 'cpuset' && \ | |
22 | + ${ECHO} 1 | ${SUDO} ${TEE} ${ctrl}/cgroup.clone_children >/dev/null | |
23 | + ${TEST} ${ctrl##*/} = 'memory' && \ | |
24 | + ${ECHO} 1 | ${SUDO} ${TEE} ${ctrl}/memory.use_hierarchy >/dev/null | |
25 | + | |
26 | + ${SUDO} ${MKDIR} ${ctrl}/${USER}/ | |
27 | + ${SUDO} ${CHOWN} ${USER}: ${ctrl}/${USER} | |
28 | + ${SUDO} ${CHOWN} ${USER}: ${ctrl}/${USER}/tasks | |
29 | + ${SUDO} ${CHOWN} ${USER}: ${ctrl}/${USER}/cgroup.procs | |
30 | + fi | |
31 | + ${ECHO} ${PID} >>"${ctrl}/${USER}/tasks" | |
32 | + done | |
33 | + | |
34 | + ${LXC_START} $@ | |
35 | + ) | |
36 | +} | |
37 | + | |
38 | +export -f lxc-start | |
39 | + | |
40 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/mailterms
0 → 100755
tools/mdates
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +## | |
4 | +# various functions and aliases that make gcal more convinient | |
5 | +# | |
6 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
7 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
8 | +# Version: 1.0.0 | |
9 | +# | |
10 | + | |
11 | +alias gcal='LC_MESSAGES=de_DE.UTF-8 /usr/bin/gcal -K -s Monday' | |
12 | +alias hollidays='gcal -qde_hh -n' | |
13 | +alias dates='gcal -c' | |
14 | +alias mdates='gcal -cm' | |
15 | +alias tcomingf='tcoming | sed '\''1!d'\' | |
16 | +alias ttomorrowf='ttomorrow | sed '\''1!d'\' | |
17 | + | |
18 | +function terms() { | |
19 | + _terms "all" 1 "$@" | |
20 | +} | |
21 | + | |
22 | +function tcoming() { | |
23 | + _terms "coming" 1 | |
24 | +} | |
25 | + | |
26 | +function tpast() { | |
27 | + _terms "past" 1 | |
28 | +} | |
29 | + | |
30 | +function ttomorrow() { | |
31 | + _terms "all" 0 -ct | |
32 | +} | |
33 | + | |
34 | +function _terms() { | |
35 | + local modifier=${1:-all} | |
36 | + local color=${2:-0} | |
37 | + local current_time=`date +%H:%M` | |
38 | + shift 2 | |
39 | + | |
40 | + #dates "$@" | sed '1,/^Fixed date/d; /^$/d; s/[^:]*: //' | |
41 | + dates "$@" | awk -v ctime="${current_time}" -v mod="${modifier}" \ | |
42 | + -v col=${color} -v format=${DATES_FORMAT} ' | |
43 | + BEGIN { | |
44 | + chour = ctime; gsub(/:.*/, "", chour); | |
45 | + cminute = ctime; gsub(/.*:/, "", cminute); | |
46 | + ctime = chour * 60 + cminute | |
47 | + } | |
48 | + | |
49 | + NR == 1, /^Fixed date/ {next} | |
50 | + /^$/ {next} | |
51 | + | |
52 | + { | |
53 | + gsub(/^[^:]*: /, ""); | |
54 | + FS=" "; | |
55 | + hour=$1; gsub(/:.*/, "", hour); | |
56 | + minute=$1; gsub(/.*:/, "", minute); | |
57 | + time = hour * 60 + minute | |
58 | + | |
59 | + color="" | |
60 | + if (format == "i3bar") { | |
61 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
62 | + color="\"color\":\"#00FF00\","; | |
63 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
64 | + color="\"color\":\"#FFFF00\","; | |
65 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
66 | + color="\"color\":\"#FF0000\","; | |
67 | + } | |
68 | + else { | |
69 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
70 | + color="\033[38;5;82m"; | |
71 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
72 | + color="\033[38;5;190m"; | |
73 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
74 | + color="\033[38;5;124m"; | |
75 | + } | |
76 | + | |
77 | + if ((mod == "all") || | |
78 | + (mod == "coming" && (time+5 >= ctime || time == 0)) || | |
79 | + (mod == "past" && (time < ctime || time == 0))) { | |
80 | + | |
81 | + gsub(/\\/, "", $0); | |
82 | + if (format == "i3bar") { | |
83 | + gsub(/"/, "\\\"", $0); | |
84 | + out = color "\"full_text\":\"" $0 "\"" | |
85 | + } | |
86 | + else { | |
87 | + out = color $0 "\033[00m" | |
88 | + } | |
89 | + print out | |
90 | + } | |
91 | + } | |
92 | + | |
93 | + END { | |
94 | + if ("" == out) { | |
95 | + if (format == "i3bar") { | |
96 | + print "\"full_text\":\"none\"" | |
97 | + } | |
98 | + else { | |
99 | + print "none" | |
100 | + } | |
101 | + } | |
102 | + }' | |
103 | +} | |
104 | + | |
105 | +test "X$(basename -- "$0")" = "Xgcal" && gcal "$@" | |
106 | +test "X$(basename -- "$0")" = "Xhollidays" && hollidays "$@" | |
107 | +test "X$(basename -- "$0")" = "Xdates" && dates "$@" | |
108 | +test "X$(basename -- "$0")" = "Xmdates" && mdates "$@" | |
109 | +test "X$(basename -- "$0")" = "Xtcomingf" && tcomingf "$@" | |
110 | +test "X$(basename -- "$0")" = "Xttomorrowf" && ttomorrowf "$@" | |
111 | +test "X$(basename -- "$0")" = "Xtcoming" && tcoming "$@" | |
112 | +test "X$(basename -- "$0")" = "Xtpast" && tpast "$@" | |
113 | +test "X$(basename -- "$0")" = "Xttomorrow" && ttomorrow "$@" | |
114 | +test "X$(basename -- "$0")" = "Xterms" && terms "$@" | |
115 | + | |
116 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/rand_printable
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +function rand_printable() { | |
4 | + local ECHO="/bin/echo" | |
5 | + local TR="/usr/bin/tr" | |
6 | + local HEAD="/usr/bin/head" | |
7 | + | |
8 | + ${ECHO} -n "`</dev/urandom ${TR} -dc \ -~ | ${HEAD} -c${1:-512}`" | |
9 | +} | |
10 | + | |
11 | +test "X$(basename -- "$0")" = "Xrand_printable" && rand_printable "$@" | |
12 | + | |
13 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/tardiff
0 → 100755
1 | +#!/bin/bash | |
2 | + | |
3 | +## | |
4 | +# Create an unified diff over two tar archives. | |
5 | +# | |
6 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
7 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
8 | +# Version: 1.0.0 | |
9 | +# | |
10 | + | |
11 | +## | |
12 | +# This one is not POSIX conform. POSIX does not define | |
13 | +# process substitution via <() or >(). The alternative | |
14 | +# I tries is using fifos but doing this with seems to | |
15 | +# be a synchonization nightmare. | |
16 | +# | |
17 | + | |
18 | +function tardiff() { | |
19 | + local SED="/bin/sed" | |
20 | + local SORT="/usr/bin/sort" | |
21 | + local TAR="/bin/tar" | |
22 | + local DIFF="/usr/bin/diff" | |
23 | + local XARGS="/usr/bin/xargs" | |
24 | + local BASH="/bin/bash" | |
25 | + | |
26 | + if [ 2 -ne $# ] | |
27 | + then | |
28 | + echo "tardiff tar1 tar2" | |
29 | + return 1 | |
30 | + fi | |
31 | + | |
32 | + local TAR1=$1 | |
33 | + local TAR2=$2 | |
34 | + | |
35 | + local FILES1="${TAR} tfa \"${TAR1}\"" | |
36 | + local FILES2="${TAR} tfa \"${TAR2}\"" | |
37 | + | |
38 | + ## | |
39 | + # get the union of all files in both tar's | |
40 | + # Exclude directories. | |
41 | + # | |
42 | + local FILES="${SORT} -u <(${FILES1}) <(${FILES2}) | ${SED} '/\/$/d'" | |
43 | + | |
44 | + ## | |
45 | + # create a diff over all files and change the /dev/fd/ entries | |
46 | + # with the current filename. | |
47 | + # The resulting diff can be used as a patch on the extracted | |
48 | + # first tar to get the content of the extracted second tar. | |
49 | + # | |
50 | + eval ${FILES} | ${XARGS} -I %file ${BASH} -c " | |
51 | + FILE=\"%file\" | |
52 | + ESC_FILE=\"\${FILE//\//\/}\" | |
53 | + ${DIFF} -Nau \ | |
54 | + <(${TAR} xfOa \"${TAR1}\" \"%file\" 2>/dev/null) \ | |
55 | + <(${TAR} xfOa \"${TAR2}\" \"%file\" 2>/dev/null) | \ | |
56 | + ${SED} 's/\/dev\/fd\/[0-9]\+/'\${ESC_FILE}'/'" | |
57 | +} | |
58 | + | |
59 | +test "X$(basename -- "$0")" = "Xtardiff" && tardiff "$@" | |
60 | + | |
61 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/tcoming
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +## | |
4 | +# various functions and aliases that make gcal more convinient | |
5 | +# | |
6 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
7 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
8 | +# Version: 1.0.0 | |
9 | +# | |
10 | + | |
11 | +alias gcal='LC_MESSAGES=de_DE.UTF-8 /usr/bin/gcal -K -s Monday' | |
12 | +alias hollidays='gcal -qde_hh -n' | |
13 | +alias dates='gcal -c' | |
14 | +alias mdates='gcal -cm' | |
15 | +alias tcomingf='tcoming | sed '\''1!d'\' | |
16 | +alias ttomorrowf='ttomorrow | sed '\''1!d'\' | |
17 | + | |
18 | +function terms() { | |
19 | + _terms "all" 1 "$@" | |
20 | +} | |
21 | + | |
22 | +function tcoming() { | |
23 | + _terms "coming" 1 | |
24 | +} | |
25 | + | |
26 | +function tpast() { | |
27 | + _terms "past" 1 | |
28 | +} | |
29 | + | |
30 | +function ttomorrow() { | |
31 | + _terms "all" 0 -ct | |
32 | +} | |
33 | + | |
34 | +function _terms() { | |
35 | + local modifier=${1:-all} | |
36 | + local color=${2:-0} | |
37 | + local current_time=`date +%H:%M` | |
38 | + shift 2 | |
39 | + | |
40 | + #dates "$@" | sed '1,/^Fixed date/d; /^$/d; s/[^:]*: //' | |
41 | + dates "$@" | awk -v ctime="${current_time}" -v mod="${modifier}" \ | |
42 | + -v col=${color} -v format=${DATES_FORMAT} ' | |
43 | + BEGIN { | |
44 | + chour = ctime; gsub(/:.*/, "", chour); | |
45 | + cminute = ctime; gsub(/.*:/, "", cminute); | |
46 | + ctime = chour * 60 + cminute | |
47 | + } | |
48 | + | |
49 | + NR == 1, /^Fixed date/ {next} | |
50 | + /^$/ {next} | |
51 | + | |
52 | + { | |
53 | + gsub(/^[^:]*: /, ""); | |
54 | + FS=" "; | |
55 | + hour=$1; gsub(/:.*/, "", hour); | |
56 | + minute=$1; gsub(/.*:/, "", minute); | |
57 | + time = hour * 60 + minute | |
58 | + | |
59 | + color="" | |
60 | + if (format == "i3bar") { | |
61 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
62 | + color="\"color\":\"#00FF00\","; | |
63 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
64 | + color="\"color\":\"#FFFF00\","; | |
65 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
66 | + color="\"color\":\"#FF0000\","; | |
67 | + } | |
68 | + else { | |
69 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
70 | + color="\033[38;5;82m"; | |
71 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
72 | + color="\033[38;5;190m"; | |
73 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
74 | + color="\033[38;5;124m"; | |
75 | + } | |
76 | + | |
77 | + if ((mod == "all") || | |
78 | + (mod == "coming" && (time+5 >= ctime || time == 0)) || | |
79 | + (mod == "past" && (time < ctime || time == 0))) { | |
80 | + | |
81 | + gsub(/\\/, "", $0); | |
82 | + if (format == "i3bar") { | |
83 | + gsub(/"/, "\\\"", $0); | |
84 | + out = color "\"full_text\":\"" $0 "\"" | |
85 | + } | |
86 | + else { | |
87 | + out = color $0 "\033[00m" | |
88 | + } | |
89 | + print out | |
90 | + } | |
91 | + } | |
92 | + | |
93 | + END { | |
94 | + if ("" == out) { | |
95 | + if (format == "i3bar") { | |
96 | + print "\"full_text\":\"none\"" | |
97 | + } | |
98 | + else { | |
99 | + print "none" | |
100 | + } | |
101 | + } | |
102 | + }' | |
103 | +} | |
104 | + | |
105 | +test "X$(basename -- "$0")" = "Xgcal" && gcal "$@" | |
106 | +test "X$(basename -- "$0")" = "Xhollidays" && hollidays "$@" | |
107 | +test "X$(basename -- "$0")" = "Xdates" && dates "$@" | |
108 | +test "X$(basename -- "$0")" = "Xmdates" && mdates "$@" | |
109 | +test "X$(basename -- "$0")" = "Xtcomingf" && tcomingf "$@" | |
110 | +test "X$(basename -- "$0")" = "Xttomorrowf" && ttomorrowf "$@" | |
111 | +test "X$(basename -- "$0")" = "Xtcoming" && tcoming "$@" | |
112 | +test "X$(basename -- "$0")" = "Xtpast" && tpast "$@" | |
113 | +test "X$(basename -- "$0")" = "Xttomorrow" && ttomorrow "$@" | |
114 | +test "X$(basename -- "$0")" = "Xterms" && terms "$@" | |
115 | + | |
116 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/tcomingf
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +## | |
4 | +# various functions and aliases that make gcal more convinient | |
5 | +# | |
6 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
7 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
8 | +# Version: 1.0.0 | |
9 | +# | |
10 | + | |
11 | +alias gcal='LC_MESSAGES=de_DE.UTF-8 /usr/bin/gcal -K -s Monday' | |
12 | +alias hollidays='gcal -qde_hh -n' | |
13 | +alias dates='gcal -c' | |
14 | +alias mdates='gcal -cm' | |
15 | +alias tcomingf='tcoming | sed '\''1!d'\' | |
16 | +alias ttomorrowf='ttomorrow | sed '\''1!d'\' | |
17 | + | |
18 | +function terms() { | |
19 | + _terms "all" 1 "$@" | |
20 | +} | |
21 | + | |
22 | +function tcoming() { | |
23 | + _terms "coming" 1 | |
24 | +} | |
25 | + | |
26 | +function tpast() { | |
27 | + _terms "past" 1 | |
28 | +} | |
29 | + | |
30 | +function ttomorrow() { | |
31 | + _terms "all" 0 -ct | |
32 | +} | |
33 | + | |
34 | +function _terms() { | |
35 | + local modifier=${1:-all} | |
36 | + local color=${2:-0} | |
37 | + local current_time=`date +%H:%M` | |
38 | + shift 2 | |
39 | + | |
40 | + #dates "$@" | sed '1,/^Fixed date/d; /^$/d; s/[^:]*: //' | |
41 | + dates "$@" | awk -v ctime="${current_time}" -v mod="${modifier}" \ | |
42 | + -v col=${color} -v format=${DATES_FORMAT} ' | |
43 | + BEGIN { | |
44 | + chour = ctime; gsub(/:.*/, "", chour); | |
45 | + cminute = ctime; gsub(/.*:/, "", cminute); | |
46 | + ctime = chour * 60 + cminute | |
47 | + } | |
48 | + | |
49 | + NR == 1, /^Fixed date/ {next} | |
50 | + /^$/ {next} | |
51 | + | |
52 | + { | |
53 | + gsub(/^[^:]*: /, ""); | |
54 | + FS=" "; | |
55 | + hour=$1; gsub(/:.*/, "", hour); | |
56 | + minute=$1; gsub(/.*:/, "", minute); | |
57 | + time = hour * 60 + minute | |
58 | + | |
59 | + color="" | |
60 | + if (format == "i3bar") { | |
61 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
62 | + color="\"color\":\"#00FF00\","; | |
63 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
64 | + color="\"color\":\"#FFFF00\","; | |
65 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
66 | + color="\"color\":\"#FF0000\","; | |
67 | + } | |
68 | + else { | |
69 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
70 | + color="\033[38;5;82m"; | |
71 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
72 | + color="\033[38;5;190m"; | |
73 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
74 | + color="\033[38;5;124m"; | |
75 | + } | |
76 | + | |
77 | + if ((mod == "all") || | |
78 | + (mod == "coming" && (time+5 >= ctime || time == 0)) || | |
79 | + (mod == "past" && (time < ctime || time == 0))) { | |
80 | + | |
81 | + gsub(/\\/, "", $0); | |
82 | + if (format == "i3bar") { | |
83 | + gsub(/"/, "\\\"", $0); | |
84 | + out = color "\"full_text\":\"" $0 "\"" | |
85 | + } | |
86 | + else { | |
87 | + out = color $0 "\033[00m" | |
88 | + } | |
89 | + print out | |
90 | + } | |
91 | + } | |
92 | + | |
93 | + END { | |
94 | + if ("" == out) { | |
95 | + if (format == "i3bar") { | |
96 | + print "\"full_text\":\"none\"" | |
97 | + } | |
98 | + else { | |
99 | + print "none" | |
100 | + } | |
101 | + } | |
102 | + }' | |
103 | +} | |
104 | + | |
105 | +test "X$(basename -- "$0")" = "Xgcal" && gcal "$@" | |
106 | +test "X$(basename -- "$0")" = "Xhollidays" && hollidays "$@" | |
107 | +test "X$(basename -- "$0")" = "Xdates" && dates "$@" | |
108 | +test "X$(basename -- "$0")" = "Xmdates" && mdates "$@" | |
109 | +test "X$(basename -- "$0")" = "Xtcomingf" && tcomingf "$@" | |
110 | +test "X$(basename -- "$0")" = "Xttomorrowf" && ttomorrowf "$@" | |
111 | +test "X$(basename -- "$0")" = "Xtcoming" && tcoming "$@" | |
112 | +test "X$(basename -- "$0")" = "Xtpast" && tpast "$@" | |
113 | +test "X$(basename -- "$0")" = "Xttomorrow" && ttomorrow "$@" | |
114 | +test "X$(basename -- "$0")" = "Xterms" && terms "$@" | |
115 | + | |
116 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/terms
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +## | |
4 | +# various functions and aliases that make gcal more convinient | |
5 | +# | |
6 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
7 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
8 | +# Version: 1.0.0 | |
9 | +# | |
10 | + | |
11 | +alias gcal='LC_MESSAGES=de_DE.UTF-8 /usr/bin/gcal -K -s Monday' | |
12 | +alias hollidays='gcal -qde_hh -n' | |
13 | +alias dates='gcal -c' | |
14 | +alias mdates='gcal -cm' | |
15 | +alias tcomingf='tcoming | sed '\''1!d'\' | |
16 | +alias ttomorrowf='ttomorrow | sed '\''1!d'\' | |
17 | + | |
18 | +function terms() { | |
19 | + _terms "all" 1 "$@" | |
20 | +} | |
21 | + | |
22 | +function tcoming() { | |
23 | + _terms "coming" 1 | |
24 | +} | |
25 | + | |
26 | +function tpast() { | |
27 | + _terms "past" 1 | |
28 | +} | |
29 | + | |
30 | +function ttomorrow() { | |
31 | + _terms "all" 0 -ct | |
32 | +} | |
33 | + | |
34 | +function _terms() { | |
35 | + local modifier=${1:-all} | |
36 | + local color=${2:-0} | |
37 | + local current_time=`date +%H:%M` | |
38 | + shift 2 | |
39 | + | |
40 | + #dates "$@" | sed '1,/^Fixed date/d; /^$/d; s/[^:]*: //' | |
41 | + dates "$@" | awk -v ctime="${current_time}" -v mod="${modifier}" \ | |
42 | + -v col=${color} -v format=${DATES_FORMAT} ' | |
43 | + BEGIN { | |
44 | + chour = ctime; gsub(/:.*/, "", chour); | |
45 | + cminute = ctime; gsub(/.*:/, "", cminute); | |
46 | + ctime = chour * 60 + cminute | |
47 | + } | |
48 | + | |
49 | + NR == 1, /^Fixed date/ {next} | |
50 | + /^$/ {next} | |
51 | + | |
52 | + { | |
53 | + gsub(/^[^:]*: /, ""); | |
54 | + FS=" "; | |
55 | + hour=$1; gsub(/:.*/, "", hour); | |
56 | + minute=$1; gsub(/.*:/, "", minute); | |
57 | + time = hour * 60 + minute | |
58 | + | |
59 | + color="" | |
60 | + if (format == "i3bar") { | |
61 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
62 | + color="\"color\":\"#00FF00\","; | |
63 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
64 | + color="\"color\":\"#FFFF00\","; | |
65 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
66 | + color="\"color\":\"#FF0000\","; | |
67 | + } | |
68 | + else { | |
69 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
70 | + color="\033[38;5;82m"; | |
71 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
72 | + color="\033[38;5;190m"; | |
73 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
74 | + color="\033[38;5;124m"; | |
75 | + } | |
76 | + | |
77 | + if ((mod == "all") || | |
78 | + (mod == "coming" && (time+5 >= ctime || time == 0)) || | |
79 | + (mod == "past" && (time < ctime || time == 0))) { | |
80 | + | |
81 | + gsub(/\\/, "", $0); | |
82 | + if (format == "i3bar") { | |
83 | + gsub(/"/, "\\\"", $0); | |
84 | + out = color "\"full_text\":\"" $0 "\"" | |
85 | + } | |
86 | + else { | |
87 | + out = color $0 "\033[00m" | |
88 | + } | |
89 | + print out | |
90 | + } | |
91 | + } | |
92 | + | |
93 | + END { | |
94 | + if ("" == out) { | |
95 | + if (format == "i3bar") { | |
96 | + print "\"full_text\":\"none\"" | |
97 | + } | |
98 | + else { | |
99 | + print "none" | |
100 | + } | |
101 | + } | |
102 | + }' | |
103 | +} | |
104 | + | |
105 | +test "X$(basename -- "$0")" = "Xgcal" && gcal "$@" | |
106 | +test "X$(basename -- "$0")" = "Xhollidays" && hollidays "$@" | |
107 | +test "X$(basename -- "$0")" = "Xdates" && dates "$@" | |
108 | +test "X$(basename -- "$0")" = "Xmdates" && mdates "$@" | |
109 | +test "X$(basename -- "$0")" = "Xtcomingf" && tcomingf "$@" | |
110 | +test "X$(basename -- "$0")" = "Xttomorrowf" && ttomorrowf "$@" | |
111 | +test "X$(basename -- "$0")" = "Xtcoming" && tcoming "$@" | |
112 | +test "X$(basename -- "$0")" = "Xtpast" && tpast "$@" | |
113 | +test "X$(basename -- "$0")" = "Xttomorrow" && ttomorrow "$@" | |
114 | +test "X$(basename -- "$0")" = "Xterms" && terms "$@" | |
115 | + | |
116 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/tpast
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +## | |
4 | +# various functions and aliases that make gcal more convinient | |
5 | +# | |
6 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
7 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
8 | +# Version: 1.0.0 | |
9 | +# | |
10 | + | |
11 | +alias gcal='LC_MESSAGES=de_DE.UTF-8 /usr/bin/gcal -K -s Monday' | |
12 | +alias hollidays='gcal -qde_hh -n' | |
13 | +alias dates='gcal -c' | |
14 | +alias mdates='gcal -cm' | |
15 | +alias tcomingf='tcoming | sed '\''1!d'\' | |
16 | +alias ttomorrowf='ttomorrow | sed '\''1!d'\' | |
17 | + | |
18 | +function terms() { | |
19 | + _terms "all" 1 "$@" | |
20 | +} | |
21 | + | |
22 | +function tcoming() { | |
23 | + _terms "coming" 1 | |
24 | +} | |
25 | + | |
26 | +function tpast() { | |
27 | + _terms "past" 1 | |
28 | +} | |
29 | + | |
30 | +function ttomorrow() { | |
31 | + _terms "all" 0 -ct | |
32 | +} | |
33 | + | |
34 | +function _terms() { | |
35 | + local modifier=${1:-all} | |
36 | + local color=${2:-0} | |
37 | + local current_time=`date +%H:%M` | |
38 | + shift 2 | |
39 | + | |
40 | + #dates "$@" | sed '1,/^Fixed date/d; /^$/d; s/[^:]*: //' | |
41 | + dates "$@" | awk -v ctime="${current_time}" -v mod="${modifier}" \ | |
42 | + -v col=${color} -v format=${DATES_FORMAT} ' | |
43 | + BEGIN { | |
44 | + chour = ctime; gsub(/:.*/, "", chour); | |
45 | + cminute = ctime; gsub(/.*:/, "", cminute); | |
46 | + ctime = chour * 60 + cminute | |
47 | + } | |
48 | + | |
49 | + NR == 1, /^Fixed date/ {next} | |
50 | + /^$/ {next} | |
51 | + | |
52 | + { | |
53 | + gsub(/^[^:]*: /, ""); | |
54 | + FS=" "; | |
55 | + hour=$1; gsub(/:.*/, "", hour); | |
56 | + minute=$1; gsub(/.*:/, "", minute); | |
57 | + time = hour * 60 + minute | |
58 | + | |
59 | + color="" | |
60 | + if (format == "i3bar") { | |
61 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
62 | + color="\"color\":\"#00FF00\","; | |
63 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
64 | + color="\"color\":\"#FFFF00\","; | |
65 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
66 | + color="\"color\":\"#FF0000\","; | |
67 | + } | |
68 | + else { | |
69 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
70 | + color="\033[38;5;82m"; | |
71 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
72 | + color="\033[38;5;190m"; | |
73 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
74 | + color="\033[38;5;124m"; | |
75 | + } | |
76 | + | |
77 | + if ((mod == "all") || | |
78 | + (mod == "coming" && (time+5 >= ctime || time == 0)) || | |
79 | + (mod == "past" && (time < ctime || time == 0))) { | |
80 | + | |
81 | + gsub(/\\/, "", $0); | |
82 | + if (format == "i3bar") { | |
83 | + gsub(/"/, "\\\"", $0); | |
84 | + out = color "\"full_text\":\"" $0 "\"" | |
85 | + } | |
86 | + else { | |
87 | + out = color $0 "\033[00m" | |
88 | + } | |
89 | + print out | |
90 | + } | |
91 | + } | |
92 | + | |
93 | + END { | |
94 | + if ("" == out) { | |
95 | + if (format == "i3bar") { | |
96 | + print "\"full_text\":\"none\"" | |
97 | + } | |
98 | + else { | |
99 | + print "none" | |
100 | + } | |
101 | + } | |
102 | + }' | |
103 | +} | |
104 | + | |
105 | +test "X$(basename -- "$0")" = "Xgcal" && gcal "$@" | |
106 | +test "X$(basename -- "$0")" = "Xhollidays" && hollidays "$@" | |
107 | +test "X$(basename -- "$0")" = "Xdates" && dates "$@" | |
108 | +test "X$(basename -- "$0")" = "Xmdates" && mdates "$@" | |
109 | +test "X$(basename -- "$0")" = "Xtcomingf" && tcomingf "$@" | |
110 | +test "X$(basename -- "$0")" = "Xttomorrowf" && ttomorrowf "$@" | |
111 | +test "X$(basename -- "$0")" = "Xtcoming" && tcoming "$@" | |
112 | +test "X$(basename -- "$0")" = "Xtpast" && tpast "$@" | |
113 | +test "X$(basename -- "$0")" = "Xttomorrow" && ttomorrow "$@" | |
114 | +test "X$(basename -- "$0")" = "Xterms" && terms "$@" | |
115 | + | |
116 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/ttomorrow
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +## | |
4 | +# various functions and aliases that make gcal more convinient | |
5 | +# | |
6 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
7 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
8 | +# Version: 1.0.0 | |
9 | +# | |
10 | + | |
11 | +alias gcal='LC_MESSAGES=de_DE.UTF-8 /usr/bin/gcal -K -s Monday' | |
12 | +alias hollidays='gcal -qde_hh -n' | |
13 | +alias dates='gcal -c' | |
14 | +alias mdates='gcal -cm' | |
15 | +alias tcomingf='tcoming | sed '\''1!d'\' | |
16 | +alias ttomorrowf='ttomorrow | sed '\''1!d'\' | |
17 | + | |
18 | +function terms() { | |
19 | + _terms "all" 1 "$@" | |
20 | +} | |
21 | + | |
22 | +function tcoming() { | |
23 | + _terms "coming" 1 | |
24 | +} | |
25 | + | |
26 | +function tpast() { | |
27 | + _terms "past" 1 | |
28 | +} | |
29 | + | |
30 | +function ttomorrow() { | |
31 | + _terms "all" 0 -ct | |
32 | +} | |
33 | + | |
34 | +function _terms() { | |
35 | + local modifier=${1:-all} | |
36 | + local color=${2:-0} | |
37 | + local current_time=`date +%H:%M` | |
38 | + shift 2 | |
39 | + | |
40 | + #dates "$@" | sed '1,/^Fixed date/d; /^$/d; s/[^:]*: //' | |
41 | + dates "$@" | awk -v ctime="${current_time}" -v mod="${modifier}" \ | |
42 | + -v col=${color} -v format=${DATES_FORMAT} ' | |
43 | + BEGIN { | |
44 | + chour = ctime; gsub(/:.*/, "", chour); | |
45 | + cminute = ctime; gsub(/.*:/, "", cminute); | |
46 | + ctime = chour * 60 + cminute | |
47 | + } | |
48 | + | |
49 | + NR == 1, /^Fixed date/ {next} | |
50 | + /^$/ {next} | |
51 | + | |
52 | + { | |
53 | + gsub(/^[^:]*: /, ""); | |
54 | + FS=" "; | |
55 | + hour=$1; gsub(/:.*/, "", hour); | |
56 | + minute=$1; gsub(/.*:/, "", minute); | |
57 | + time = hour * 60 + minute | |
58 | + | |
59 | + color="" | |
60 | + if (format == "i3bar") { | |
61 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
62 | + color="\"color\":\"#00FF00\","; | |
63 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
64 | + color="\"color\":\"#FFFF00\","; | |
65 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
66 | + color="\"color\":\"#FF0000\","; | |
67 | + } | |
68 | + else { | |
69 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
70 | + color="\033[38;5;82m"; | |
71 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
72 | + color="\033[38;5;190m"; | |
73 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
74 | + color="\033[38;5;124m"; | |
75 | + } | |
76 | + | |
77 | + if ((mod == "all") || | |
78 | + (mod == "coming" && (time+5 >= ctime || time == 0)) || | |
79 | + (mod == "past" && (time < ctime || time == 0))) { | |
80 | + | |
81 | + gsub(/\\/, "", $0); | |
82 | + if (format == "i3bar") { | |
83 | + gsub(/"/, "\\\"", $0); | |
84 | + out = color "\"full_text\":\"" $0 "\"" | |
85 | + } | |
86 | + else { | |
87 | + out = color $0 "\033[00m" | |
88 | + } | |
89 | + print out | |
90 | + } | |
91 | + } | |
92 | + | |
93 | + END { | |
94 | + if ("" == out) { | |
95 | + if (format == "i3bar") { | |
96 | + print "\"full_text\":\"none\"" | |
97 | + } | |
98 | + else { | |
99 | + print "none" | |
100 | + } | |
101 | + } | |
102 | + }' | |
103 | +} | |
104 | + | |
105 | +test "X$(basename -- "$0")" = "Xgcal" && gcal "$@" | |
106 | +test "X$(basename -- "$0")" = "Xhollidays" && hollidays "$@" | |
107 | +test "X$(basename -- "$0")" = "Xdates" && dates "$@" | |
108 | +test "X$(basename -- "$0")" = "Xmdates" && mdates "$@" | |
109 | +test "X$(basename -- "$0")" = "Xtcomingf" && tcomingf "$@" | |
110 | +test "X$(basename -- "$0")" = "Xttomorrowf" && ttomorrowf "$@" | |
111 | +test "X$(basename -- "$0")" = "Xtcoming" && tcoming "$@" | |
112 | +test "X$(basename -- "$0")" = "Xtpast" && tpast "$@" | |
113 | +test "X$(basename -- "$0")" = "Xttomorrow" && ttomorrow "$@" | |
114 | +test "X$(basename -- "$0")" = "Xterms" && terms "$@" | |
115 | + | |
116 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
tools/ttomorrowf
0 → 100755
1 | +#!/bin/sh | |
2 | + | |
3 | +## | |
4 | +# various functions and aliases that make gcal more convinient | |
5 | +# | |
6 | +# Author: Georg Hopp <ghopp@bigpoint.net> | |
7 | +# Date: Tue Apr 17 17:19:56 CEST 2012 | |
8 | +# Version: 1.0.0 | |
9 | +# | |
10 | + | |
11 | +alias gcal='LC_MESSAGES=de_DE.UTF-8 /usr/bin/gcal -K -s Monday' | |
12 | +alias hollidays='gcal -qde_hh -n' | |
13 | +alias dates='gcal -c' | |
14 | +alias mdates='gcal -cm' | |
15 | +alias tcomingf='tcoming | sed '\''1!d'\' | |
16 | +alias ttomorrowf='ttomorrow | sed '\''1!d'\' | |
17 | + | |
18 | +function terms() { | |
19 | + _terms "all" 1 "$@" | |
20 | +} | |
21 | + | |
22 | +function tcoming() { | |
23 | + _terms "coming" 1 | |
24 | +} | |
25 | + | |
26 | +function tpast() { | |
27 | + _terms "past" 1 | |
28 | +} | |
29 | + | |
30 | +function ttomorrow() { | |
31 | + _terms "all" 0 -ct | |
32 | +} | |
33 | + | |
34 | +function _terms() { | |
35 | + local modifier=${1:-all} | |
36 | + local color=${2:-0} | |
37 | + local current_time=`date +%H:%M` | |
38 | + shift 2 | |
39 | + | |
40 | + #dates "$@" | sed '1,/^Fixed date/d; /^$/d; s/[^:]*: //' | |
41 | + dates "$@" | awk -v ctime="${current_time}" -v mod="${modifier}" \ | |
42 | + -v col=${color} -v format=${DATES_FORMAT} ' | |
43 | + BEGIN { | |
44 | + chour = ctime; gsub(/:.*/, "", chour); | |
45 | + cminute = ctime; gsub(/.*:/, "", cminute); | |
46 | + ctime = chour * 60 + cminute | |
47 | + } | |
48 | + | |
49 | + NR == 1, /^Fixed date/ {next} | |
50 | + /^$/ {next} | |
51 | + | |
52 | + { | |
53 | + gsub(/^[^:]*: /, ""); | |
54 | + FS=" "; | |
55 | + hour=$1; gsub(/:.*/, "", hour); | |
56 | + minute=$1; gsub(/.*:/, "", minute); | |
57 | + time = hour * 60 + minute | |
58 | + | |
59 | + color="" | |
60 | + if (format == "i3bar") { | |
61 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
62 | + color="\"color\":\"#00FF00\","; | |
63 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
64 | + color="\"color\":\"#FFFF00\","; | |
65 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
66 | + color="\"color\":\"#FF0000\","; | |
67 | + } | |
68 | + else { | |
69 | + if (col != 0 && time != 0 && time-ctime <= 15) | |
70 | + color="\033[38;5;82m"; | |
71 | + if (col != 0 && time != 0 && time-ctime <= 5) | |
72 | + color="\033[38;5;190m"; | |
73 | + if (col != 0 && time != 0 && time-ctime <= 0) | |
74 | + color="\033[38;5;124m"; | |
75 | + } | |
76 | + | |
77 | + if ((mod == "all") || | |
78 | + (mod == "coming" && (time+5 >= ctime || time == 0)) || | |
79 | + (mod == "past" && (time < ctime || time == 0))) { | |
80 | + | |
81 | + gsub(/\\/, "", $0); | |
82 | + if (format == "i3bar") { | |
83 | + gsub(/"/, "\\\"", $0); | |
84 | + out = color "\"full_text\":\"" $0 "\"" | |
85 | + } | |
86 | + else { | |
87 | + out = color $0 "\033[00m" | |
88 | + } | |
89 | + print out | |
90 | + } | |
91 | + } | |
92 | + | |
93 | + END { | |
94 | + if ("" == out) { | |
95 | + if (format == "i3bar") { | |
96 | + print "\"full_text\":\"none\"" | |
97 | + } | |
98 | + else { | |
99 | + print "none" | |
100 | + } | |
101 | + } | |
102 | + }' | |
103 | +} | |
104 | + | |
105 | +test "X$(basename -- "$0")" = "Xgcal" && gcal "$@" | |
106 | +test "X$(basename -- "$0")" = "Xhollidays" && hollidays "$@" | |
107 | +test "X$(basename -- "$0")" = "Xdates" && dates "$@" | |
108 | +test "X$(basename -- "$0")" = "Xmdates" && mdates "$@" | |
109 | +test "X$(basename -- "$0")" = "Xtcomingf" && tcomingf "$@" | |
110 | +test "X$(basename -- "$0")" = "Xttomorrowf" && ttomorrowf "$@" | |
111 | +test "X$(basename -- "$0")" = "Xtcoming" && tcoming "$@" | |
112 | +test "X$(basename -- "$0")" = "Xtpast" && tpast "$@" | |
113 | +test "X$(basename -- "$0")" = "Xttomorrow" && ttomorrow "$@" | |
114 | +test "X$(basename -- "$0")" = "Xterms" && terms "$@" | |
115 | + | |
116 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
vcs.sh
0 → 100644
1 | +vcs() { | |
2 | + local VCS REF | |
3 | + | |
4 | + git_dir() { | |
5 | + [ 'true' != "$(git rev-parse --is-inside-work-tree 2>/dev/null)" ] && return 1 | |
6 | + REF=$(git symbolic-ref -q HEAD || git name-rev --name-only HEAD 2>/dev/null) | |
7 | + REF=${REF#refs/heads/} | |
8 | + VCS="git" | |
9 | + } | |
10 | + | |
11 | + svn_dir() { | |
12 | + local INFO | |
13 | + INFO="$(svn info 2>/dev/null)" || return 1 | |
14 | + REF=$(echo "${INFO}" | awk '/^Repository Root/ { sub(".*/","",$0); r=$0 } /^Revision/ { sub("[^0-9]*","",$0); print r":"$0 }') | |
15 | + VCS="svn" | |
16 | + } | |
17 | + | |
18 | + git_dir || svn_dir | |
19 | + | |
20 | + echo "${VCS:+[${VCS}|${REF}]}" | |
21 | +} | |
22 | + | |
23 | +# vim: set ft=sh ts=4 sw=4: | ... | ... |
Please
register
or
login
to post a comment