Skip to content

Instantly share code, notes, and snippets.

@jonathannerat
Last active October 19, 2019 20:22
Show Gist options
  • Select an option

  • Save jonathannerat/00996032fe6c41add8704c38d5b35174 to your computer and use it in GitHub Desktop.

Select an option

Save jonathannerat/00996032fe6c41add8704c38d5b35174 to your computer and use it in GitHub Desktop.

Revisions

  1. jonathannerat revised this gist Oct 19, 2019. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions plank_launch.sh
    Original file line number Diff line number Diff line change
    @@ -24,6 +24,6 @@ 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%.desktop}"
    gtk-launch ${FILE##*/}
    FILE="${LAUNCHER##*/}"
    gtk-launch ${FILE%.desktop}
    fi
  2. jonathannerat revised this gist Oct 19, 2019. 1 changed file with 13 additions and 2 deletions.
    15 changes: 13 additions & 2 deletions plank_launch.sh
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,16 @@
    #!/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"
    @@ -9,10 +21,9 @@ DCONF_KEY="/net/launchpad/plank/docks/dock1/dock-items"
    # 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%.desktop}"
    gtk-launch ${FILE##*/}
    else
    echo "There is no $1th item pinned in plank dock"
    fi
  3. jonathannerat created this gist Oct 19, 2019.
    18 changes: 18 additions & 0 deletions plank_launch.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    #!/bin/bash

    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[^']*"`

    if [ ! -z "$DOCKITEM" ]; then
    LAUNCHER=`grep -Po "Launcher=file://\K.*\.desktop" "$ITEMS_DIR/$DOCKITEM"`
    FILE="${LAUNCHER%.desktop}"
    gtk-launch ${FILE##*/}
    else
    echo "There is no $1th item pinned in plank dock"
    fi