Enhancing Plank Dock’s Flexibility for Virtual Machines

Last Updated on December 29, 2023 by Freddy Reyes

As an avid user of virtual machines (VMs), I’ve often been slightly frustrated with the Plank dock’s static nature. Mainly, it cannot adjust when the VM window resizes or the resolution changes. The only workaround until now has been a somewhat clunky process of ending and restarting the Plank. But, I’m excited to share a neat solution I’ve devised for this issue.

Before diving into the solution, ensure your system has the necessary tools. Open your terminal and run:

sudo apt update 
sudo apt install libx11-dev make gcc

Tweaking the Autostart First things first, let’s deal with the original Plank autostart shortcut. You can rename it for backup:

mv ~/.config/autostart/plank.desktop ~/.config/autostart/plank.desktop.org

Setting Up Plank as a Systemd Service Create the necessary directories:

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

Then, create a new service file using vi or your preferred editor:

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

And add the following content:




Enable and start the service:

systemctl --user enable plank
pkill -f plank
systemctl --user start plank

Monitoring Resolution Changes with xeventbind Install xeventbind:

git clone https://github.com/ritave/xeventbind.git 
cd xeventbind 
cp ./xeventbind /usr/bin/xeventbind

Automating the Restart Create a script to restart Plank:


Add the script content:

systemctl --user restart plank

Make it executable:

chmod +x ~/bin/restart_plank.sh

Testing Change your resolution to test the setup:

/usr/bin/xeventbind resolution /home/{username}/.local/bin/restart_plank.sh

Finalizing the Autostart Edit the new Plank autostart shortcut:

And add:

vi ~/.config/autostart/plank.desktop
[Desktop Entry] Name=Plank 
Exec=/usr/bin/bash -c "systemctl --user start plank && /usr/bin/xeventbind resolution /home/{username}/.local/bin/restart_plank.sh" 
Type=Application X-GNOME-Autostart-enabled=true

Conclusion: With these steps, Plank should seamlessly restart and adjust whenever your VM window size or resolution changes. While not officially packaged, this solution significantly improves over the previous manual method.

Credit & Original Information Sources:

rbreaves @ https://discourse.ubuntubudgie.org/t/fix-plank-location-when-changing-resolution/5198