noctuid / tdrop

A Glorified WM-Independent Dropdown Creator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Working Solution for hyprland

Schweber opened this issue · comments

Hi,

i have a working solution for hyprland, jq is required. I'm not good at bash and it can certainly be improved but the important parts are at the bottom. Feel free to use it if you like, i wasn't willing to use hyprland until i could emulate tdrop behaviour ;-) Multiple instances of the same program have to be differenciated by giving them different class names e.g. kitty --class kitty_1 and kitty --class kitty_2.

#!/usr/bin/env bash

commandline="${*:1}"
CLASS="$1"
ACTIVE_WORKSPACE="$(hyprctl activeworkspace -j | jq -r .id)"

TEMP=$(getopt -q --longoptions class: -n 'hdrop' -- "$@")
eval set -- "$TEMP"

while true; do
  case "$1" in
  --class)
    CLASS="$2"
    shift 2
    ;;
  --)
    shift
    break
    ;;
  *) break ;;
  esac
done

if [[ $(hyprctl clients -j | jq -r ".[] | select(.class==\"$CLASS\" and .workspace.id!=$ACTIVE_WORKSPACE)") ]]; then
  hyprctl dispatch -- movetoworkspacesilent $ACTIVE_WORKSPACE,"$CLASS"
  hyprctl dispatch -- focuswindow "$CLASS"
elif [[ $(hyprctl clients -j | jq -r ".[] | select(.class==\"$CLASS\" and .workspace.id==$ACTIVE_WORKSPACE)") ]]; then
  hyprctl dispatch -- movetoworkspacesilent special,"$CLASS"
else
  hyprctl dispatch -- exec $commandline
fi