-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoggle-lang.sh
executable file
·42 lines (36 loc) · 1.23 KB
/
toggle-lang.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
#!/usr/bin/env bash
# variables --------------------------------------------------------------------
scripts_dir="$HOME/.local/bin"
# functions - x11 --------------------------------------------------------------
function toggle_x11 () {
case $("$scripts_dir/get-lang.sh") in
'us') new_lang='ru' ;;
'ru') new_lang='jp' ;;
'jp') new_lang='us' ;;
*) new_lang='us' ;;
esac
"$scripts_dir/set-lang.sh $new_lang"
case $new_lang in
'jp') fcitx5-remote -o ;; # enable japanese
*) fcitx5-remote -c ;; # disable japanese
esac
}
# functions - wayland ----------------------------------------------------------
function toggle_wayland () {
case $XDG_CURRENT_DESKTOP in
'Hyprland') toggle_hyprland ;;
esac
}
function toggle_hyprland () {
keyboard_device="massdrop-inc.-ctrl-keyboard"
hyprctl switchxkblayout "$keyboard_device" next
case $("$scripts_dir/get-lang.sh") in
'Japanese') fcitx5-remote -o ;; # enable japanese
*) fcitx5-remote -c ;; # disable japanese
esac
}
# execution ====================================================================
case $XDG_SESSION_TYPE in
x11) toggle_x11 ;;
wayland) toggle_wayland ;;
esac