minor improvements and readme
This commit is contained in:
parent
5fe135eaa3
commit
f6270f43a5
32
README.md
32
README.md
@ -1,3 +1,33 @@
|
|||||||
# kb-layout-caps-led
|
# kb-layout-caps-led
|
||||||
|
|
||||||
Switching on and off capslock led according to the keyboard layout
|
> Switching on and off capslock led according to the keyboard layout
|
||||||
|
|
||||||
|
This project is againts to show your keyboard layout switching with CapsLock LED indicator.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
There are two systemd daemons: one is running from user, the other one as root.
|
||||||
|
|
||||||
|
### User's daemon is against of to determine the current keyboard layout and tell it to root's daemon
|
||||||
|
|
||||||
|
```bash
|
||||||
|
> systemctl --user enable /%FULL_PATH_TO%/daemons/gnome-kb-layout-watcher.service
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
> systemctl --user start gnome-kb-layout-watcher.service
|
||||||
|
```
|
||||||
|
|
||||||
|
### Root's daemon is against of to set up the CapsLock LED indicator according of user's daemon data
|
||||||
|
|
||||||
|
```bash
|
||||||
|
> sudo cp /%FULL_PATH_TO/daemons/kb-layout-signal-watcher.service /etc/systemd/system/kb-layout-signal-watcher.service
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
> sudo systemctl enable kb-layout-signal-watcher.service
|
||||||
|
```
|
||||||
|
|
||||||
|
```bash
|
||||||
|
> sudo start kb-layout-signal-watcher.service
|
||||||
|
```
|
||||||
|
@ -4,15 +4,20 @@ echo $$ > /tmp/gnome-kb-layout-watcher.pid
|
|||||||
|
|
||||||
MAIN_KB_LAYOUT=$(gsettings get org.gnome.desktop.input-sources sources | sed -e 's!\[!!g; s!\]!!g; s!), (!,!g; s!(!!; s!)!!g; s! !!g;' | awk -F, '{print $2}' | sed "s/'//g")
|
MAIN_KB_LAYOUT=$(gsettings get org.gnome.desktop.input-sources sources | sed -e 's!\[!!g; s!\]!!g; s!), (!,!g; s!(!!; s!)!!g; s! !!g;' | awk -F, '{print $2}' | sed "s/'//g")
|
||||||
|
|
||||||
|
LAST_KB_LAYOUT=''
|
||||||
|
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
CURRENT_KB_LAYOUT=$(gsettings get org.gnome.desktop.input-sources mru-sources | sed -e 's!\[!!g; s!\]!!g; s!), (!,!g; s!(!!; s!)!!g; s! !!g;' | awk -F, '{print $2}' | sed "s/'//g")
|
CURRENT_KB_LAYOUT=$(gsettings get org.gnome.desktop.input-sources mru-sources | sed -e 's!\[!!g; s!\]!!g; s!), (!,!g; s!(!!; s!)!!g; s! !!g;' | awk -F, '{print $2}' | sed "s/'//g")
|
||||||
|
|
||||||
|
if ! [[ "$LAST_KB_LAYOUT" == "$CURRENT_KB_LAYOUT" ]]; then
|
||||||
if [[ "$CURRENT_KB_LAYOUT" == "$MAIN_KB_LAYOUT" ]]; then
|
if [[ "$CURRENT_KB_LAYOUT" == "$MAIN_KB_LAYOUT" ]]; then
|
||||||
echo "1" > /tmp/kb-layout
|
echo "1" > /tmp/kb-layout
|
||||||
else
|
else
|
||||||
echo "0" > /tmp/kb-layout
|
echo "0" > /tmp/kb-layout
|
||||||
fi
|
fi
|
||||||
|
LAST_KB_LAYOUT="$CURRENT_KB_LAYOUT"
|
||||||
|
fi
|
||||||
|
|
||||||
sleep .1
|
sleep .1
|
||||||
done
|
done
|
||||||
|
@ -6,21 +6,21 @@ CAPS_INPUT=$(ls /sys/class/leds/ | grep caps | head -n 1)
|
|||||||
|
|
||||||
echo $CAPS_INPUT
|
echo $CAPS_INPUT
|
||||||
|
|
||||||
PREVIOUS_KB_LAYOUT=""
|
LAST_KB_LAYOUT=""
|
||||||
|
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
CURRENT_KB_LAYOUT=$(cat /tmp/kb-layout)
|
CURRENT_KB_LAYOUT=$(cat /tmp/kb-layout)
|
||||||
|
|
||||||
if ! [[ "$PREVIOUS_KB_LAYOUT" == "$CURRENT_KB_LAYOUT" ]]; then
|
if ! [[ "$LAST_KB_LAYOUT" == "$CURRENT_KB_LAYOUT" ]]; then
|
||||||
if [[ "$CURRENT_KB_LAYOUT" == "1" ]]; then
|
if [[ "$CURRENT_KB_LAYOUT" == "1" ]]; then
|
||||||
echo 0
|
#echo 0
|
||||||
echo 0 | sudo tee "/sys/class/leds/$CAPS_INPUT/brightness"
|
echo 0 | sudo tee "/sys/class/leds/$CAPS_INPUT/brightness"
|
||||||
else
|
else
|
||||||
echo 1
|
#echo 1
|
||||||
echo 1 | sudo tee "/sys/class/leds/$CAPS_INPUT/brightness"
|
echo 1 | sudo tee "/sys/class/leds/$CAPS_INPUT/brightness"
|
||||||
fi
|
fi
|
||||||
PREVIOUS_KB_LAYOUT="$CURRENT_KB_LAYOUT"
|
LAST_KB_LAYOUT="$CURRENT_KB_LAYOUT"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep .1
|
sleep .1
|
||||||
|
Loading…
Reference in New Issue
Block a user