Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 22 Jun 2017, 10:34
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » System
LockState v0.3
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [8 Posts]  
Author Message
SFR


Joined: 26 Oct 2011
Posts: 1609

PostPosted: Fri 09 Jun 2017, 14:28    Post subject:  LockState v0.3
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 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!
LockState-0.3.tar.gz
Description  MD5: bf91f3be11aa6575d359b69b99ee0c41 LockState-0.3.tar.gz
gz

 Download 
Filename  LockState-0.3.tar.gz 
Filesize  30.19 KB 
Downloaded  12 Time(s) 
LockState-0.1.tar.gz
Description  MD5: 30c970f380aa93f74a779e9a0eb01c12 LockState-0.1.tar.gz
gz

 Download 
Filename  LockState-0.1.tar.gz 
Filesize  93.2 KB 
Downloaded  12 Time(s) 
LockState.png
 Description   
 Filesize   10.93 KB
 Viewed   273 Time(s)

LockState.png


_________________
[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 Sun 11 Jun 2017, 17:14; edited 5 times in total
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 10306
Location: Gatineau (Qc), Canada

PostPosted: Fri 09 Jun 2017, 15:58    Post subject:  

Thanks, SFR.

Certainly useful for small WM's like aewm or echinus.

BFN.

_________________
musher0
~~~~~~~~~~
« Un insensé sur le trône n'est qu'un singe sur le haut d'un toit. » / "A madman
on the throne is just a monkey on top of a roof." (Bernard de Clervaux)
Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 1378
Location: The other Mr. 305

PostPosted: 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
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1432
Location: Ukraine

PostPosted: 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. Smile 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. Smile 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>).
lockstate-vov.c.tar.gz
Description 
gz

 Download 
Filename  lockstate-vov.c.tar.gz 
Filesize  3.54 KB 
Downloaded  4 Time(s) 
key-svg.tar.gz
Description 
gz

 Download 
Filename  key-svg.tar.gz 
Filesize  685 Bytes 
Downloaded  3 Time(s) 
Back to top
View user's profile Send private message 
zigbert


Joined: 29 Mar 2006
Posts: 6435
Location: Valåmoen, Norway

PostPosted: Sun 11 Jun 2017, 05:24    Post subject:  

Very nice Smile
_________________
Stardust resources
Back to top
View user's profile Send private message Visit poster's website 
vovchik


Joined: 23 Oct 2006
Posts: 1432
Location: Ukraine

PostPosted: 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
lockstate-mod.c.tar.gz
Description 
gz

 Download 
Filename  lockstate-mod.c.tar.gz 
Filesize  11.49 KB 
Downloaded  5 Time(s) 
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1609

PostPosted: 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! Very Happy
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 Rolling Eyes .

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
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1432
Location: Ukraine

PostPosted: 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. Smile I wish politicians around the world would adopt the practice.

With kind regards,
vovchikl
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [8 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » System
Jump to:  

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
[ Time: 0.0483s ][ Queries: 12 (0.0079s) ][ GZIP on ]