The time now is Sun 17 Jan 2021, 09:35
All times are UTC - 4 |
Page 1 of 2 [18 Posts] |
Goto page: 1, 2 Next |
Author |
Message |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Fri 09 Jun 2017, 14:28 Post subject:
LockState v1.1 Subject description: CapsLock, NumLock, ScrollLock tray indicator app. |
|
This utility monitors the state of CapsLock, NumLock and ScrollLock* keys and shows status icons in system tray.
Right-clicking any icon displays a popup menu, where you can show/hide selected indicator or quit the app.
Just note that if you have only one icon enabled, it cannot be hidden.
The attached archive contains source code, two PETs (for 32bit and 64bit systems) and TXZ package for Fatdog - all built in FD, too.
Briefly tested in Slacko-5.7 and Tahr64-6.0.5, but may not work on other/older ones.
Written in C/GTK+-2.0 on Fatdog64-710.
Since I'm completely hopeless at drawing, I had to borrow status icons from somewhere - in this case LXPanel project.
EDIT: as of version 0.2, LockState uses status icons created by vovchik.
___________
* ScrollLock: in Puppyland this key is usually inactive. So, if xmodmap -pm shows:
Code: | [...]
mod1 Alt_L (0x40), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
[...] |
and you want to be able to monitor ScrollLock's state, just do this:
Code: | xmodmap -e 'add mod3 = Scroll_Lock' |
and you should get that:
Code: | [...]
mod1 Alt_L (0x40), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3 Scroll_Lock (0x4e)
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
[...] |
___________
Changelog:
Version 1.1:
- removed the micro-delay between displaying icons - it's no longer necessary with newer LxQt-Panel in Fatdog
- fixed quitting the app when Preferences window is open
- changed program icon
Version 1.0:
- left-clicking an icon toggles the state of the corresponding key
- the last (hopefully) memory leak has been fixed
- minor rearrangements in the code
Version 0.5:
- added option to draw icons in reversed order (Scroll->Num->Caps), because some panels (JWM's, FBPanel...) draw tray icons from right to left
- added 'Redraw icons' option
- fixed some minor memory leaks
- fixed segfault with glib < 2.36
- small bugfix in sanity checks
- code improvements
Version 0.4:
- added Preferences dialog for colors & symbols customization
- some internal rearrangements/improvements
Version 0.3:
- improvement: no need for temp files anymore, all done internally via rsvg & pixbufs
Version 0.2:
- new status icons (thanks to vovchik)
- icons are embedded in the code (thanks to vovchik)
Version 0.1:
- initial release
Enjoy &
Greetings!
 |
Description |
MD5: f1331bb662ab2a06f715207d4fdae540 LockState-1.1.tar.gz
|

Download |
Filename |
LockState-1.1.tar.gz |
Filesize |
69.91 KB |
Downloaded |
387 Time(s) |
Description |
MD5: 598a0a9d955f89a6f0113edd14b64bcd LockState-1.0.tar.gz
|

Download |
Filename |
LockState-1.0.tar.gz |
Filesize |
55.49 KB |
Downloaded |
592 Time(s) |
Description |
MD5: 30c970f380aa93f74a779e9a0eb01c12 LockState-0.1.tar.gz
|

Download |
Filename |
LockState-0.1.tar.gz |
Filesize |
93.2 KB |
Downloaded |
539 Time(s) |
Description |
|
Filesize |
10.93 KB |
Viewed |
1256 Time(s) |

|
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Last edited by SFR on Fri 26 Apr 2019, 08:07; edited 9 times in total
|
Back to top
|
|
 |
musher0
Joined: 04 Jan 2009 Posts: 15041 Location: Gatineau (Qc), Canada
|
Posted: Fri 09 Jun 2017, 15:58 Post subject:
|
|
Thanks, SFR.
Certainly useful for small WM's like aewm or echinus.
BFN.
_________________ musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)
|
Back to top
|
|
 |
slavvo67
Joined: 12 Oct 2012 Posts: 1625 Location: The other Mr. 305
|
Posted: Sat 10 Jun 2017, 13:49 Post subject:
|
|
I would have never thought of something so simple, yet useful.
Thanks SFR!
Slavvo67
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1538 Location: Ukraine
|
Posted: Sat 10 Jun 2017, 18:57 Post subject:
|
|
Dear SFR,
Very nice and terse -- and useful. Thanks.
I had to change the makefile to:
Code: | $(CC) lockstate.c -o lockstate $(FLAGS) |
to get it to compile because of newer and more fussy gcc.
With kind regards,
vovchik
PS. If you use inline svgs (or even inline pngs as header files), you could make this thing entirely self-contained. It would still be tiny, I think. I have attached some sample svgs that could be used as icons. They could be done in "inline" and written out to /tmp and read from there.
UPDATE: I modded your code slightly to include the inline svgs, which get written to /tmp and read from there. Seems to be working fine. The 6 svg strings could actually reduced to one, with some replacing (one #xxxx xx color for on/off and the char show for the key in <text></text>).
Description |
|

Download |
Filename |
lockstate-vov.c.tar.gz |
Filesize |
3.54 KB |
Downloaded |
525 Time(s) |
Description |
|

Download |
Filename |
key-svg.tar.gz |
Filesize |
685 Bytes |
Downloaded |
604 Time(s) |
|
Back to top
|
|
 |
zigbert

Joined: 29 Mar 2006 Posts: 6629 Location: Valåmoen, Norway
|
Posted: Sun 11 Jun 2017, 05:24 Post subject:
|
|
Very nice
_________________ Stardust resources
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1538 Location: Ukraine
|
Posted: Sun 11 Jun 2017, 10:08 Post subject:
|
|
Dear SFR,
I did some code golfing and reduced the six svg inline strings to one and then implemented a search and replace routine to ready the svgs for export to /tmp. I think it's more tidy and efficient that way if using inline svgs. And, any old stock gtk icon could conceivably go into the desktop file, perhaps, obviating a need to put anything in /usr/share/pixmaps (only the desktop file itself in /usr/share/applications). What do you think
I have , in addition to the modded source, also included a 32-bit Tahr binary.
With kind regards,
vovchik
Description |
|

Download |
Filename |
lockstate-mod.c.tar.gz |
Filesize |
11.49 KB |
Downloaded |
510 Time(s) |
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Sun 11 Jun 2017, 11:46 Post subject:
|
|
Thanks guys!
@Vovchik: yeah, I was hoping someone would provide "our own" icons. Many thanks for that!
The only changes I've made was to darken the inactive color from #bbbbbb to #888888, to get better contrast, and replaced the character for inactive state of ScrollLock from ↓ to ⇣.
It really looks nicer with your icons.
As for the code, since it's using GTK+ and friends anyway, I'm trying to limit myself to g_ stuff as much as possible, so I replaced what I could.
Makefile fixed as well.
vovchik wrote: | I did some code golfing and reduced the six svg inline strings to one and then implemented a search and replace routine to ready the svgs for export to /tmp. |
Thanks for the code, but I've already done it, not using any search/replace mechanisms, though.
Well, that was my first though, but I couldn't find an appropriate func in GLib, so just went a no-brainer way - divided one of the images into 3 sub-templates and glued them together with variables, in a loop.
But thanks for the search & replace routines, may come in handy one day.
vovchik wrote: | any old stock gtk icon could conceivably go into the desktop file |
I wanted to use a stock icon, but LxQtPanel can't display it in Menu (no wonder, it uses QT, not GTK), so I just used your caps-on instead, but converted to PNG, because the panel wasn't happy with SVG, too .
First post updated!
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
vovchik

Joined: 23 Oct 2006 Posts: 1538 Location: Ukraine
|
Posted: Sun 11 Jun 2017, 14:03 Post subject:
|
|
Dear SFR,
It works very nicely and I'm glad I could be of some use. That search/replace function might indeed be useful elsehwere, but I can understand your desire to use gtk-related functions whenever possible. What is nice is that there are many ways the same problem can be solved with a bit of thinking. I wish politicians around the world would adopt the practice.
With kind regards,
vovchikl
|
Back to top
|
|
 |
Puppus Dogfellow

Joined: 07 Jan 2013 Posts: 1669 Location: nyc
|
Posted: Sun 25 Jun 2017, 21:50 Post subject:
|
|
cool--seems to find the tray no matter where it's located. tested out the ability to attach shortcuts with the third mod in Rox and couldn't--second key didn't register no matter what non-modifier call i used. tried out meta and hyper and got control plus super and alt. tried it out in jwm and "3" as a key mask works fine. does anyone know how to get ISO_Level3_Shift working in puppy? Mode_shift works well (the file below uses it to put Menu on the q key--keyboard is missing menu and another i have is missing scroll_lock and menu, so this is the basic xmodfile i've been using:
Quote: |
! caps lock becomes mode switch, scroll lock becomes caps lock, Menu gets added as modeshift plus q
remove Lock = Caps_Lock
keycode 78 = Caps_Lock
! keycode 110 = Caps_Lock
keycode 66 = Mode_switch
add Lock = Caps_Lock
keycode 24 = q Q Menu Q q Q
! keycode 144 = Caps_Lock
! keycode 71 = F5
! keycode 72 = ISO_Level3_Shift
! keycode 153 = F6
! xmodmap -e 'keycode 21 = equal plus Menu'
! keycode 71 = Mode_switch Mode_switch Mode_switch Mode_switch
! keycode 49 = grave asciitilde grave asciitilde grave asciitilde
! keycode 9 = Escape Menu(second slot is plus shift) (plus modeshift)3 (plus shift and modeshift)4 (can't-get 5th6th2wrk)5 (iso level shift 3 plus shift)6
! possible use is to add another 24 function keys (12 on the Function row, 12 on the numbers plus -/+ row, so that shift isn't used/precluded as a modifier. getting isolevel to work would probably be a better solution...)
! (84 is 82 but with scroll lock rather than pause made caps lock; 87 is the same as 84 but without the menu key activated as mode shift plus q; all three relocate Caps_Lock and make the original key into Mode_switch
! c version makes caps lock an extra control and moves mode switch to pause (rest is same as 84))
! make Hyper_R the pause key and add it as a modifier:
keycode 110 = Hyper_R
add mod3 = Hyper_R
! add Control = Hyper_R
! ^tried the above to get the third modifier to work in rox to no avail. line doesn't affect whether or not mod3 works with jwm.
|
), and the hyper_R shortcut works well once you make jwm aware of it. thanks again and in advance
______
jwm mod3 template/includes file available.
|
Back to top
|
|
 |
bigpup

Joined: 11 Oct 2009 Posts: 13981 Location: S.C. USA
|
Posted: Mon 26 Jun 2017, 06:36 Post subject:
|
|
This could be offered as a pet package to install.
You can still posts pet packages on the forum.
Just nothing bigger than Max size 256K.
_________________ The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected
YaPI(any iso installer)
Last edited by bigpup on Fri 14 Jul 2017, 12:02; edited 1 time in total
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Thu 29 Jun 2017, 09:49 Post subject:
|
|
@Puppus Dogfellow: glad it works for you and thanks for the feedback.
Unfortunately I can't help you with the other stuff, because I'm not sure what you're trying to achieve and how it relates to LockState.
___________
bigpup wrote: | This could be offered as a pet package to install. |
It is:
the opening post wrote: | The attached archive contains source code, two PETs (for 32bit and 64bit systems) and TXZ package for Fatdog - all built in FD, too. |
bigpup wrote: | Max size 256mb. |
I believe you meant 256kb.
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Tue 04 Jul 2017, 06:30 Post subject:
|
|
Version 0.4:
- added Preferences dialog for colors & symbols customization
- some internal rearrangements/improvements
First post updated.
Greetings!
Description |
|
Filesize |
22.31 KB |
Viewed |
893 Time(s) |

|
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Wed 12 Jul 2017, 08:38 Post subject:
|
|
Version 0.5:
- added option to draw icons in reversed order (Scroll->Num->Caps), because some panels (JWM's, FBPanel...) draw tray icons from right to left
- added 'Redraw icons' option
- fixed some minor memory leaks
- fixed segfault with glib < 2.36
- small bugfix in sanity checks
- code improvements
First post updated.
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
|
Back to top
|
|
 |
SFR

Joined: 26 Oct 2011 Posts: 1802
|
Posted: Fri 14 Jul 2017, 09:09 Post subject:
|
|
Version 1.0:
- left-clicking an icon toggles the state of the corresponding key
- the last (hopefully) memory leak has been fixed
- minor rearrangements in the code
That's pretty much all I wanted to implement/fix.
Fist post updated.
Greetings!
_________________ [O]bdurate [R]ules [D]estroy [E]nthusiastic [R]ebels => [C]reative [H]umans [A]lways [O]pen [S]ource
Omnia mea mecum porto.
Last edited by SFR on Fri 14 Jul 2017, 16:31; edited 1 time in total
|
Back to top
|
|
 |
bigpup

Joined: 11 Oct 2009 Posts: 13981 Location: S.C. USA
|
Posted: Fri 14 Jul 2017, 12:10 Post subject:
|
|
SFR wrote: | bigpup wrote: | This could be offered as a pet package to install. |
It is: |
The first post looks like LockState-1.0.tar.gz is offered.
That is not a pet package.
I am talking about making a pet package of this, that you can download, click on, and it installs.
I know the pet is in the tar.gz package, but we are humans.
Keep it simple for the human mind.
_________________ The things they do not tell you, are usually the clue to solving the problem.
When I was a kid I wanted to be older.... This is not what I expected
YaPI(any iso installer)
|
Back to top
|
|
 |
|
Page 1 of 2 [18 Posts] |
Goto page: 1, 2 Next |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|