Fix Plank Location when Changing Resolution

So I was getting annoyed that the Plank dock does not relocate itself when your VM window resizes or resolution changes. You have to end it and then restart it. Well I have found a decent way to implement a fix for this. Not sure if @fossfreedom will want to try and package this as a fix or wait for the Plank authors to implement a better fix altogether.

Here is an overview of what I strung together though.

  1. Remove the original Plank autostart desktop shortcut.
  2. Create Plank as a systemd service
  3. Use xeventbind to monitor resolution changes
  4. Launch Plank and xeventbind in a new Plank autostart shortcut.

Pre-setup

sudo apt update
sudo apt install libx11-dev make gcc

  1. Remove or rename plank.desktop
rm ~/.config/autostart/plank.desktop
#
mv ~/.config/autostart/plank.desktop ~/.config/autostart/plank.desktop.org
  1. Plank as a Systemd service

mkdir -p ~/.config/systemd
mkdir -p ~/.config/systemd/user

vi ~/.config/systemd/user/plank.service

[Unit]
Description=Plank

[Service]
ExecStart=/usr/bin/plank
KillMode=process
RestartSec=3
Restart=always

[Install]
WantedBy=multi-user.target

systemctl --user enable plank
# Kill plank if it is running
pkill -f plank
systemctl --user start plank

  1. Install xeventbind
git clone https://github.com/ritave/xeventbind.git
cd xeventbind
make
cp ./xeventbind /usr/bin/xeventbind
  1. Setup new autostart launcher and script to trigger.

mkdir -p ~/bin
vi ~/bin/restart_plank.sh

#!/bin/bash
systemctl --user restart plank

chmod +x ~/bin/restart_plank.sh

Test it - change your resolution

/usr/bin/xeventbind resolution ~/bin/restart_plank.sh

vi ~/.config/autostart/plank.desktop

[Desktop Entry]
Name=Plank
GenericName=Plank
Comment=Plank
Exec=/usr/bin/bash -c "systemctl --user start plank && /usr/bin/xeventbind resolution /home/{username}/bin/restart_plank.sh"
Terminal=false
Type=Application
X-GNOME-Autostart-enabled=true

https://launchpad.net/ubuntu/+source/plank

If you look at the changelog for 21.04 and 21.10 it sounds like debian has included a relevant patch that maybe messing up here.

Might be worth removing this patch and seeing what happens in a vm

1 Like

Thanks I did not notice this.

ok - the utility does look very small.

If this was ported to run with Vala then we could incorporate this into budgie-extras-daemon (budgie-extras/budgie-extras-daemon at master · UbuntuBudgie/budgie-extras · GitHub)

The idea would be simply to “kill plank; sleep 1 && plank &” on a resolution change.

That way we would have a generic solution specifically for budgie on debian/ubuntu & other distros using budgie-extras.

1 Like

Thanks for pointing me in that direction. Tempted to start digging right now, but I probably won’t be able to look at forking extras until about a week from now. I did mention this issue on their launchpad issues page and have confirmed that I am running the latest -3 minor build so yea… no reason why that patch shouldn’t have worked other than it simply not working.

Wonder if this issue is only on 21.04 or pre-existed, I am not sure.

Has there been a solution to this yet? When i flip my tablet over to portrait mode the dock location gets screwed up.

Sort of. Debian MATE added a patch to the plank package to fix resolution issues. This messes up other desktops like budgie.

The patch debian holds with its package needs reworking.

For your use-case, i would suggest using a different layout that doesnt involve plank … i.e. by adding the icon-tasklist-applet to the panel.

Alternatively if you want to use a dock, use an alternative. Maybe latte-dock or something similar.

i looked in budgie extras but couldn’t find icon-tasklist-applet. how would i go about installing that?

Thats preinstalled.

Just open budgie desktop settings … click on the panel on the left side of the windows. Click the + button on the right side to add applets to your panel.

ok, i see that’s pretty cool, a little bit more like windows i guess. how do i now disable plank?

Just remove plank from budgie desktop settings autostart section.

1 Like

thanks! sorry one last question here… how do i remove apps from the task-bar-list? i don’t want firefox or budgie welcome menu in there.

Various right click options exist on each icon. One of these unpin’s … forgotten which one off the top of my head.

ok figured it out, you need to open the program and then star it or unstar it.

A simple work around for plank when changing resolution is to open the terminal and enter killall plank and restart the app from the menu. If you want to disable plank, creating a second panel in dock mode with an icon task installed works very well.

I can say that this issue is still active.

yeah - assuming I can find the time I intend to fix this for 23.04 then possibly backporting sometime after its release date.

1 Like

Ok - this has now completed backporting activities - it has been resolved in 23.04 and backported to 22.04.

Usual updates apply to pick up the revised plank package.