You are not logged in.
Hi, all
I was trying to create a small script to send a notification if the Caps Lock is active or not. The script works correctly in the terminal, but when I use the script as a shortcut in KDE it does not work ... I simply trigger the shortcut with the "Caps Lock".
Below is the script that I created:
#!/bin/bash
#
# Send a notification of CAPS LOCK on/off
# Icon used in the notification
icon="/usr/share/icons/NITRUX/devices/48/keyboard.svg"
# verify if the CAPS is on/off
value=$(xset q | grep "LED mask" | sed -r "s/.*LED mask:\s+[0-9a-fA-F]+([0-9a-fA-F]).*/\1/")
if [ "$value" == "0" ]; then
output="Off"
else
output="On"
fi
# Send notification (use Gnome or KDE)
# GNOME
#notify-send -i $icon "Caps Lock $output" -t 1000
#KDE
kdialog --icon $icon --passivepopup "Caps Lock $output" --title "Keyboard" 1Could someone help me pointing what I'm doing wrong?
Thanks in advance!
EDIT: If I do not use the "caps lock" as a trigger, the script works as it should (I tried using "ctrl + alt + L") ...
Last edited by gustavosg (2012-11-13 00:06:46)
Offline
Is caps lock set to do something in KDE settings? I don't know but usually KDE won't let you use a shortcut which is assigned to do something else. I'm not sure whether you can use a single key as a shortcut but, if you can, wouldn't you have to dedicate that key to just doing that? Not sure about this...
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
I have no problem setting shortcuts for scripts with kde. Are you using systemsettings to stablish the shortcut?
Offline
I'm not sure whether you can use a single key as a shortcut
yes, you can.
Offline
I have no problem setting shortcuts for scripts with kde. Are you using systemsettings to stablish the shortcut?
Hi, all.
Sorry, I think I expressed myself badly.
When I use my scrip "caps.sh" as a shortcut and use the "caps lock" key as a trigger, whenever I press the caps lock key the shortcut works and the script runs, but the information he gives me is wrong (it always says the caps is on). When I use a different trigger key, for example "ctrl + shift + L", everything works like a charm...
I hope I have made my issue clearer.
Also, sorry for my bad english.
Thanks for all the replies.
Last edited by gustavosg (2012-11-12 19:05:42)
Offline
try sending the dialog with a delay in background
Offline
SysSettings->Input edvices->Keyboard, Advanced tab, under 'Caps lock behaviour', disable usage of caps lock.
I think the problem is that both kde and your script manage the same thing, so when you press Caps, two things happen, and they collide.
Offline
try sending the dialog with a delay in background
Hi! Thanks for replying. I've tried the sleep command, still saying that caps is always on (if it is what you mean).
SysSettings->Input edvices->Keyboard, Advanced tab, under 'Caps lock behaviour', disable usage of caps lock.
I think the problem is that both kde and your script manage the same thing, so when you press Caps, two things happen, and they collide.
If I disable the caps, the shortcut don't trigger. And what my script does is just check the caps "statuts". But thanks for the reply, I didn't noticed that function. Now i'm using "shift disables caps" ![]()
Last edited by gustavosg (2012-11-12 21:16:52)
Offline
Pajaro wrote:try sending the dialog with a delay in background
Hi! Thanks for replying. I've tried the sleep command, still saying that caps is always on (if it is what you mean).
What I meant is to do something like:
$(sleep .5; echo kdialog --icon $icone --passivepopup "Caps Lock $saida" --title "Teclado" 1) &Offline
Maybe you could post the script if you are still having trouble?
Thanks for the info about single key short cuts. I guess it has never occurred to me. (Maybe because on a laptop you can't usually spare a whole key for a single short cut!)
CLI Paste | How To Ask Questions
Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L
Offline
gustavosg wrote:Pajaro wrote:try sending the dialog with a delay in background
Hi! Thanks for replying. I've tried the sleep command, still saying that caps is always on (if it is what you mean).
What I meant is to do something like:
$(sleep .5; echo kdialog --icon $icone --passivepopup "Caps Lock $saida" --title "Teclado" 1) &
When I use it on the script it just printi "Caps" on the notification, as if it was reading just the first word of the "Caps Lock $saida".
Edited the script to this:
#!/bin/bash
#
# Manda aviso de CAPS LOCK on/off
# icone pra usar na notificacao
icone="/usr/share/icons/NITRUX/devices/48/keyboard.svg"
# verifica se o Caps esta ligado
valor=$(xset q | grep "LED mask" | sed -r "s/.*LED mask:\s+[0-9a-fA-F]+([0-9a-fA-F]).*/\1/")
if [ "$valor" == "0" ]; then
$(sleep .5; echo kdialog --icon $icone --passivepopup "Caps Lock Off" --title "Teclado" 1) &
else
$(sleep .5; echo kdialog --icon $icone --passivepopup "Caps Lock On" --title "Teclado" 1) &
fi
# Dispara alerta (usar Gnome ou KDE)
# GNOME
#notify-send -i $icone "Caps Lock $saida" -t 1000
#KDE
#$(sleep .5; echo kdialog --icon $icone --passivepopup "Caps Lock $saida" --title "Teclado" 1) &Maybe you could post the script if you are still having trouble?
Thanks for the info about single key short cuts. I guess it has never occurred to me. (Maybe because on a laptop you can't usually spare a whole key for a single short cut!)
The script is the one in the OP. I'm using a laptop.
EDIT:
Updated OP script to english...
Last edited by gustavosg (2012-11-13 00:07:38)
Offline
Well, you can try to just put $saida as --passivepopup argument to at least see if it is working.
Another way to achieve the same is this. I didn't test it, fix it if you need to.
function delayed() {
sleep .5
kdialog --icon "$1" --passivepopup "Caps Lock $2" 0 --title "Teclado"
}
delayed $icon $saida &Last edited by Pajaro (2012-11-13 11:43:36)
Offline
Well, you can try to just put $saida as --passivepopup argument to at least see if it is working.
Another way to achieve the same is this. I didn't test it, fix it if you need to.
function delayed() { sleep .5 kdialog --icon "$1" --passivepopup "Caps Lock $2" 0 --title "Teclado" } delayed $icon $saida &
Hi! Just tested... Didn't work. Still just saying Caps is ON.
Thanks for the reply.
Offline