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 Sat 21 Oct 2017, 04:48
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » System
LockState v1.0
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [15 Posts]  
Author Message
SFR


Joined: 26 Oct 2011
Posts: 1636

PostPosted: Fri 09 Jun 2017, 14:28    Post subject:  LockState v1.0
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.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!
LockState-1.0.tar.gz
Description  MD5: 598a0a9d955f89a6f0113edd14b64bcd LockState-1.0.tar.gz
gz

 Download 
Filename  LockState-1.0.tar.gz 
Filesize  55.49 KB 
Downloaded  52 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  31 Time(s) 
LockState.png
 Description   
 Filesize   10.93 KB
 Viewed   617 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 Fri 14 Jul 2017, 09:07; edited 8 times in total
Back to top
View user's profile Send private message 
musher0


Joined: 04 Jan 2009
Posts: 10969
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
~~~~~~~~~~
"Logical entities must not be multiplied beyond necessity." | |
« Il ne faut pas multiplier les entités logiques sans nécessité. » (Ockham)
Back to top
View user's profile Send private message 
slavvo67

Joined: 12 Oct 2012
Posts: 1424
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: 1441
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  22 Time(s) 
key-svg.tar.gz
Description 
gz

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


Joined: 29 Mar 2006
Posts: 6493
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: 1441
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  21 Time(s) 
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1636

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: 1441
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 
Puppus Dogfellow


Joined: 07 Jan 2013
Posts: 1493
Location: nyc

PostPosted: 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 Very Happy

______

jwm mod3 template/includes file available.
Back to top
View user's profile Send private message 
bigpup


Joined: 11 Oct 2009
Posts: 9386
Location: Charleston S.C. USA

PostPosted: 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.

_________________
I have found, in trying to help people, that 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 Shocked

Last edited by bigpup on Fri 14 Jul 2017, 12:02; edited 1 time in total
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1636

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


Joined: 26 Oct 2011
Posts: 1636

PostPosted: 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!
LockState_Settings.png
 Description   
 Filesize   22.31 KB
 Viewed   240 Time(s)

LockState_Settings.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.
Back to top
View user's profile Send private message 
SFR


Joined: 26 Oct 2011
Posts: 1636

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


Joined: 26 Oct 2011
Posts: 1636

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


Joined: 11 Oct 2009
Posts: 9386
Location: Charleston S.C. USA

PostPosted: 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. Shocked
Keep it simple for the human mind. Laughing

_________________
I have found, in trying to help people, that 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 Shocked
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [15 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.0664s ][ Queries: 12 (0.0047s) ][ GZIP on ]