summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
Diffstat (limited to '.local')
-rwxr-xr-x.local/bin/config-path5
-rwxr-xr-x.local/bin/iwdata8
-rwxr-xr-x.local/bin/xrotate119
3 files changed, 129 insertions, 3 deletions
diff --git a/.local/bin/config-path b/.local/bin/config-path
index dcac0e8..cbecc95 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() {
@@ -50,7 +51,6 @@ main() {
IFS=:
# Import existing values
var_init PATH
- var_init MANPATH
var_init LD_LIBRARY_PATH
var_init PKG_CONFIG_PATH
var_init RUBYLIB
@@ -59,7 +59,6 @@ main() {
# Scan through prefixes
for prefix in "${prefixes[@]}"; do
var_add PATH "$prefix/bin" "$prefix/sbin"
- var_add MANPATH "$prefix/share/man"
var_add LD_LIBRARY_PATH "$prefix"/lib{,32,64}
var_add PKG_CONFIG_PATH "$prefix"/lib{,32,64}/pkgconfig
var_add RUBYLIB "$prefix"/lib{,32,64}
@@ -68,7 +67,7 @@ main() {
# Finally, print the values
lines=()
- for var in PATH MANPATH LD_LIBRARY_PATH PKG_CONFIG_PATH RUBYLIB PERL5LIB; do
+ for var in PATH LD_LIBRARY_PATH PKG_CONFIG_PATH RUBYLIB PERL5LIB; do
lines+=("$(var_done "$var")")
done
shopt -s extglob
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/'
diff --git a/.local/bin/xrotate b/.local/bin/xrotate
new file mode 100755
index 0000000..c7d9f0d
--- /dev/null
+++ b/.local/bin/xrotate
@@ -0,0 +1,119 @@
+#!/usr/bin/env bash
+
+# xrandr (graphical output) ############################################
+type xrandr &>/dev/null && modules+=(xrandr)
+
+xrandr.get() {
+ # 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() {
+ 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 <tab> DEVICE <tab> STATE <newline>'
+}
+
+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 "$@"