@@ -9,18 +9,19 @@ if [ "$1" == "check" ]; then
99 else
1010 echo " false"
1111 fi
12- # elif [[ "$XDG_CURRENT_DESKTOP" == *"GNOME"* ]];then
13- # if [[ "$someTest" == "true" ]];then
14- # echo "true"
15- # else
16- # echo "false"
17- # fi
18- # elif [[ "$XDG_CURRENT_DESKTOP" == *"XFCE"* ]];then
19- # if [[ "$someTest" == "true" ]];then
20- # echo "true"
21- # else
22- # echo "false"
23- # fi
12+ elif [[ " $XDG_CURRENT_DESKTOP " == * " GNOME" * ]]; then
13+ numlock_state=$( gsettings get org.gnome.desktop.peripherals.keyboard numlock-state 2> /dev/null)
14+ if [[ " $numlock_state " == " true" ]]; then
15+ echo " true"
16+ else
17+ echo " false"
18+ fi
19+ elif [[ " $XDG_CURRENT_DESKTOP " == * " XFCE" * ]]; then
20+ if [ -f " $HOME /.config/autostart/numlockx.desktop" ] && ! grep -q " Hidden=true" " $HOME /.config/autostart/numlockx.desktop" 2> /dev/null; then
21+ echo " true"
22+ else
23+ echo " false"
24+ fi
2425 elif [[ " $XDG_CURRENT_DESKTOP " == * " Cinnamon" * ]] || [[ " $XDG_CURRENT_DESKTOP " == * " X-Cinnamon" * ]]; then
2526 recent_status=$( gsettings get org.cinnamon.desktop.peripherals.keyboard numlock-state)
2627 if [[ " $recent_status " == " true" ]]; then
@@ -36,31 +37,44 @@ if [ "$1" == "check" ]; then
3637elif [ " $1 " == " toggle" ]; then
3738 if [[ " $XDG_CURRENT_DESKTOP " == * " KDE" * ]] || [[ " $XDG_CURRENT_DESKTOP " == * " Plasma" * ]]; then
3839 if [ " $2 " == " true" ]; then
39- pkexec kwriteconfig6 --group " General" --key " Numlock" --file " /etc/sddm.conf" " on"
40- kwriteconfig6 --group " Keyboard" --key " NumLock" --file " $HOME /.config/kcminputrc" " 0"
40+ pkexec kwriteconfig6 --group " General" --key " Numlock" --file " /etc/sddm.conf" " on"
41+ kwriteconfig6 --group " Keyboard" --key " NumLock" --file " $HOME /.config/kcminputrc" " 0"
42+ else
43+ pkexec kwriteconfig6 --group " General" --key " Numlock" --file " /etc/sddm.conf" " off"
44+ kwriteconfig6 --group " Keyboard" --key " NumLock" --file " $HOME /.config/kcminputrc" " 1"
45+ fi
46+ elif [[ " $XDG_CURRENT_DESKTOP " == * " GNOME" * ]]; then
47+ if [[ " $2 " == " true" ]]; then
48+ gsettings set org.gnome.desktop.peripherals.keyboard remember-numlock-state true 2> /dev/null
49+ gsettings set org.gnome.desktop.peripherals.keyboard numlock-state true 2> /dev/null
50+ numlockx on 2> /dev/null
51+ else
52+ gsettings set org.gnome.desktop.peripherals.keyboard numlock-state false 2> /dev/null
53+ numlockx off 2> /dev/null
54+ fi
55+ elif [[ " $XDG_CURRENT_DESKTOP " == * " XFCE" * ]]; then
56+ if [[ " $2 " == " true" ]]; then
57+ mkdir -p " $HOME /.config/autostart"
58+ cat > " $HOME /.config/autostart/numlockx.desktop" << 'EOF '
59+ [Desktop Entry]
60+ Type=Application
61+ Name=NumLock On
62+ Exec=numlockx on
63+ NoDisplay=true
64+ X-XFCE-Autostart-Override=true
65+ EOF
66+ numlockx on 2> /dev/null
4167 else
42- pkexec kwriteconfig6 --group " General " --key " Numlock " --file " /etc/sddm.conf " " off "
43- kwriteconfig6 --group " Keyboard " --key " NumLock " --file " $HOME /.config/kcminputrc " " 1 "
68+ rm -f " $HOME /.config/autostart/numlockx.desktop "
69+ numlockx off 2> /dev/null
4470 fi
45- # elif [[ "$XDG_CURRENT_DESKTOP" == *"GNOME"* ]];then
46- # if [[ "$2" == "true" ]];then
47- # some command
48- # else
49- # some command
50- # fi
51- # elif [[ "$XDG_CURRENT_DESKTOP" == *"XFCE"* ]];then
52- # if [[ "$2" == "true" ]];then
53- # some command
54- # else
55- # some command
56- # fi
5771 elif [[ " $XDG_CURRENT_DESKTOP " == * " Cinnamon" * ]] || [[ " $XDG_CURRENT_DESKTOP " == * " X-Cinnamon" * ]]; then
5872 if [[ " $2 " == " true" ]]; then
59- gsettings set org.cinnamon.desktop.peripherals.keyboard numlock-state true
60- numlockx on
73+ gsettings set org.cinnamon.desktop.peripherals.keyboard numlock-state true
74+ numlockx on
6175 else
62- gsettings set org.cinnamon.desktop.peripherals.keyboard numlock-state false
63- numlockx off
76+ gsettings set org.cinnamon.desktop.peripherals.keyboard numlock-state false
77+ numlockx off
6478 fi
6579 fi
6680 exit $?
0 commit comments