Page 3 of 4

Re: Is there any way to show a notification when Caps Lock is pressed?

Posted: Sun Nov 12, 2023 2:24 pm
by siamhie
Jerry3904 wrote: Sun Nov 12, 2023 11:08 am
Fluxbox would need to be completely rebuilt from scratch
:rofl:
I second that emoji @Jerry3904 :rofl: :rofl:

Re: Is there any way to show a notification when Caps Lock is pressed?

Posted: Sun Nov 12, 2023 2:38 pm
by Jerry3904
Did you get a working line using that key_caps_lock?

Re: Is there any way to show a notification when Caps Lock is pressed?

Posted: Sun Nov 12, 2023 2:52 pm
by ceeslans
fehlix wrote: Sun Nov 12, 2023 1:31 pm In addtion to the xfce-builtin Caps-Lock indicator on the panel as mentioned in #12,
one could also bind a "send notification" action to the Caps_Lock key itself:
E.g. To bind the send-notification event in Xfce on command line with this one-liner:

Code: Select all

xfconf-query -c xfce4-keyboard-shortcuts -p /commands/custom/Caps_Lock -n -t string -s 'sh -c '\''sleep 0.2; notify-send -t 5000  -i caps-lock "Caps Lock" $(xset -q | grep -oP "Caps Lock:\s*\K(off|on)")'\'''

or alternatively within Keyboard-Settings add new applications shortcut,
with the command:

Code: Select all

sh -c 'sleep 0.2; notify-send -t 5000  -i caps-lock "Caps Lock" $(xset -q | grep -oP "Caps Lock:\s*\K(off|on)")'
and press Caps_Lock for the key to bind.
This gives a nice notification on the desktop when the Caps Lock key is pressed:
Caps Lock on
caps-on-notification.jpg
Caps Lock off
caps-off-notification.jpg
This surely is way more sophisticated code than my feable attempt to script a notification message every time the CapsLock key (and similar script for NumLock key) is pressed - when running Fluxbox...
My script does show individual icons for 'on' and 'off' state :

caps_lock.sh

Code: Select all

#!/bin/bash

value=$(xset q | grep "Caps Lock:" | awk '{print $4}' | grep -c on)

if [ "$value" -eq "1" ]; 
then
   notify-send -t 2500 -i  "capslock-on" "Caps Lock is ON" &
else
   notify-send -t 2500 -i  "capslock-off" "Caps Lock is OFF"
fi
num_lock.sh

Code: Select all

#!/bin/bash

value=$(xset q | grep "Num Lock:" | awk '{print $8}' | grep -c on)

if [ "$value" -eq "1" ]; 
then
   notify-send -t 2500 -i  "numlock-on" "Num Lock is ON" &
else
   notify-send -t 2500 -i  "numlock-off" "Num Lock is OFF"
fi
keybindings in ~/fluxbox/keys:

Code: Select all

Caps_Lock	:Exec sleep 0.3 && caps_lock.sh
Num_Lock	:Exec sleep 0.3 && num_lock.sh

Re: Is there any way to show a notification when Caps Lock is pressed?

Posted: Sun Nov 12, 2023 4:41 pm
by oops
... Or a simple script into the terminal (in "real time")

Code: Select all

#!/bin/bash
for (( ; ; ))
do
echo -n $(xset -q | grep Caps)
echo " … (Crtl + c to quit)"
sleep 0.5
clear
done

Re: Is there any way to show a notification when Caps Lock is pressed?

Posted: Sun Nov 12, 2023 8:11 pm
by i_ri
Hello MXRobo the wayland script shows notification of Caps Lock On.

Re: Is there any way to show a notification when Caps Lock is pressed?

Posted: Sun Nov 12, 2023 10:30 pm
by MXRobo
@i_ri Great, personally, I'd change the textual notification output, and I do NOT know this stuff, I'm just throwing what seems reasonably relevant at the fan.
I didn't try it because I can not even write a script or know where to keep it!

And fehlix's second one, keybind is the idea and what I tried last night, horrible attempt - and it should have responded, "cannot complete childlike command".

I have a caps lock light in the keyboard so I don't really need it, but I still like fehlix's very much, only if I had my druthers, I'd like it better if the notification for on was larger than the notification for being off – or only notified for on.
Hey Jerk! Caps ON!

This would be nice for the insert key too.

Nice, and nice toy!

Re: Is there any way to show a notification when Caps Lock is pressed?

Posted: Mon Nov 13, 2023 1:46 am
by i_ri
"(MX-Cees) conky
by Jerry3904 » Sun Nov 12, 2023 3:38 pm
Did you get a working line using that key_caps_lock?" Yes. It prints On or prints Off.

Re: Is there any way to show a notification when Caps Lock is pressed?

Posted: Tue Nov 14, 2023 6:04 am
by Jerry3904
Thanks.

I'm trying to have it show only when caps lock is on. Thought this would work but it doesn't, so would be interested in and grateful for any suggestions

Code: Select all

${alignc}${if_match "${key_caps_lock} == 1"}${color5} Caps Lock: ${key_caps_lock} ${endif}

Re: Is there any way to show a notification when Caps Lock is pressed?

Posted: Tue Nov 14, 2023 6:21 am
by fehlix
:

Code: Select all

${alignc}${if_match "${key_caps_lock}" == "On"}${color5} Caps Lock: ${key_caps_lock} ${endif}

Re: Is there any way to show a notification when Caps Lock is pressed?

Posted: Tue Nov 14, 2023 6:40 am
by Jerry3904
Perfect, thanks. I had been using "On" and only switched to "1" in trying to fix it; but I never had the extra quote marks.