Is there a way to customize commands used by system-tray-app (display-setting)

Hi,

I would like to set my own commands to the system-tray-app for switching screens. Is this possible and where do I find the files to change these commands?

The thing is, when I switch to my second monitor from the system-tray-app, the wrong refresh-rate is set. If I switch via a shortcut that I gave the command xrandr --output DP-1 --mode 1920x1080 --rate 60 then everything is fine. So I would like to configure the system-tray-app to use this command, instead of the one it uses now.

You could do a script… make a folder and an empty file… ~/bin/160.sh (160 short for dp-1 60)

Contents:

#!/bin/bash
commands () {
xrandr --output DP-1 --mode 1920x1080 --rate 60
'echo Setting DP-1 to FHD 60Hz'
sleep 4
}
export -f commands
konsole -e 'bash -c commands'

Juz drag a shortcut to your panel :wink: here’s my ‘sleep timer’.

1 Like

Thanks for your reply.

I have copied the script, saved it into .bin at my home-folder, made it excutable and it works perfectly. But I don’t understand how to drag it to the panel.

But in the end I want to know where to edit the commands being used by the system-tray app itself. Because I would like to use this one.
For now I have the miniature-application “text-command”, that could also contain commands. But I don’t want to have several buttons for - 1. monitor - 2. monitor - both monitors - but use this really nice system-tray app (I don’t know how to attach screenshots, so I can’t show you) that contains all in one.

But if you like to explain it anyway, how to “drag this script to the panel”, I would be glad and maybe replace the “text command”-app in the meantime.

My sleeptimer is simply open a terminal and typing:
shutdown -h +90
:slight_smile:

My first sleep timer would set RTCWake (inputting sudo password).

Interative Sleep timer - checks wakeup time
#!/bin/bash

commands () {
echo Wakeup time check: && echo masonnnn | sudo -S rtcwake -m show -l -v |rg alarm: | cut -c 12-30}
sleep 1;
date +"It's now %R" | cowthink
echo "How long until suspending?"
read TIME
echo $TIME set!; sleep $TIME;
xdotool getwindowfocus windowkill; amixer set Master 45%; systemctl suspend
}

export -f commands

konsole -e "bash -c 'commands'"

Dragging to the panel… you open the folder in Dolphin, click it with the mouse and drag it over the panel until you see a + symbol on your mouse cursor…

Then if you want sleep now, you set something like 10s to give time to put the mouse away (so as not to wake it up) or 90m to give you 90 minutes.
Screenshot_20220820_083119
After a rude awakening (loud music) I also put in the amixer volume reset command.

Should also work for shutting down - but that won’t wake up in the morning before my KAlarm wakeup call playing gentle music…

You should tell us exactly what widget you’re using - because you can’t actually drag things to the systray itself.

Another thing - you don’t need to keep the panel visible for such ‘extra’ items. You can make an extra, smaller panel - I have a hidden panel at the top for hidden entries and I actually kekep the script there (I just took this screenshot to show I could drag it there) - which you could not see in the original screenshot.
Screenshot_20220820_083840

There’s also another option for this - if you are cool with shortcuts.

You can make two scripts display160.sh and display 260.sh and bind them to a mouse gesture.

Here’s one I did for xKill (drawing ‘K’ brings up skull and crossbones window killer :P)


You could set one were you draw either a small ‘d’ or a capital ‘D’ to switch to two modes - enter command from mouse gesture… or you could set it to a keyboard shortcut, and also map that keyboard shortcut to a mouse gesture.

Cool stuff :slight_smile:

In german it is titled with “Anzeige-Einrichtung” so in english I guess it is display-setting. When you klick on it, it opens an area (display arrangement) where you can choose to click on 5 different arrangements.

https://paste.pics/5ce59eae7b9c21946c9f7c1d7396737e

This is why I try to find out where kde does define what to do on mouseclick on one of the arrangements, and if there is a way to modify the command being executed.

Ah, tough one - those aren’t widgets and I don’t think it’s so easy to define stuff that comes up in the Tray icons.

I’d definitely look at keyboard/mouse gestures for this one. They work well for restarting kwin, refreshing plasma, and setting Krohnkite to tiling/floating modes too.

As I said, I just have the “text command” widget with the xrand command set. So if I now want to turn my second screen on, I can do it from there. (If I switch to the second screen from the system-tray while disabling the first screen simultaneously, the refresh-rate of the second screen is set properly).
Or I use a keyboard shortcut. This works fine also.

But I was curious whether I could customize the system-tray-widget in a way, that this would work as well. I think I would have to ask the kde-team how this works :slight_smile:

Thank you very much for your suggestions. And for your insights in shell-scripts. Maybe I could use some of it later.