6

I'm usually using 4 virtual desktops and I like to keep the pager widget in the taskbar, which shows which desktop I'm currently looking at.

But the widget is relatively large:

enter image description here

Is there a way to decrease the width of the desktop symbols in the pager widget?

My plasmashell version is 5.12.8.

JBGruber
  • 221
  • 1
    There may be a way. See, for example, https://askubuntu.com/q/1094113/248158 and this link. – DK Bose Aug 07 '19 at 15:35
  • 2
    Thanks! I haven't found the correct line in the main.qml file yet but this looks really promising! – JBGruber Aug 07 '19 at 16:21
  • 1
    More reading here: https://zren.github.io/kde/docs/widget/ – DK Bose Aug 09 '19 at 14:35
  • Thanks again! I'll have a look. I updated the question to reflect my progress on this. But this might be more work than it's worth. – JBGruber Aug 09 '19 at 15:27
  • Hmm... are you sure? I usually don't look at questions that already have an answer (I'm more active on a different site of StackExchange) that's why I thought it would make more sense to include it in the question for now until I have a proper answer. – JBGruber Aug 09 '19 at 15:47
  • 1
    @DKBose I solved it! Finally found the line I needed to change :) – JBGruber Aug 12 '19 at 17:15

2 Answers2

6

Just open systemsettings and choose "Desktop Behavior" -> "Virtual Desktops" and make it two Rows. The widget will adjust to half width and the four desktops will be shown in two rows as shown in the screenshot (it seems a little bit wide because I have 3 monitors).

You don't really need to modify the code. :)

KDE Virtual Desktops

jsalatas
  • 411
  • Thanks! You are right that the widget gets much smaller and I like how simple it is. But it changes the arrangement of the desktops which I don't like. – JBGruber Aug 12 '19 at 17:13
5

I figured it out with massive help from @DKBose!

Here are the steps

1. make backup of config file

sudo cp /usr/share/plasma/plasmoids/org.kde.plasma.pager/contents/ui/main.qml /usr/share/plasma/plasmoids/org.kde.plasma.pager/contents/ui/main.qml_backup

2. edit config using favourite editor (I simply use kate)

kate /usr/share/plasma/plasmoids/org.kde.plasma.pager/contents/ui/main.qml

3. Change the width of each desktop symbol (I simply add / 2 at the end of the line to get half the original width):

property int columnWidth: Math.floor(rowHeight * pagerItemSizeRatio) / 2

4. Change the minimum width of the whole widget (again just adding / 2, this time after aspectRatio):

Layout.minimumWidth: !root.vertical ? Math.floor(height * aspectRatio / 2) : 1

And here is the result:

enter image description here

(5.) In case anything goes wrong just copy the backup file back into location:

sudo cp /usr/share/plasma/plasmoids/org.kde.plasma.pager/contents/ui/main.qml_backup /usr/share/plasma/plasmoids/org.kde.plasma.pager/contents/ui/main.qml
JBGruber
  • 221
  • 1
    I did this, but made the applet twice as wide instead of half. I found I also needed to double the Layout.maximumWidth to prevent the pager applet from overlapping the applet to its right. – Mark Dominus Apr 02 '21 at 16:48
  • Thank you, it really helped – parsecer Apr 17 '21 at 17:33
  • I found when I connect the second monitor it takes the total width of both monitors in calculations (therefore the virtual desktops icons become x2 wider). So I had to change / 2 to / 4. However now if I disconnect the second monitor the icons on the remaining monitor resize and become too narrow. Is there a way to make that 2 / 4 coefficient dependent on the number of monitors being used? Automatically? – parsecer May 20 '21 at 20:39
  • I usually position my monitors on top of each other, so I never noticed. Maybe worth asking this as a question? – JBGruber May 21 '21 at 05:47
  • I also tested this widget and really like it so far: https://github.com/wsdfhjxc/virtual-desktop-bar Maybe I'll update the answer. – JBGruber May 21 '21 at 07:31