From ddb7692a2f93dca1ebf39a8ea7a710363aea516a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 6 Dec 2016 21:45:25 -0500 Subject: wmii: Support the rotate screen button on my x60 tablet --- .config/wmii-hg/config.sh | 11 +++++ .local/bin/xrotate | 117 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100755 .local/bin/xrotate diff --git a/.config/wmii-hg/config.sh b/.config/wmii-hg/config.sh index 1b48cc4..ffb5f20 100644 --- a/.config/wmii-hg/config.sh +++ b/.config/wmii-hg/config.sh @@ -263,6 +263,17 @@ Key() { sel=$(sed 1q $WMII_DIR/client/sel/ctl) tag=$(lstags | wimenu -h "${HIST}.tags" -n 50) || return echo "$tag" >> $WMII_DIR/client/$sel/tags;; + + ## Hardware keys + XF86RotateWindows) ## Rotate the screen + local old new + old="$(xrotate|cut -d $'\t' -f3|sort -u)" + case "$old" in + normal) new=right;; + *) new=normal;; + esac + xrotate "$new" + ;; esac } diff --git a/.local/bin/xrotate b/.local/bin/xrotate new file mode 100755 index 0000000..55b4e88 --- /dev/null +++ b/.local/bin/xrotate @@ -0,0 +1,117 @@ +#!/usr/bin/env bash + +# xrandr (graphical output) ############################################ +type xrandr &>/dev/null && modules+=(xrandr) + +xrandr.get() { + xrandr --query --verbose|awk -v OFS=$'\t' '/ connected /{print "xrandr", $1, $5}' +} + +xrandr.set() { + xrandr --orientation "$1" +} + +# xsetwacom (touchscreen input) ######################################## +type xsetwacom &>/dev/null && modules+=(xsetwacom) + +xsetwacom.get() { + local device + xsetwacom --list devices|cut -d $'\t' -f1|while read -r device; do + printf 'xsetwacom\t%s\t%s\n' "$device" "$(xsetwacom --get "$device" Rotate)" + done | sed -e $'s/\tnone$/\tnormal/' \ + -e $'s/\tcw$/\tright/' \ + -e $'s/\tccw$/\tleft/' \ + -e $'s/\thalf$/\tinverted/' +} + +xsetwacom.set() { + declare -A xrandr2wacom + xrandr2wacom[normal]=none + xrandr2wacom[left]=ccw + xrandr2wacom[right]=cw + xrandr2wacom[inverted]=half + + local device + local r=0 + xsetwacom --list devices|cut -d $'\t' -f1|while read -r device; do + xsetwacom --set "$device" Rotate ${xrandr2wacom[$1]} || r=$? + done + return $r +} + +# xmodmap (D-pad input) ################################################ +type xmodmap &>/dev/null && modules+=(xmodmap) + +declare -A xrandr2xmodmap +xrandr2xmodmap[keycode]=' 111 113 114 116 ' +xrandr2xmodmap[normal]=' Up Left Right Down ' +xrandr2xmodmap[left]=' Right Up Down Left ' +xrandr2xmodmap[right]=' Left Down Up Right' +xrandr2xmodmap[inverted]='Down Right Left Up ' + +xmodmap.get() { + local cur=malformed + + local keys=($(xmodmap -pke | grep -f <(printf '^keycode %s =\n' ${xrandr2xmodmap[keycode]})|awk '{print $4}')) + local k + for k in normal left right inverted; do + if [[ "$(echo ${xrandr2xmodmap[$k]})" = "${keys[*]}" ]]; then + cur=$k + fi + done + printf 'xmodmap\t-\t%s\n' "$cur" +} + +xmodmap.set() { + paste \ + <(printf '%s\n' ${xrandr2xmodmap[keycode]}) \ + <(printf '%s\n' ${xrandr2xmodmap[$1]}) \ + | awk '{print "keycode", $1, "=", $2}' | xmodmap - +} + +# main ################################################################# + +usage() { + . libremessages + print 'Usage: %q [-h|--help|normal|left|right|inverted]' "${0##*/}" + print 'Get or set screen rotation.' + echo + prose 'Without any arguments, return the screen rotation as + reported by supported subsystems. The output format is:' + echo + print ' SUBSYSTEM DEVICE STATE ' +} + +xget() { + local r=0 + local module + for module in "${modules[@]}"; do + "${module}.get" || r=$? + done + return $r +} + +xset() { + local r=0 + local module + for module in "${modules[@]}"; do + "${module}.set" "$1" || r=$? + done + return $r +} + +main() { + case $# in + 0) xget;; + 1) + case "$1" in + normal|left|right|inverted) xset "$1";; + -h|--help) usage;; + *) usage >&2; exit 1;; + esac + ;; + *) usage >&2; exit 1;; + esac +} + +main "$@" -- cgit v1.1-4-g5e80 From 07ec79433657e754965dd2eb7a324512d46a72ee Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 7 Dec 2016 19:57:05 -0500 Subject: rbar: be more compact --- .config/wmii-hg/rbar_acpi | 3 ++- .config/wmii-hg/rbar_clock | 2 +- .config/wmii-hg/rbar_wifi | 11 +---------- .local/bin/iwdata | 8 ++++++++ 4 files changed, 12 insertions(+), 12 deletions(-) create mode 100755 .local/bin/iwdata diff --git a/.config/wmii-hg/rbar_acpi b/.config/wmii-hg/rbar_acpi index 6e3e6e5..7c1d18b 100755 --- a/.config/wmii-hg/rbar_acpi +++ b/.config/wmii-hg/rbar_acpi @@ -15,7 +15,8 @@ update() { -e 's/\s*remaining//g' \ -e 's/\s*until charged//g' \ -e 's/charging at zero rate - will never fully charge./∞/g' \ - -e 's/\s*ok,\s*//g' | + -e 's/\s*ok,\s*//g' \ + -e 's/\s+//g' | cat -n | while read -r n line; do printf "label %s\n" "$line" | write "${id}.${n}" done diff --git a/.config/wmii-hg/rbar_clock b/.config/wmii-hg/rbar_clock index e84d5c3..c66b21e 100755 --- a/.config/wmii-hg/rbar_clock +++ b/.config/wmii-hg/rbar_clock @@ -7,7 +7,7 @@ update() { while true; do { printf 'label ' - date +'%a, %F %T %Z(%:::z)' + date +'%a %F %T %Z(%:::z)' } | write "$id" sleep .5 done diff --git a/.config/wmii-hg/rbar_wifi b/.config/wmii-hg/rbar_wifi index d201152..e740777 100755 --- a/.config/wmii-hg/rbar_wifi +++ b/.config/wmii-hg/rbar_wifi @@ -1,14 +1,5 @@ #!/usr/bin/env bash -iwinfo() { - local interface=$1 - iwconfig "$interface" | - sed -r 's/ {2,}/\n/g' | - sed -e '/^\s*$/d' -e 's/:\s*/=/' \ - -e '1s/^/Interface=/' \ - -e '2s/^/MAC Protocol=/' -} - update() { local iface=wlp2s0 @@ -18,7 +9,7 @@ update() { while true; do IFS=$'\n' lines=($( - iwinfo "$iface" | sed -rn 's@^(ESSID|Link Quality)=@@p' + iwdata "$iface" | sed -rn 's@^(ESSID|Link Quality)=@@p' ifdata -pa "$iface" )) IFS='|' diff --git a/.local/bin/iwdata b/.local/bin/iwdata new file mode 100755 index 0000000..a631d6d --- /dev/null +++ b/.local/bin/iwdata @@ -0,0 +1,8 @@ +#!/bin/sh + +iwconfig "$1" | +sed -r 's/ {2,}/\n/g' | +sed -e '/^\s*$/d' -e 's/:\s*/=/' \ + -e '1s/^/Interface=/' \ + -e '2s/^/MAC Protocol=/' \ + -e 's/^ESSID="\(.*\)"$/ESSID=\1/' -- cgit v1.1-4-g5e80 From 3480ad667f090731ce1424efda3cad4c55b697c8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2017 18:39:30 -0500 Subject: bash: systemd aliases --- .config/bash/rc.d/10_aliases.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.config/bash/rc.d/10_aliases.sh b/.config/bash/rc.d/10_aliases.sh index 2e28a5d..e33ff53 100644 --- a/.config/bash/rc.d/10_aliases.sh +++ b/.config/bash/rc.d/10_aliases.sh @@ -100,9 +100,12 @@ alias l='ls -CF' alias tree='tree --charset utf8' alias cd=pushd alias gitk='gitk --all --date-order' -alias userctl='systemctl --user' alias mv='mv -i' +alias userctl='systemctl --user' +alias journalctl='journalctl --no-hostname' # I know what host I'm on +alias datetimectl=timedatectl # I forget which it is + ###################################################################### # These are actually functions :P # ###################################################################### -- cgit v1.1-4-g5e80 From 461cdd261c53674b0da09f9101f3665c8f1cfd1d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2017 19:02:11 -0500 Subject: bash: add `calc` function --- .config/bash/rc.d/10_aliases.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.config/bash/rc.d/10_aliases.sh b/.config/bash/rc.d/10_aliases.sh index e33ff53..8499bde 100644 --- a/.config/bash/rc.d/10_aliases.sh +++ b/.config/bash/rc.d/10_aliases.sh @@ -178,3 +178,6 @@ jarmain() { grep -E '(^[a-z]|public static void main\(java\.lang\.String\[\]\))' | grep -B1 '^ ' } +calc() { + bc <<<"$*" +} -- cgit v1.1-4-g5e80 From 6e75c582ffcc1ddd5d0be97379f64ead21232080 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2017 19:02:39 -0500 Subject: ssh: more host configurations --- .config/ssh/config | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.config/ssh/config b/.config/ssh/config index 9dbf510..7687d08 100644 --- a/.config/ssh/config +++ b/.config/ssh/config @@ -20,13 +20,20 @@ Host parabola.nu *.parabola.nu # Personal ################################################# -Host lukeshu.com +Host lukeshu.com *.lukeshu.com Port 1863 User lukeshu Host ssl.lukeshu.com User lukeshu ProxyCommand proxytunnel --proxy=lukeshu.com:8443 --proxyauth=frc4272:password --encrypt-proxy --dest=lukeshu.com:1863 +Host team4272.com + Port 1863 + User lukeshu +Host ssl.team4272.com + User lukeshu + ProxyCommand proxytunnel --proxy=lukeshu.com:8443 --proxyauth=frc4272:password --encrypt-proxy --dest=team4272.com:1863 + Match host build64-par exec "nslookup %n.lan." HostName build64-par Port 22 @@ -37,6 +44,6 @@ Host build64-par ForwardX11 yes ForwardX11Trusted yes -Host 192.168.*.1 10.* +Host 192.168.*.1 10.* 169.254.* roborio-*-frc.local StrictHostKeyChecking no UserKnownHostsFile /dev/null -- cgit v1.1-4-g5e80 From 4d327ed17d90f7c32c2e9f73736b511c17b54699 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2017 19:02:59 -0500 Subject: config-path: recognize go 1.8 implicit GOPATH --- .local/bin/config-path | 1 + 1 file changed, 1 insertion(+) diff --git a/.local/bin/config-path b/.local/bin/config-path index dcac0e8..74748f7 100755 --- a/.local/bin/config-path +++ b/.local/bin/config-path @@ -9,6 +9,7 @@ prefixes=( "$HOME/.prefix" "$HOME"/.gem/ruby/* "$HOME"/.npm-prefix + "$HOME"/go ) in_array() { -- cgit v1.1-4-g5e80 From c47626e1dadc96162cf65af6c1f2485e37ce865b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2017 19:03:14 -0500 Subject: xrotate: fix, kinda --- .local/bin/xrotate | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.local/bin/xrotate b/.local/bin/xrotate index 55b4e88..c7d9f0d 100755 --- a/.local/bin/xrotate +++ b/.local/bin/xrotate @@ -4,7 +4,9 @@ type xrandr &>/dev/null && modules+=(xrandr) xrandr.get() { - xrandr --query --verbose|awk -v OFS=$'\t' '/ connected /{print "xrandr", $1, $5}' + # FIXME: I don't think simple column counting is reliable. + # I'll have to study the exact output format. + xrandr --query --verbose|awk -v OFS=$'\t' '/ connected /{print "xrandr", $1, $6}' } xrandr.set() { -- cgit v1.1-4-g5e80 From 0c3fdcfa05aeaa47430d0aede456f32c9d741301 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2017 18:55:57 -0500 Subject: bash: turn of '!' history expansion --- .config/bash/rc.d/10_no_histexpand.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .config/bash/rc.d/10_no_histexpand.sh diff --git a/.config/bash/rc.d/10_no_histexpand.sh b/.config/bash/rc.d/10_no_histexpand.sh new file mode 100644 index 0000000..985b03d --- /dev/null +++ b/.config/bash/rc.d/10_no_histexpand.sh @@ -0,0 +1,4 @@ +#!/hint/bash + +# Turn off (csh-style) '!' history expansion +set +o histexpand -- cgit v1.1-4-g5e80 From 15452ba20c9d2cd652186c610ed3ada798b78e08 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2017 19:07:17 -0500 Subject: emacs: play nice with ssh --- .config/emacs/init.el | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index b7ee6df..be98b5f 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -179,6 +179,10 @@ sh-script.el is broken." (if xterm-mouse-mode (xterm-mouse-mode 1)) ))) +;; Make TRAMP obey ~/.ssh/config for ControlMaster. For some reason, +;; customize doesn't correctly set this. +(setq tramp-use-ssh-controlmaster-options nil) + ;; Use mailcrypt to encrypt/decrypt email (when (require 'mailcrypt nil t) (mc-setversion "gpg") -- cgit v1.1-4-g5e80 From 796c1def3ffdd2c5619bae6e544744f14849f730 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2017 19:07:52 -0500 Subject: emacs: move eshell and ido.last.el into XDG_DATA_HOME --- .config/emacs/init.el | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index be98b5f..3ac58cf 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -2,19 +2,21 @@ ;; Hey, Emacs: -*- Indent-tabs-mode: nil -*- ;; Without (advice-add) it should work in older versions of Emacs 24. ;;;; Use XDG-ish locations ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(setq xdg-cache-home (file-name-as-directory (or (getenv "XDG_CACHE_HOME") "~/.cache"))) -(setq - package-user-dir (concat xdg-cache-home "emacs/elpa") - ido-save-directory-list-file (concat xdg-cache-home "emacs/ido.last.el") - el-get-dir (concat xdg-cache-home "emacs/el-get/") - eshell-directory-name (concat xdg-cache-home "emacs/eshell/") - wl-score-files-directory (concat xdg-cache-home "emacs/wl-score-files/") - elmo-msgdb-directory (concat xdg-cache-home "emacs/elmo-msgdb/") - elmo-cache-directory (concat xdg-cache-home "emacs/elmo-cache/") - auto-save-list-file-prefix (concat xdg-cache-home "emacs/auto-save-list/saves-") - tramp-persistency-file-name (concat xdg-cache-home "emacs/tramp-cache.el") - wl-init-file (concat user-emacs-directory "wl.el") - ) +(let ((xdg-cache-home (file-name-as-directory (or (getenv "XDG_CACHE_HOME") "~/.cache"))) + (xdg-data-home (file-name-as-directory (or (getenv "XDG_DATA_HOME") "~/.local/share")))) + (setq + wl-init-file (concat user-emacs-directory "wl.el") + eshell-directory-name (concat xdg-data-home "emacs/eshell/") ;; actually should be split between config and data + ido-save-directory-list-file (concat xdg-data-home "emacs/ido.last.el") + + package-user-dir (concat xdg-cache-home "emacs/elpa") + el-get-dir (concat xdg-cache-home "emacs/el-get/") + wl-score-files-directory (concat xdg-cache-home "emacs/wl-score-files/") + elmo-msgdb-directory (concat xdg-cache-home "emacs/elmo-msgdb/") + elmo-cache-directory (concat xdg-cache-home "emacs/elmo-cache/") + auto-save-list-file-prefix (concat xdg-cache-home "emacs/auto-save-list/saves-") + tramp-persistency-file-name (concat xdg-cache-home "emacs/tramp-cache.el") + )) (setq custom-file (concat user-emacs-directory "custom.el")) (load custom-file 'noerror) -- cgit v1.1-4-g5e80 From 5cbeb557303e1249bf3eb0c671018894f1892838 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2017 19:08:11 -0500 Subject: emacs: add editorconfig and cmake-mode --- .config/emacs/init.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.config/emacs/init.el b/.config/emacs/init.el index 3ac58cf..200daad 100644 --- a/.config/emacs/init.el +++ b/.config/emacs/init.el @@ -73,6 +73,7 @@ (smart-tabs-mode 1) (apply 'smart-tabs-insinuate (mapcar 'car smart-tabs-insinuate-alist)))) +(use-package editorconfig) ;; Major modes (use-package bison-mode :mode (("\\.l\\'" . bison-mode) @@ -97,7 +98,7 @@ ;; '(lambda () ;; (c-set-offset 'cpp-macro 0) ;; ))) -(use-package php-mode :mode ("\\.php[s345t]?\\'" "/\\.php_cs\\(\\.dist\\)?\\'" "\\.phtml\\'" "/Amkfile\\'" "\\.amk\\'")) +(use-package cmake-mode :mode ("CMakeLists\\.txt\\'" "\\.cmake\\'")) (use-package glsl-mode :mode ("\\.vert\\'" "\\.frag\\'" "\\.geom\\'" "\\.glsl\\'")) (use-package go-mode :mode "\\.go\\'") (use-package graphviz-dot-mode :mode ("\\.dot\\'" "\\.gv\\'")) @@ -105,6 +106,7 @@ (use-package less-css-mode :mode "\\.less\\'") (use-package markdown-mode :mode ("\\.markdown\\'" "\\.md\\'" "\\.ronn\\'")) (use-package nginx-mode :mode ("nginx\\.conf\\'" "/nginx/.+\\.conf\\'")) +(use-package php-mode :mode ("\\.php[s345t]?\\'" "/\\.php_cs\\(\\.dist\\)?\\'" "\\.phtml\\'" "/Amkfile\\'" "\\.amk\\'")) (use-package scss-mode :mode "\\.scss\\'") (use-package yaml-mode :mode "\\.e?ya?ml\\'") -- cgit v1.1-4-g5e80 From 58f68e4899bd0b55c10b1f3322b1378d1e009030 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2017 19:10:49 -0500 Subject: wmii: Make it possible to move windows between columns w/ mouse --- .config/wmii-hg/config.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.config/wmii-hg/config.sh b/.config/wmii-hg/config.sh index ffb5f20..402ae52 100644 --- a/.config/wmii-hg/config.sh +++ b/.config/wmii-hg/config.sh @@ -123,13 +123,17 @@ Event() { 2) ;; 3) { - case $(wmii9menu Delete Fullscreen ToggleFloat) in + case $(wmii9menu Delete Fullscreen ToggleFloat SendLeft SendRight) in Delete) echo kill >> $WMII_DIR/client/$client/ctl;; Fullscreen) echo Fullscreen on >> $WMII_DIR/client/$client/ctl;; ToggleFloat) echo send $client toggle >> $WMII_DIR/tag/sel/ctl;; + SendLeft) + echo send sel left >> $WMII_DIR/tag/sel/ctl;; + SendRight) + echo send sel right >> $WMII_DIR/tag/sel/ctl;; esac }& ;; 4) ;; -- cgit v1.1-4-g5e80 From b9d017e5ae3de10c8aa7a213537f2ee0c0c4c45d Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 11 Feb 2017 19:11:19 -0500 Subject: wmii: better rotation support --- .config/wmii-hg/config.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.config/wmii-hg/config.sh b/.config/wmii-hg/config.sh index 402ae52..ba40460 100644 --- a/.config/wmii-hg/config.sh +++ b/.config/wmii-hg/config.sh @@ -269,7 +269,7 @@ Key() { echo "$tag" >> $WMII_DIR/client/$sel/tags;; ## Hardware keys - XF86RotateWindows) ## Rotate the screen + XF86RotateWindows) ## Toggle between 'normal' an 'right' local old new old="$(xrotate|cut -d $'\t' -f3|sort -u)" case "$old" in @@ -278,6 +278,17 @@ Key() { esac xrotate "$new" ;; + $MODKEY-XF86RotateWindows) ## Rotate in 90° steps + local old new + old="$(xrotate|cut -d $'\t' -f3|sort -u)" + case "$old" in + normal) new=right;; + right) new=inverted;; + inverted) new=left;; + left) new=normal;; + esac + xrotate "$new" + ;; esac } -- cgit v1.1-4-g5e80