[KDE] How to remove all active panels with script

I need a universal & reliable way to remove all default panels, but without completely removing plasma-org.kde.plasma.desktop-appletsrc or any of it's non-panel options.

Please? :slight_smile:

I would propose creating a user account in which you remove the panels first, and then using the widget below to store your configuration, which you can then port to other user accounts. Of course, being a widget, you'd have to put it somewhere ─ maybe on the desktop.

2 Likes

Nice, but not what i'm looking for - i need script way not for initial setup only but with any possible configuration of plasma-org.kde.plasma.desktop-appletsrc

Well, the placement and sizes of the panels are defined in ~/.config/plasmashellrc, but I don't know where the contents of the panels are defined. :thinking:

As far as i see it's in plasma-org.kde.plasma.desktop-appletsrc, inside sections:
[Containments][randomnumber_defining_panel]
well, at least partially with applets and all that

Well, then I imagine the proper course of action for your script would have to be...

  1. Make a backup copy of ~/.config/plasmashellrc and ~/.config/plasma-org.kde.plasma.desktop-appletsrc.

  2. Pull some magic with sed and/or awk to remove the pertinent sections from ~/.config/plasmashellrc and ~/.config/plasma-org.kde.plasma.desktop-appletsrc.

... and in that order. :thinking:

Yep, that's what i though unless we miss some native options / utility to do same...

kreadconfig5 / kwriteconfig5 unfortunately can only work with single option in single Category at a time..

Unfortunately that level of sed/awk trickery to define all Categories corresponding to panels and then remove it with all of it's property specifically for panels...is waaay above my "paygrade" :laughing:, so hopefully someone could help with example :slight_smile:

Ditto. :slight_smile: :white_flag:

1 Like

looks like this might work .. try at your own risk.

perl -00ne 'print unless /org.kde.panel/' .config/plasma-org.kde.plasma.desktop-appletsrc

That should print the missing all 'panel paragraphs'. Check for yourself.

Then you can use -i to change it on the fly or -i.bak to creat a backup while editing

perl -i -00ne 'print unless /org.kde.panel/' .config/plasma-org.kde.plasma.desktop-appletsrc

(I just checked real quick on the output.. dont blame me for catastrophic cats)

2 Likes

exists also

 kwriteconfig5 --file plasma-org.kde.plasma.desktop-appletsrc ...
 kreadconfig5 --file plasma-org.kde.plasma.desktop-appletsrc --group "Containments" --group "7" --key location

Here's the desired effect, compare those 2 with Meld or any diff software for example i'll have KDE pre4 .iso:

default

[ActionPlugins][0]
MidButton;NoModifier=org.kde.paste
RightButton;NoModifier=org.kde.contextmenu
wheel:Vertical;NoModifier=org.kde.switchdesktop

[ActionPlugins][1]
MidButton;NoModifier=org.kde.paste
RightButton;NoModifier=org.kde.contextmenu

[Containments][1]
activityId=
formfactor=2
immutability=1
lastScreen=0
location=4
plugin=org.kde.panel
wallpaperplugin=org.kde.image

[Containments][1][Applets][2]
immutability=1
plugin=org.kde.plasma.kickoff

[Containments][1][Applets][2][Configuration]
PreloadWeight=92

[Containments][1][Applets][2][Configuration][General]
favorites=firefox.desktop,org.kde.dolphin.desktop,org.kde.konversation.desktop,libreoffice-writer.desktop,cantata.desktop,kde4-digikam.desktop,org.kde.konsole.desktop,pamac-manager.desktop,pamac-updater.desktop,systemsettings.desktop
favoritesPortedToKAstats=true
systemApplications=systemsettings.desktop,org.kde.kinfocenter.desktop

[Containments][1][Applets][2][Configuration][Shortcuts]
global=Alt+F1

[Containments][1][Applets][2][Shortcuts]
global=Alt+F1

[Containments][1][Applets][3]
immutability=1
plugin=org.kde.plasma.pager

[Containments][1][Applets][3][Configuration]
PreloadWeight=42

[Containments][1][Applets][4]
immutability=1
plugin=org.kde.plasma.icontasks

[Containments][1][Applets][4][Configuration]
PreloadWeight=42

[Containments][1][Applets][4][Configuration][General]
launchers=applications:org.kde.dolphin.desktop,applications:firefox.desktop

[Containments][1][Applets][5]
immutability=1
plugin=org.kde.plasma.showdesktop

[Containments][1][Applets][5][Configuration]
PreloadWeight=42

[Containments][1][Applets][6]
immutability=1
plugin=org.kde.plasma.trash

[Containments][1][Applets][6][Configuration]
PreloadWeight=42

[Containments][1][Applets][7]
immutability=1
plugin=org.kde.plasma.systemtray

[Containments][1][Applets][7][Configuration]
PreloadWeight=42
SystrayContainmentId=8

[Containments][1][Applets][7][Configuration][Containments][8]
formfactor=2
location=4

[Containments][1][Applets][8]
immutability=1
plugin=org.kde.plasma.digitalclock

[Containments][1][Applets][8][Configuration]
PreloadWeight=7

[Containments][1][Applets][8][Configuration][Appearance]
dateFormat=custom
showDate=true

[Containments][1][Applets][8][Configuration][ConfigDialog]
DialogHeight=540
DialogWidth=720

[Containments][1][Configuration]
PreloadWeight=42

[Containments][1][General]
AppletOrder=2;3;4;5;6;7;8

[Containments][8]
activityId=
formfactor=2
immutability=1
lastScreen=0
location=4
plugin=org.kde.plasma.private.systemtray
wallpaperplugin=org.kde.image

[Containments][8][Applets][10]
immutability=1
plugin=org.kde.plasma.volume

[Containments][8][Applets][10][Configuration]
PreloadWeight=42

[Containments][8][Applets][11]
immutability=1
plugin=org.kde.plasma.clipboard

[Containments][8][Applets][11][Configuration]
PreloadWeight=42

[Containments][8][Applets][12]
immutability=1
plugin=org.kde.plasma.devicenotifier

[Containments][8][Applets][12][Configuration]
PreloadWeight=42

[Containments][8][Applets][13]
immutability=1
plugin=org.kde.kdeconnect

[Containments][8][Applets][13][Configuration]
PreloadWeight=42

[Containments][8][Applets][14]
immutability=1
plugin=org.kde.plasma.keyboardindicator

[Containments][8][Applets][14][Configuration]
PreloadWeight=42

[Containments][8][Applets][15]
immutability=1
plugin=org.kde.plasma.notifications

[Containments][8][Applets][15][Configuration]
PreloadWeight=42

[Containments][8][Applets][16]
immutability=1
plugin=org.kde.plasma.printmanager

[Containments][8][Applets][16][Configuration]
PreloadWeight=42

[Containments][8][Applets][17]
immutability=1
plugin=org.kde.plasma.networkmanagement

[Containments][8][Applets][17][Configuration]
PreloadWeight=42

[Containments][8][Applets][18]
immutability=1
plugin=org.kde.plasma.battery

[Containments][8][Applets][18][Configuration]
PreloadWeight=42

[Containments][8][Configuration]
PreloadWeight=42

[Containments][8][General]
extraItems=org.kde.plasma.devicenotifier,org.kde.plasma.battery,org.kde.kdeconnect,org.kde.plasma.volume,org.kde.plasma.mediacontroller,org.kde.plasma.printmanager,org.kde.plasma.keyboardindicator,org.kde.plasma.bluetooth,org.kde.plasma.clipboard,org.kde.plasma.networkmanagement,org.kde.plasma.notifications
knownItems=org.kde.plasma.devicenotifier,org.kde.plasma.battery,org.kde.kdeconnect,org.kde.plasma.volume,org.kde.plasma.mediacontroller,org.kde.plasma.printmanager,org.kde.plasma.keyboardindicator,org.kde.plasma.bluetooth,org.kde.plasma.clipboard,org.kde.plasma.networkmanagement,org.kde.plasma.notifications

[Containments][9]
activityId=4f79abe6-046c-4f34-9e58-ce12fcca4067
formfactor=0
immutability=1
lastScreen=0
location=0
plugin=org.kde.plasma.folder
wallpaperplugin=org.kde.image

[Containments][9][Configuration]
PreloadWeight=42

[Containments][9][Wallpaper][org.kde.image][General]
Image=file:///usr/share/wallpapers/Breath2/contents/images/1600x1200.png

[ScreenMapping]
itemsOnDisabledScreens=

remove panel manually via KDE

[ActionPlugins][0]
MidButton;NoModifier=org.kde.paste
RightButton;NoModifier=org.kde.contextmenu
wheel:Vertical;NoModifier=org.kde.switchdesktop

[ActionPlugins][1]
MidButton;NoModifier=org.kde.paste
RightButton;NoModifier=org.kde.contextmenu

[Containments][9]
activityId=4f79abe6-046c-4f34-9e58-ce12fcca4067
formfactor=0
immutability=1
lastScreen=0
location=0
plugin=org.kde.plasma.folder
wallpaperplugin=org.kde.image

[Containments][9][Configuration]
PreloadWeight=42

[Containments][9][Wallpaper][org.kde.image][General]
Image=file:///usr/share/wallpapers/Breath2/contents/images/1600x1200.png

[ScreenMapping]
itemsOnDisabledScreens=

Your perl actually works pretty well, it removes this section as intended, which effectively annihilate panel visually after plasma reboot:

[Containments][1]
activityId=
formfactor=2
immutability=1
lastScreen=0
location=4
plugin=org.kde.panel
wallpaperplugin=org.kde.image

But it would be cool to remove all the other crap as well, that's not necessary and harder i guess...

@papajoke
Not sure i follow? Please expand on what you mean :slight_smile:

Actually looking at the diff, i was thinking why not remove all containment entries all together, except wallpaperplugin & Image=file:// using perl method?

But i guess if for example there are some plugins directly on desktop they will also be containment, so it would remove them as well....

Well .. this isnt smart or anything ..it just removes the exact line numbers ..but it works:

sed '10,179d' FILE

or

sed -i.bak '10,179d' FILE

or

sed '10,179d' FILE > NEWFILE

OK .. and a little smarter now naming strings for each paragraph you wanted to preserve:

Test by printing:

sed -e '/./{H;$!d;}' -e 'x;/ActionPlugins/b' -e '/[9]/b' -e '/ScreenMapping/b' -e d FILE

Then, again, you can use something like -i to make the changes to the file:

sed -i -e '/./{H;$!d;}' -e 'x;/ActionPlugins/b' -e '/[9]/b' -e '/ScreenMapping/b' -e d FILE

EDIT @keybreak ..

So something like this as a script would work:

#!/usr/bin/env bash
#               panelpluckr.sh               #
## To automate the killing of Plasma panels ##
#####                cscs                #####
sed -i.bak -e '/./{H;$!d;}' -e 'x;/ActionPlugins/b' -e '/[9]/b' -e '/ScreenMapping/b' -e d /home/$USER/.config/plasma-org.kde.plasma.desktop-appletsrc ;
qdbus org.kde.KWin /KWin reconfigure ; 
kquitapp5 plasmashell > /dev/null 2>&1 && kstart5 plasmashell > /dev/null 2>&1 ; 
echo -e "\nPanels now removed. Previous configuration file saved as\n\"plasma-org.kde.plasma.desktop-appletsrc.bak\"\n" ;
exit

In this case I used the '$USER' variable for the home path, though you could use a manually generated variable like

 YOU=`echo $1 | sed -e 's/^[^ ]* //g'`

I also used -i.bak so that sed would create a backup of the file before making the edit.

Again note that I have no idea how well this would work in other situations .. its just printing the matching paragraphs that you showed me. The first example of perl is probably the most 'agnostic'.

2 Likes

:laughing:

Nice one mr. sed ninja! :slight_smile:

i'd have to sleep with it, but for now it's closest :+1:

Although reloading for me works only like that:

qdbus org.kde.KWin /KWin reconfigure
kquitapp5 plasmashell
kstart5 plasmashell > /dev/null 2>&1

Probably you should edit this in your script

There .. edited with some commentary too. Looks Like it works at least in your case. I just took it for a spin.

..if you like .. I could add some switches so it can have a flag for how it works now - create a no-panel config file and reload plasma .. and then another one to do the reverse - move the .bak file back and reload plasma.

panelpluckr -kill
panelpluckr -revive

or similar.

1 Like

Well, if you want to, for those who'll find it here later - i'll reuse just sed part in series of bigger scripts )

1 Like

Fair enough .. maybe if I am bored :wink:

By the way - if you find you need to capture more paragraphs in the future it should be intelligible enough so that you can expand that sed line for any other terms/strings to look for.

exists also plasma python api, for exemple

from PyKF5 import KConfigCore   #doc: /usr/include/KF5/KConfigCore/

kc = KConfigCore.KConfig("plasma-org.kde.plasma.desktop-appletsrc");
print("groupList:", kc.groupList())

group = kc.group("Containments")
print("\ngroupList:", group.groupList())
for k in group.groupList():
    print(k, " - ", group.group(k).readEntry("plugin"))

# for control
# grep -E "^(.Containments.*[0-9].$|plugin)" .config/plasma-org.kde.plasma.desktop-appletsrc

ouput

groupList: ['24', '7', '2']
24  -  org.kde.desktopcontainment
7  -  org.kde.plasma.private.systemtray
2  -  org.kde.panel
1 Like

Oooh, that's interesting!
So basically with their python api you can get numbers of panel only groups and then eliminate them! :+1:

Is there a function in ** KConfigCore** for removing full group (in case you already know it's full name)?

Something like:

kc.group("Containments","2").remove()

?

I haven't found one with quick look on source...But maybe missed something

Forum kindly sponsored by