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.
- Remove the original Plank autostart desktop shortcut.
- Create Plank as a systemd service
- Use xeventbind to monitor resolution changes
- Launch Plank and xeventbind in a new Plank autostart shortcut.
Pre-setup
sudo apt update
sudo apt install libx11-dev make gcc
- Remove or rename plank.desktop
rm ~/.config/autostart/plank.desktop
#
mv ~/.config/autostart/plank.desktop ~/.config/autostart/plank.desktop.org
- 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
- Install xeventbind
git clone https://github.com/ritave/xeventbind.git
cd xeventbind
make
cp ./xeventbind /usr/bin/xeventbind
- 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