Last active
October 19, 2019 20:22
-
-
Save jonathannerat/00996032fe6c41add8704c38d5b35174 to your computer and use it in GitHub Desktop.
Launch Plank pinned items
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Launch Plank pinned items | |
| # | |
| # receives a number and launches the corresponding pinned item in your plank dock | |
| # | |
| # Relies on gtk-launch to launch the .desktop file, which needs to be located | |
| # in /usr/share/applications or $HOME/.local/share/applications | |
| # | |
| # You can use it to simulate the Meta+<Number> shortcut in Windows. To do this, | |
| # create a shortcut for Win+1, Win+2, ..., Win+9, Win+0, with each of them executing | |
| # ./plank_launch.sh <n - 1> (./plank_launch.sh 9 for Win+0) | |
| # This will try to start the n-th app in your dock, if it's present, and do nothing | |
| # if it isn't. | |
| ITEMS_DIR="$HOME/.config/plank/dock1/launchers" | |
| DCONF_KEY="/net/launchpad/plank/docks/dock1/dock-items" | |
| # $1: item number, starts at 0 | |
| [ -z "$1" ] && echo "Supply a number to launch plank item" && exit | |
| # selects $1-th dockitem from key | |
| DOCKITEM=`dconf read $DCONF_KEY | grep -Po "^\[('[^']*', ){$1}'\K[^']*"` | |
| # only try to launch if an item was found | |
| if [ ! -z "$DOCKITEM" ]; then | |
| LAUNCHER=`grep -Po "Launcher=file://\K.*\.desktop" "$ITEMS_DIR/$DOCKITEM"` | |
| FILE="${LAUNCHER##*/}" | |
| gtk-launch ${FILE%.desktop} | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment