1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- #!/bin/bash
-
- . $(ffoom path)
-
- ffoo import inigrep
- ffoo import pretty
-
-
- usage() {
- mkusage "[show]" \
- "next" \
- "home" \
- "layout LAYOUT"
- }
-
- next_layout() {
- #
- # change layout to the next one in row
- #
- local cur="$current_layout"
- local all="$(inigrep -p kb.layout)"
- local def="$default_layout"
- local nxt=$(
- echo -e "$all\n$all" \
- | grep -m 1 -A 1 $cur \
- | tail -1
- )
- test -z "$nxt" && nxt=$def
- test -z "$nxt" && nxt=us
- debug -v all def cur nxt
- echo "$nxt"
- }
-
- default_layout="$(inigrep -1 -p kb.layout)"
- current_layout="$(setxkbmap -v | grep '^symbols: ' | cut -d+ -f2)"
-
- layout=""
- action=show
- case "$1" in
- home) action=set; layout="$default_layout" ;;
- next) action=set; layout="$(next_layout)" ;;
- layout) action=set; layout="$2" ;;
- ""|show) true ;;
- *) usage ;;
- esac
-
-
- debug -v layout current_layout default_layout
-
- case "$action" in
- show)
- echo "$current_layout"
- exit
- ;;
- set)
- test -n "$layout" || usage
- setxkbmap "$layout"
- ;;
- esac
|