summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2018-05-04 12:39:01 (EDT)
committer P. J. McDermott <pj@pehjota.net>2018-05-04 12:39:01 (EDT)
commit82a11c00fe5d443fa0604cf21cc098d932176f5c (patch)
tree7a7d4d6782253f95984e2f491aa271213fbed1f3 /bin
parent8ebdb567f49145f1137016a5a1f67be8c50c45ca (diff)
downloadfluxbox-82a11c00fe5d443fa0604cf21cc098d932176f5c.zip
fluxbox-82a11c00fe5d443fa0604cf21cc098d932176f5c.tar.gz
fluxbox-82a11c00fe5d443fa0604cf21cc098d932176f5c.tar.bz2
bin/chdt: Read desktop geometry settings from rc file
Diffstat (limited to 'bin')
-rwxr-xr-xbin/chdt34
1 files changed, 20 insertions, 14 deletions
diff --git a/bin/chdt b/bin/chdt
index a6e1e5d..3a29ae5 100755
--- a/bin/chdt
+++ b/bin/chdt
@@ -2,9 +2,10 @@
set -eu
-ROWS=2
-COLS=6
-ORIENTATION='horizontal'
+# Default values, overridden in ~/.chdtrc
+rows=2
+cols=6
+orientation='horizontal'
debug=0
@@ -53,22 +54,22 @@ inc_desktop()
local dx=${2}
local dy=${3}
- case "${ORIENTATION}" in
+ case "${orientation}" in
[Hh]*)
- x=$((${dt} % ${COLS}))
- y=$((${dt} / ${COLS}))
+ x=$((${dt} % ${cols}))
+ y=$((${dt} / ${cols}))
dbg 'Old coordinates: (%d, %d)' ${x} ${y}
- x=$(((${x} + ${COLS} + ${dx}) % ${COLS}))
- y=$(((${y} + ${ROWS} + ${dy}) % ${ROWS}))
+ x=$(((${x} + ${cols} + ${dx}) % ${cols}))
+ y=$(((${y} + ${rows} + ${dy}) % ${rows}))
dbg 'New coordinates: (%d, %d)' ${x} ${y}
- dt=$((${y} * ${COLS} + ${x}))
+ dt=$((${y} * ${cols} + ${x}))
;;
[Vv]*)
- x=$((${dt} / ${ROWS}))
- y=$((${dt} % ${ROWS}))
- x=$(((${x} + ${dx}) % ${COLS}))
- y=$(((${y} + ${dy}) % ${ROWS}))
- dt=$((${x} * ${ROWS} + ${y}))
+ x=$((${dt} / ${rows}))
+ y=$((${dt} % ${rows}))
+ x=$(((${x} + ${dx}) % ${cols}))
+ y=$(((${y} + ${dy}) % ${rows}))
+ dt=$((${x} * ${rows} + ${y}))
;;
esac
@@ -162,6 +163,11 @@ main()
;;
esac
+ # POSIX on the dot utility:
+ # "If no readable file is found, a non-interactive shell shall abort"
+ # So to survive an ENOENT or other error, we need this eval/cat command.
+ eval "$(cat ~/.chdtrc 2>/dev/null || :)"
+
cur_dt=$(get_desktop) || return 1
new_dt=$(inc_desktop ${cur_dt} ${dx} ${dy})
case ${move_win} in