Skip to content

Instantly share code, notes, and snippets.

@notanimposter
Created March 13, 2020 18:17
Show Gist options
  • Save notanimposter/952ec7aefad1825ee9a30cbbbc4a6453 to your computer and use it in GitHub Desktop.
Save notanimposter/952ec7aefad1825ee9a30cbbbc4a6453 to your computer and use it in GitHub Desktop.
make a second plank for your second monitor
#!/bin/bash
plank -n dock2 &
kill $!
printf "Monitor: "
read monitor
echo "Using $monitor as monitor"
gsettings reset-recursively net.launchpad.plank.dock.settings:/net/launchpad/plank/docks/dock2/
for key in $(gsettings list-keys net.launchpad.plank.dock.settings:/net/launchpad/plank/docks/dock1/); do
val=$(gsettings get net.launchpad.plank.dock.settings:/net/launchpad/plank/docks/dock1/ $key)
gsettings set net.launchpad.plank.dock.settings:/net/launchpad/plank/docks/dock2/ $key "$val"
done
gsettings set net.launchpad.plank.dock.settings:/net/launchpad/plank/docks/dock2/ monitor $monitor
mkdir -p $HOME/.config/plank/dock2/
rm -rf $HOME/.config/plank/dock2/launchers
ln -s $HOME/.config/plank/dock1/launchers $HOME/.config/plank/dock2/launchers
killall plank
@angela-d
Copy link

angela-d commented Mar 6, 2021

Thanks for sharing, this is super useful!

If anyone reading this wants the script to auto-detect the non-primary monitor, replace:

printf "Monitor: "
read monitor

with:

# get the non-primary monitor
monitor=$(xrandr | grep " connected" | awk '$3 !="primary" { print $1 }')

(if you have more than 2 monitors, you might need to do a loop, instead)

The only thing this script didn't do, was set dock2 as enabled. You can pull the current array (as long as you have at least dock1) and simply append to it, without disturbing other docks, by adding this after gsettings set net.launchpad.plank.dock.settings:/net/launchpad/plank/docks/dock2/ monitor $monitor :

current=$(gsettings get net.launchpad.plank enabled-docks)
append=$(echo $current | sed "s@dock1@dock1','dock2@g")
gsettings set net.launchpad.plank enabled-docks "$append"

@henrygermany
Copy link

Thanks for this, was exactly what I needed. Also thanks @angela-d, your modifications worked spot on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment