Would you like to react to this message? Create an account in a few clicks or log in to continue.

  • Post new topic
  • Reply to topic

Using "Configurable Buttons" to lock your KDE Desktop

avatar
davecs


Posts : 110
Join date : 2024-05-14

Using "Configurable Buttons" to lock your KDE Desktop Empty Using "Configurable Buttons" to lock your KDE Desktop

Post by davecs 20th July 2024, 1:46 pm

I like a lot of things about the KDE desktop, but one thing that I don't like is how easy it is to accidentally move applets off the panel onto the desktop (as an example). Too much drag and drop is not always a good thing. It is possible to lock the system, but the command to do so is in really obscure parts of certain context menus. I thought what might be better is to have an icon on the panel that can easily switch between locked and unlocked.

There is a way to do this. You can add a plasmoid called "Configurable Button" from the KDE Store. It is installed to the your folder /home/yourusername/.local/share/plasma/plasmoids/ but can be moved to /usr/share/plasma/plasmoids/ if you want to make it available to other users on the same computer. As with most plasmoids, after you put it on your panel, you can set its properties with a right click.

You get a box to add an on script, which should be:

Code:
qdbus org.kde.plasmashell /PlasmaShell evaluateScript "lockCorona(false)"

The on script unlocks the panel, and the icon I use is an open padlock type icon in red (to suggest it's unlocked and dangerous)

You get a box to add an off script, which should be:

Code:
qdbus org.kde.plasmashell /PlasmaShell evaluateScript "lockCorona(true)"

The off script locks the panel, and the icon I use is an closed padlock type icon in green (to suggest it's locked and safe)

I found both icons in the "Emblem" section of the icons. The open padlock was a bit "orange" rather than red. Of course you can create your own.

The other thing is that you need to set up your desktop so that it's locked when you log in. This involves two scripts which you can put in /usr/local/bin and need to be marked executable.

First is lock-desktop
Code:
#!/bin/bash

sleep 10

qdbus org.kde.plasmashell /PlasmaShell evaluateScript "lockCorona(true)"

Second is lock-desktop-startup
Code:
#!/bin/bash

lock-desktop &

The reason for two scripts is to create a delay while handing control back to KDE. This is because you have to lock the desktop after the KDE desktop startup has finished doing its stuff. If there's no delay, the KDE scripts will unlock the desktop after you lock it! If your computer is a bit slow, you might have to increase the number after "sleep". You need to put lock-desktop-startup in your KDE startup settings.


Last edited by davecs on 25th July 2024, 6:31 pm; edited 2 times in total
avatar
davecs


Posts : 110
Join date : 2024-05-14

Using "Configurable Buttons" to lock your KDE Desktop Empty Re: Using "Configurable Buttons" to lock your KDE Desktop

Post by davecs 20th July 2024, 2:06 pm

Here are a couple of icons you might want to use for the above:

Using "Configurable Buttons" to lock your KDE Desktop Locked10  Using "Configurable Buttons" to lock your KDE Desktop Unlock10
  • Post new topic
  • Reply to topic

Current date/time is 20th September 2024, 8:48 pm