Automating Command Line Panels?

I have a question about Manjaro KDE automation.

Every time I start the computer, I have to run a series of commands across a few monitors to set up the konsole system monitoring.

This consists of running a few commands to check on system health and other monitors: glances, nmon +d.

Every time KDE is restarted, it remembers that there are terminals there, but does not remember the commands which were run. Is it possible to automate the opening of these terminal windows in their proper screen positions with the commads they are supposed to run?

With the disclaimer that I’ve never done this, I think you can do it by creating .desktop files for those commands, and the .desktop files can then be added to the Autostart section.

Wow!

That’s really interesting, I’ve never meade a.desktop file, but I’ve seen them around.

I looked into creating the .desktop files, and I think that might be a workable solution.

But how should I implement it for persistance? Will the .desktop files be remembered by KDE (and opened next restart)? Or should I try a slightly more complicated approach like a starting .sh script with a closing script run at shutdown?

If you add them to the Autostart section of the System Settings, then they will automatically be launched at login.

Workspace → Startup and Shutdown → Autostart+Add

1 Like

Would the memory function of KDE just see them as regular terminal windows though and duplicate them, or would it just think that this is a very specific .desktop thing?

IDK, never done this before.
Thanks for the advice though ^^

A .desktop file has a certain declarative syntax that tells Plasma how to start a particular application. This includes whether the application must run in a terminal or not.

The example below is the .desktop file for htop, which is a process, memory and CPU monitoring tool that runs in a terminal. :arrow_down:

[Desktop Entry]
Type=Application
Version=1.0
Name=Htop
GenericName=Process Viewer
GenericName[ca]=Visualitzador de processos
GenericName[da]=Procesfremviser
GenericName[de]=Prozessanzeige
GenericName[en_GB]=Process Viewer
GenericName[es]=Visor de procesos
GenericName[fi]=Prosessikatselin
GenericName[fr]=Visualiseur de processus
GenericName[gl]=Visor de procesos
GenericName[it]=Visore dei processi
GenericName[ko]=프로세스 뷰어GenericName[nb]=Prosessviser
GenericName[nl]=Viewer van processen
GenericName[nn]=Prosessvisar
GenericName[pl]=Przeglądarka procesów
GenericName[pt]=Visualizador de Processos
GenericName[pt_BR]=Visualizador de processos
GenericName[ru]=Монитор процессов
GenericName[sk]=Prehliadač procesov
GenericName[sl]=Pregledovalnik opravil
GenericName[sr@ijekavian]=Приказивач процеса
GenericName[sr@ijekavianlatin]=Prikazivač procesa
GenericName[sr@latin]=Prikazivač procesa
GenericName[sr]=Приказивач процеса
GenericName[sv]=Processvisning
GenericName[tr]=Süreç Görüntüleyici
GenericName[uk]=Перегляд процесів
GenericName[zh_CN]=进程查看器GenericName[zh_TW]=行程檢視器Comment=Show System Processes
Comment[ca]=Visualitzeu els processos del sistema
Comment[da]=Vis systemprocesser
Comment[de]=Systemprozesse anzeigen
Comment[en_GB]=Show System Processes
Comment[es]=Mostrar procesos del sistema
Comment[fi]=Katsele järjestelmän prosesseja
Comment[fr]=Affiche les processus système
Comment[gl]=Mostrar os procesos do sistema.
Comment[it]=Mostra processi di sistema
Comment[ko]=시스템 프로세스 보기Comment[nb]=Vis systemprosesser
Comment[nl]=Systeemprocessen tonen
Comment[nn]=Vis systemprosessar
Comment[pl]=Pokaż procesy systemowe
Comment[pt]=Mostrar os Processos do Sistema
Comment[pt_BR]=Mostra os processos do sistema
Comment[pt_BR]=Mostra os processos do sistema
Comment[ru]=Просмотр списка процессов в системе
Comment[sk]=Zobraziť systémové procesy
Comment[sl]=Prikaz sistemskih opravil
Comment[sr@ijekavian]=Приказ системских процеса
Comment[sr@ijekavianlatin]=Prikaz sistemskih procesa
Comment[sr@latin]=Prikaz sistemskih procesa
Comment[sr]=Приказ системских процеса
Comment[sv]=Visa systemprocesser
Comment[tr]=Sistem Süreçlerini Göster
Comment[uk]=Перегляд системних процесів
Comment[zh_CN]=显示系统进程Comment[zh_TW]=顯示系統行程Icon=htop
Exec=htop
Terminal=true
Categories=System;Monitor;ConsoleOnly;
Keywords=system;process;task

Don’t mind the multiple translations — you don’t need to add those — but look at the rest of the syntax; it includes the name of the process to run — htop, which is an executable — as well as that it must be run in a terminal.

I do not know whether a .desktop file allows you to pick the virtual desktop that the session will be launched on, but you can use window rules for that in the System Settings. :arrow_down:

Workspace → Window Management → Window Rules+Add New

Note: The .desktop file itself does not need to have execute permission. It’s a plain text file.

2 Likes

The .desktop files work as expected, but don’t start on the correct screen.

When I try and add a window rule for each window, it overwrites the prior one :frowning:

Is there a way to say which screen it should start on in the desktop file?

Apparently you can set it in the Autostart entry, by replacing the name of the executable with a longer command, along the lines of… :arrow_down:

kstart5 --desktop 2 name-of-the-application

… whereby name-of-the-application corresponds to the executable. This way, you don’t need window rules.

For more information regarding the options, see… :arrow_down:

kstart5 --help

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.