How to show 'Caps Lock' on screen? (Solved)

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

How to show 'Caps Lock' on screen? (Solved)

#1 Post by Mike Walsh »

Evening, kiddiwinks.

Got a wee poser for you.

I want to try doing something just for kicks. I want to set things up so that when I hit my 'Caps Lock' key, not only does the keyboard indicator light come on, but I get the words 'Caps Lock' come up on the screen in big letters.

A second press of the key will then make the words disappear again.

I think I can use the key-bindings section at the bottom of /etc/xdg/templates/_root_.jwmrc to set up a trigger for this.....but how would you actually script this? One press makes something appear, then a second press causes it to disappear again. Appear...disappear...appear...disappear...appear...disappear (you get the picture). I'm guessing it's time for me to learn a bit more Bash.

Any ideas, please? Any & all suggestions/advice much appreciated, as always.


Mike. :wink:
Last edited by Mike Walsh on Wed 13 Mar 2019, 03:16, edited 1 time in total.
User avatar
trapster
Posts: 2117
Joined: Mon 28 Nov 2005, 23:14
Location: Maine, USA
Contact:

#2 Post by trapster »

This is what I use in a script on my desktop to start and stop an application by clicking on it. (yad used an an example)

Code: Select all

#!/bin/sh

pidof yad && killall yad  || yad --form --field="Test"
trapster
Maine, USA

Asus eeepc 1005HA PU1X-BK
Frugal install: Slacko
Currently using full install: DebianDog
User avatar
Keef
Posts: 987
Joined: Thu 20 Dec 2007, 22:12
Location: Staffordshire

#3 Post by Keef »

A bit crude, and not exactly what you wanted (you have to close the dialog box yourself), but it's a start. Run the script then press the caps-lock.

Code: Select all

#!/bin/sh
# dialog box won't go away until caps is off and you press OK
# This will run forever unless you hit Ctrl+C

while : ; do
     
    state=$(xset -q | grep LED | cut -f 4 -d ":")
      
    if [ $state = "00000001" ] ; then

       gxmessage -ontop -center "CAPS-LOCK ON"
       
    fi

done
(I wouldn't recommend actually using this, it is just an example).
User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#4 Post by MochiMoppel »

I use a CapsLock warning and I changed it to meet your requirements. Pressing CapsLock key puts up a red warning, pressing again kills it.

To make it really easy I use a desktop icon, but you can use other ways for the key binding. To make it clear: The icon is not meant to be pushed, so you may want to replace the 48x48px icon with a 1px icon and "hide" it somewhere on the desktop where it doesn't hurt. It's main function is to provide a keyboard shortcut for the included code.

- create a desktop icon
- change/add input fields according to screenshot
- add a keyboard shortcut (MUST of course be the CapsLock)

The code in the arguments field:

Code: Select all

-c "sleep .1;[[ $(xset -q) =~ (Caps Lock: *off) ]] && busybox pkill MySwitch  || exec -a MySwitch gxmessage -bo  -c -fn 'bold 18' -bg red -fg white -nof -bu '' $'\n  CapsLock' "  
Works for me.
[EDIT 2019-3-14] Changed 'pkill' to 'busybox pkill' because of faulty pkill symlinks in some Puppies
Attachments
cAPSLOCK.png
(25.32 KiB) Downloaded 240 times
Last edited by MochiMoppel on Thu 14 Mar 2019, 01:59, edited 3 times in total.
User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#5 Post by Mike Walsh »

Hallo, you two.

Thanks for the demos. After some hunting around on t'web, I've found something in the PPM of the 'buntu-based Pups that'll do the job.

It's called indicator-keylock. It doesn't put text on the screen, but what it does do is to place a visible indicator in the notification area, over to the right. Like so:-


Image


In fact, you get one for each of the 3 'lock' keys. You get an 'A' for CapsLock; you get a '1' for NumLock, and you get a '↓' for ScrollLock.

You can get this as a .deb package, but there's a few necessary deps (I've just knocked up a package for Precise 571 from the .deb in the age-related Ubuntu 'old-releases' archive).....mainly libdbusmenu-glib & libdbusmenu-gtk3. Also libindicator, libappindicator, and libunique, but we're looking at less than 300kb of deps, so it's not exactly hurting the save-file.

If anybody's interested, I'm attaching the .pet below. Only for Precise 571, mind, and although I've included those deps mentioned above, I can't guarantee it'll necessarily work for anyone else. My 571 has had so much extra stuff added over the last 3 years or so, god only knows what I've got kicking around in /lib & /usr/lib by this time..!

The binary's sym-linked into /root/Startup, so it'll run every time you fire Puppy up.

I'll mark this as 'Solved'. Thanks for the pointers anyway, guys; they got me searching around on a rather different tack to what I started out with; I got the link for this from StackOverflow, of all places.

---------------------------------------

@ Mochi:-

Sorry, mate; our posts crossed, I think. I posted at the same time as you, or shortly afterwards while I was editing...

I'm going to hang onto your script there, 'cos I've got an idea in mind for something else that I think I can modify it for. It certainly won't go to waste. Cheers!

(I came across 'xset q' during my research, so I see where you're going with that. I was initially thinking along the same lines myself.....using 'grep' to 'cut-out' the bit I needed, though how to implement the on/off part was where I'd got stuck.)


Mike. :wink:
User avatar
ETP
Posts: 1193
Joined: Tue 19 Oct 2010, 19:55
Location: UK

#6 Post by ETP »

Hi Mike,

Two more alternative pets (64-bit & 32-bit) which I have been using in every Pup since 2017. :D

http://www.murga-linux.com/puppy/viewto ... 512#963460

http://www.murga-linux.com/puppy/viewto ... 512#963428
Regards ETP
[url=http://tinyurl.com/pxzq8o9][img]https://s17.postimg.cc/tl19y14y7/You_Tube_signature80px.png[/img][/url]
[url=http://tinyurl.com/kennels2/]Kennels[/url]
User avatar
Mike Walsh
Posts: 6351
Joined: Sat 28 Jun 2014, 12:42
Location: King's Lynn, UK.

#7 Post by Mike Walsh »

@ ETP:-

Mornin', mate. Hey, thanks for those. I've installed it in Slacko 560 for now; running nicely.

I'll trial all these. The one I found in a couple of Pups; Mochi's in another couple, and this one of SFR's in yet two more. Give 'em a few weeks.....see which one I like the best.

I've got the same problem you mentioned, anyway. Following the (ahem!) 'coffee' incident with the old Dell's keyboard a couple of years ago, I now use a cheap'n'cheerful wireless one from PCWorld. Works great.....but NO indicator lights! (*grrrr*) :roll:

(For my use-case - with a dark grey title bar - and the state of my eyes ( :lol: ), black text on a white background seems to work best for me.....)


Image


Let's see how I get on with 'em, shall we? Thanks again.

-----------------------------

@ Flash:-

Thanks for modifying the thread title. That's much clearer.....dunno what I was thinking last night. Cheers.


Mike. :wink:
User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#8 Post by fabrice_035 »

Hello,
Just for info:
The MochiMoppel code (and idea) is very interessting but it's buggy sometimes. Gxmessage active remain, sometimes when I change the active window, or not, strange behavior :roll:
Regard
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752
User avatar
pp4mnklinux
Posts: 375
Joined: Fri 23 Aug 2013, 06:56

http://www.murga-linux.com/puppy/viewtopic.php?t=115651

#9 Post by pp4mnklinux »

Last edited by pp4mnklinux on Thu 14 Mar 2019, 06:30, edited 2 times in total.
Distro: xenialpup64 7.5 XXL
Desktop Panel: JWM ~ FbBox 5.0
User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#10 Post by MochiMoppel »

fabrice_035 wrote:The MochiMoppel code (and idea) is very interessting but it's buggy sometimes. Gxmessage active remain, sometimes when I change the active window, or not, strange behavior
I can't replicate your strange behavior. Try to increase the sleep time.
gxmessage relies on the results of xset, and xset must run only after the system has noticed the new key status. Normally 0.1sec should be enough but maybe some systems need more.

.
Last edited by MochiMoppel on Wed 20 Mar 2019, 12:10, edited 1 time in total.
User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#11 Post by Flash »

http://www.murga-linux.com/puppy/viewtopic.php?t=114189
pp4mnklinux had a similar problem back in August.
User avatar
fabrice_035
Posts: 765
Joined: Mon 28 Apr 2014, 17:54
Location: Bretagne / France

#12 Post by fabrice_035 »

MochiMoppel wrote: Normally 0.1sec should be enough but maybe some systems need more.
Right, 0.7s it's good
Bionicpup64-8.0 _ Kernel 5.4.27-64oz _ Asus Rog GL752
Post Reply