New applet mod for Linux Mint Cinnamon: betterlockPlus

This is the second attempt at improving a Linux Mint Cinnamon applet; a “spice” – as they call it. An applet is nothing more than a sort of a script, or better said a collection of scripts mainly written in javascript with possible Python connections and JSON settings, accessible through one or more icons residing in the Panel (or Taskbar as it’s called in MS Windows).

This one is a multiple indicator for the state of the lock keys on the keyboard: Num Lock, Caps Lock and Scroll Lock. While regular (external) keyboards may still sport LEDs showing these keys’ state, laptops/notebooks and other devices are very scarce with these indicators and in certain models they lack completely. Many people – me included – wasted time and got mad after realizing they’ve been typing a lot of text in Capitals, for example, when Caps Lock got accidentally hit. Or accidentally disabling Num Lock – not to mention in Linux Mint and possibly other distros it is disabled at startup and requires the installation of an additional package (numlockx) that for mysterious reason is not installed and enabled by default – which makes one type numbers and perform calculations only to notice they instead just scroll the page in all directions or whatever effect may have.

Scroll Lock doesn’t even get included in Ubuntu and derivatives’ keyboard layouts! No idea what the reason may be, but it’s possible people may need it in some application. At least on the specific Spices page for this applet there is a request for the implementation of a Scroll Lock notifier, something I saw only after having implemented it. So maybe at least for another person I haven’t worked in vain.
Sure, there is a recent attempt at implementing this, found out also after having done it while looking for some license for the original package to get my ass covered in case anyone cried for rights. No idea how it looks like, didn’t bother to look at the code but I’m fairly sure it’s much simpler than what I did here. Or maybe I’m wrong, dunno. Whatever.

Now what I did to improve over the current code as found in the official Spices repository at the time of starting the changes (few days ago, mid May 2022):
– added Scroll Lock indicator icon
– added individual tooltip (shows only hovered icon’s state)
– added ability to customize icon size (between 12px and 48px)
– added ability to change icons’ colors
– added automatic orientation based on icon size and panel height/width
– added automatic addition/removal of menu items according to enabled indicators

A few details about the above changes.
The addition of the Scroll Lock icon is self-explanatory. It should all be just like it used to be at least on legacy keyboards, regardless of whether the user needs all indicators or not. At any time any of the indicator icons can be disabled (hidden) if the user doesn’t want them, by means of the configuration panel. By the way, I’m inclined to redo that panel more in the way I did with Applet PYE: toggle buttons with icons instead of the dropdown list. I find it to look more elegant that way. We’ll see (what do you think…?).

The individual tooltip is just an ordinary tooltip that displays the state of the currently hovered icon. I’ve seen an attempt at a tooltip that was displaying all states at once; actually it was just Num Lock and Caps Lock. Didn’t like that, wanted it to be strict, so the user would know precisely what the currently hovered icon is for and what its state is, although that should arguably be understood from the appearance of the icon.

The ability to customize icon size could be seen as too fancy, superfluous or even damaging to the aspect of the entire Panel, for some. But the beauty is that anyone can choose the preferred size, so they can make them all look alike to be in line with the other icons in that area, or make them stand out for better visibility – especially people with poor eyesight – or on the contrary make them smaller to only catch a glimpse at them when needed without disturbing other more important notification icons around. It’s everyone’s choice.

Same could be said about the ability to change icons’ colors. Just like the icon size it’s optional; one doesn’t have to do it if they don’t want/need it. Downside is they’re all interconnected, it’s all or none – at least for now. So if one enables customizing they’ll have to both choose an icon size of the available ones and the colors for the on/off icons. They are still symbolic-looking but they get a tint, which may help with certain themes as someone at the same Spices page pointed out.

As an aside, this obstinated choice of grey for the major parts of the interface is something I’ll never understand. And the worst thing is that changing colors for the theme elements is reserved only to the very knowledgeable since it’s all CSS (Cascade Style Sheets). In a way the Linux graphical interface is nothing but a glorified web page! Anyone remembers the degree of theme customization in Windows 95/98/ME/2000/XP…? Regular users will never get to do any detailed customization other than changing the theme as a whole, and there is not much to choose there either since all authors seem to be bent on the same dark, flat and minimalist style. Which I find ugly as hell and damaging to the mind in the long run – but who cares about my opinions.

Back to our topic: the automatic orientation. What does that mean? It means that as long as the cumulated icon sizes plus the spacing exceeds the panel height (in horizontal layout) or width (in vertical layout) the icons will be in line with all the surrounding icons. However when that cumulated size is less or equal than panel size (height or width as mentioned above) the icons will have a perpendicular layout.

I wanted that firstly for me, as having so many icons on both sides of the panel leaves very little space for the currently open window “buttons” even when using the – still flawed – multi-line taskbar applet. Having all three icon indicators visible and still taking little space – the chosen width of a single icon in perpendicular layout – is a small but welcome improvement. I keep the panel(s) autohidden so there’s no problem with their large size anyway. Wish the Cinnamon developers had thought about implementing multi-row panels but I guess they were busy with other more useless gimmicks. Even if they did it now it would be too late for me anyway as I won’t leave this Mint 19.2 setup. Too much has been stripped off in later versions.

Last thing is the menu items in the context (right-click) menu. I feel they are somehow superfluous considering the icons are clickable and can change state that way, but while the menu was already there I thought it should also work correctly. So when the user disables any icon/indicator the corresponding menu item is being removed. This is a logical flow as leaving all of them enabled without the corresponding indicators could lead to inadvertently switching of the locks.

When a single icon/indicator is displayed the menu is completely hidden. This seems to have been the desire of the author or one of the contributors so I kept it while reorganizing the menu building process. Therefore if one chooses to display only one of the three icons – be it Num-, Caps- or Scroll Lock – the switches menu will be missing. Choosing a combination of two or all three icons will bring the corresponding menu items back.

And that’s about it folks. If you need it and like it, fine; if you don’t it’s fine all the same. Any suggestions or bug reports are welcome as long as I still breathe and can do something about it. happy

Screenshot (perpendicular layout):

Settings panel in various themes (Mint-Y, Windows Longhorn Aero, Windows Longhorn Plex, Cinnamox-Aubergine, Rose):

betterlockPlus settings panel

Direct download link (Dropbox): betterlockPlus 1.3.1

Old versions:
betterlockPlus 1.3.0
betterlockPlus 1.2.0
betterlockPlus 1.0.1
P.S. If anyone lacks the operation of Scroll Lock and needs to know how to enable it, just say it and I’ll do a post on that. It involves editing the very keyboard layout file(s), so while in itself it’s quite an easy task care must be taken not to bork the file(s).