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

Help for Current Versions of MX
When asking for help, use Quick System Info from MX Tools. It will be properly formatted using the following steps.
1. Click on Quick System Info in MX Tools
2. Right click in your post and paste.
Message
Author
User avatar
siamhie
Global Moderator
Posts: 3402
Joined: Fri Aug 20, 2021 5:45 pm

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

#21 Post 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:
This is my Fluxbox . There are many others like it, but this one is mine. My Fluxbox is my best friend. It is my life.
I must master it as I must master my life. Without me, my Fluxbox is useless. Without my Fluxbox, I am useless.

User avatar
Jerry3904
Administrator
Posts: 23236
Joined: Wed Jul 19, 2006 6:13 am

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

#22 Post by Jerry3904 »

Did you get a working line using that key_caps_lock?
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
ceeslans
Posts: 831
Joined: Sun Apr 14, 2019 3:48 am

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

#23 Post 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
You do not have the required permissions to view the files attached to this post.
Sony Vaio VPCF23P (2011), Intel Core i7-2670, 6gb RAM, 240gb SSD, MX-Linux 23 based Fluxbox v/1.3.7+
Lenovo Thinkpad L560 (2016), Intel Core i5-6200, 16gb RAM, 240gb SSD, Devuan Daedalus based Fluxbox v/1.3.7+

User avatar
oops
Posts: 1920
Joined: Tue Apr 10, 2018 5:07 pm

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

#24 Post 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
Pour les nouveaux utilisateurs: Alt+F1 pour le manuel, ou FAQS, MX MANUEL, et Conseils Debian - Info. système “quick-system-info-mx” (QSI) ... Ici: System: MX-19_x64 & antiX19_x32

User avatar
i_ri
Posts: 1105
Joined: Tue Jun 30, 2015 12:26 am

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

#25 Post by i_ri »

Hello MXRobo the wayland script shows notification of Caps Lock On.
You do not have the required permissions to view the files attached to this post.

MXRobo
Posts: 1834
Joined: Thu Nov 14, 2019 12:09 pm

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

#26 Post 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!

User avatar
i_ri
Posts: 1105
Joined: Tue Jun 30, 2015 12:26 am

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

#27 Post 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.
You do not have the required permissions to view the files attached to this post.

User avatar
Jerry3904
Administrator
Posts: 23236
Joined: Wed Jul 19, 2006 6:13 am

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

#28 Post 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}
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

User avatar
fehlix
Developer
Posts: 12723
Joined: Wed Apr 11, 2018 5:09 pm

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

#29 Post by fehlix »

:

Code: Select all

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

User avatar
Jerry3904
Administrator
Posts: 23236
Joined: Wed Jul 19, 2006 6:13 am

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

#30 Post 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.
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin

Post Reply

Return to “MX Help”