-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswap-win-alt.sh
executable file
·42 lines (36 loc) · 1007 Bytes
/
swap-win-alt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
#
# configures mac keyboard mode
#
# swaps the positions of the alt/win keys
#
# accepts arg of {ON/OFF/TOGGLE} to set swap state
SESSION_TYPE="$(~/.scripts/get-session-type.sh)"
ENABLED="$(setxkbmap -query | grep 'altwin:swap_alt_win' -c)"
ACTION=$1
if [ -z "$ACTION" ] || [ $ACTION == "TOGGLE" ]; then
if [ $ENABLED == "0" ]; then
ACTION=ON
else
ACTION=OFF
fi
fi
if [ $ACTION == "ON" ]; then
setxkbmap -option
setxkbmap -option "apple:alupckeys,altwin:swap_alt_win"
if [[ $SESSION_TYPE == "wayland" ]]; then
swaymsg "input type:keyboard xkb_options \"apple:alupckeys,altwin:swap_alt_win\""
fi
notify-send -u low "Alt-win swapped."
else
setxkbmap -option
setxkbmap -option "apple:alupckeys"
if [[ $SESSION_TYPE == "wayland" ]]; then
swaymsg "input type:keyboard xkb_options \"apple:alupckeys\""
fi
notify-send -u low "Alt-win unswapped."
fi
if [[ $SESSION_TYPE == "x11" ]]; then
# reapply custom keymap modifications from .Xmodmap
cat $HOME/.Xmodmap | xmodmap -
fi