Skip to content

Commit 2776a0e

Browse files
committed
Add g810-led-numlock-color.service to reflect numlock state
At least the G513 does not have a numlock indicator, but I'd like to see the state.
1 parent efa3c35 commit 2776a0e

2 files changed

Lines changed: 28 additions & 1 deletion

File tree

makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ setup:
7171
@cp udev/$(PROGN).rules $(DESTDIR)/etc/udev/rules.d
7272
@test -s /usr/bin/systemd-run && \
7373
install -m 755 -d $(DESTDIR)$(SYSTEMDDIR)/system && \
74-
cp systemd/$(PROGN)-reboot.service $(DESTDIR)$(SYSTEMDDIR)/system
74+
cp systemd/$(PROGN)-reboot.service $(DESTDIR)$(SYSTEMDDIR)/system && \
75+
cp systemd/$(PROGN)-numlock-color.service $(DESTDIR)$(SYSTEMDDIR)/system
7576

7677
install-lib: lib
7778
@install -m 755 -d $(libdir)
@@ -103,6 +104,7 @@ uninstall:
103104
@test -s /usr/bin/systemd-run && \
104105
systemctl disable $(PROGN)-reboot && \
105106
rm $(SYSTEMDDIR)/system/$(PROGN)-reboot.service && \
107+
rm $(SYSTEMDDIR)/system/$(PROGN)-numlock-color.service && \
106108
systemctl daemon-reload && \
107109
rm -R /etc/$(PROGN)
108110

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[Unit]
2+
Description=Update RGB for Num-Lock state
3+
4+
[Service]
5+
Restart=always
6+
Environment=NUM_ON_COLOR=FF0000
7+
Environment=NUM_OFF_COLOR=00FFFF
8+
9+
ExecStart=/bin/bash -c '\
10+
LAST_STATE=""; \
11+
while true; do \
12+
STATE=$(cat /sys/class/leds/*::numlock/brightness | head -n1 ) ; \
13+
if [ "$STATE" != "$LAST_STATE" ]; then \
14+
if [ "$STATE" -eq 1 ]; then \
15+
g810-led -k numlock "$NUM_ON_COLOR" ; \
16+
else \
17+
g810-led -k numlock "$NUM_OFF_COLOR" ; \
18+
fi; \
19+
LAST_STATE="$STATE"; \
20+
fi; \
21+
sleep 0.2; \
22+
done;'
23+
24+
[Install]
25+
WantedBy=multi-user.target

0 commit comments

Comments
 (0)