dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 2b14d0d08b6bfede5d9bb72fe69d32e0674e1f0e
parent 4170c07b33944c81c52ffd0607c546e80a329115
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Wed,  9 Jan 2019 19:07:40 +0100

Improve layout switching and use danish during texting

Diffstat:
Mlinks/bin/keyboard-layout-switch.sh | 39+++++++++++++++++++--------------------
Mlinks/bin/textqr | 5+++++
2 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/links/bin/keyboard-layout-switch.sh b/links/bin/keyboard-layout-switch.sh @@ -1,37 +1,36 @@ #!/bin/bash # the language is written to ./.kbd-layout -LAYOUTFILE="$HOME/.kbd-layout" +layoutfile="$HOME/.kbd-layout" # define two languages -LANG1="us" -LANG2="dk" +lang1="us" +lang2="dk" -# make the caps lock key a ctrl key -#OPTS="-option ctrl:nocaps,altwin:swap_lalt_lwin" -OPTS="-option ctrl:nocaps" +function set_language { + setxkbmap "$1" -option ctrl:nocaps + notify-send "$1" + xmodmap ~/.Xmodmap + echo "$1" > "$layoutfile" + exit 0 +} + +[[ $# -gt 0 ]] && set_language "$1" # write the file if it doesn't exist -if [ ! -f $LAYOUTFILE ]; then - echo 'echo "us" > $LAYOUTFILE' - echo "us" > $LAYOUTFILE - setxkbmap $LANG1 $OPTS +if [ ! -f $layoutfile ]; then + echo "us" > $layoutfile + setxkbmap "$lang1" xmodmap ~/.Xmodmap #notify-send $LANG1 exit fi # read the language file, and switch to the other language -CURRLANG="`cat $LAYOUTFILE`" +currlang="$(cat $layoutfile)" -if [ "$CURRLANG" = "$LANG1" ]; then - echo $LANG2 > $LAYOUTFILE - setxkbmap $LANG2 $OPTS - notify-send $LANG2 - xmodmap ~/.Xmodmap +if [ "$currlang" = "$lang1" ]; then + set_language "$lang2" else - echo $LANG1 > $LAYOUTFILE - setxkbmap $LANG1 $OPTS - notify-send $LANG1 - xmodmap ~/.Xmodmap + set_language "$lang1" fi diff --git a/links/bin/textqr b/links/bin/textqr @@ -1,7 +1,10 @@ #!/usr/bin/env bash +set -e pgrep -x dmenu && exit +keyboard-layout-switch.sh dk + names="susan\nanders\nchristian\njesper\nsimon\nfar\nmor\nlars" recipient=$(echo -e "${names[@]}" | dmenu -i -p "To:" || exit 1) @@ -38,6 +41,8 @@ esac message=$(echo "💬" | dmenu -i -p "Message:") || exit 1 +keyboard-layout-switch.sh us + qrencode -o - -s 1 \ "$number $message" | feh --auto-zoom \