Skip to content

Commit

Permalink
hdrop: 0.5.3 -> 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Schweber authored and fufexan committed Sep 5, 2024
1 parent ae618ea commit 1e531dc
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### 2024-09-05

hdrop: add `--focus` option

### 2024-09-01

hdrop:
Expand Down
7 changes: 5 additions & 2 deletions hdrop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ This Bash script emulates the main features of [tdrop](https://github.com/noctui
> -f, --floating
> Spawn as a floating window. Standard is top half, full width, no gap. Can be adjusted with -g, -h, -p and -w.
>
> -F, --focus
> Changes the default behaviour: focus the specified program's window and switch to its present workspace if necessary. Do not hide it, if it's already on the current workspace."
>
> -g, --gap
> If using --floating: specify gap to the screen edge in pixels.
>
Expand Down Expand Up @@ -54,7 +57,7 @@ This Bash script emulates the main features of [tdrop](https://github.com/noctui

Multiple instances of the same program can be run concurrently, if different class names are assigned to each instance. Presently, there is support for the following flags in the [COMMAND] string:

> `-a` ([foot](https://codeberg.org/dnkl/foot/) terminal emulator)
> `-a` | `--app-id` ([foot](https://codeberg.org/dnkl/foot/) terminal emulator)
> `--class` (all other programs)
#### Example bindings in Hyprland config:
Expand Down Expand Up @@ -101,7 +104,7 @@ This is a known issue and no workaround is known to me.

If hdrop isn't installed but just added to PATH, then you might have to use this instead:

> exec-once = [workspace special:hdrop silent] hdrop [OPITONS] [COMMAND]
> exec-once = [workspace special:hdrop silent] hdrop [OPTIONS] [COMMAND]
## Installation

Expand Down
2 changes: 1 addition & 1 deletion hdrop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}:
stdenvNoCC.mkDerivation {
pname = "hdrop";
version = "0.5.3";
version = "0.6.0";

src = ./.;

Expand Down
29 changes: 22 additions & 7 deletions hdrop/hdrop
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ print_help() {
echo " Standard is top half, full width, no gap."
echo " Can be adjusted with -g, -h, -p and -w."
echo ""
echo " -F, --focus"
echo " Changes the default behaviour: focus the specified program's"
echo " window and switch to its present workspace if necessary."
echo " Do not hide it, if it's already on the current workspace."
echo ""
echo " -g, --gap"
echo " If using --floating: specify gap to the screen edge in pixels."
echo ""
Expand Down Expand Up @@ -68,7 +73,7 @@ print_help() {
}

print_version() {
echo "hdrop version: 0.5.3"
echo "hdrop version: 0.6.0"
}

notify() {
Expand Down Expand Up @@ -98,6 +103,9 @@ hdrop_flags() {
-f | --floating)
FLOATING=true
;;
-F | --focus)
FOCUS=true
;;
-g | --gap)
shift
GAP="$1"
Expand Down Expand Up @@ -135,6 +143,7 @@ hdrop_flags() {
}

BACKGROUND=""
FOCUS=false
GAP=0
INSENSITIVE=false
FLOATING=false
Expand Down Expand Up @@ -164,7 +173,7 @@ done
# shellcheck disable=SC2128 # erroneous warning
if [[ -n $HDROP_FLAGS ]]; then
# shellcheck disable=SC2046 # avoids having to run 'eval set -- "$HDROP_FLAGS"' to remove leading whitespace
hdrop_flags $(getopt -u --options bc:fg:h:Hip:vVw: --longoptions background,class:,floating,gap:,height:,help,insensitive,position:,verbose,version,width: -n hdrop -- "${HDROP_FLAGS[@]}")
hdrop_flags $(getopt -u --options bc:fFg:h:Hip:vVw: --longoptions background,class:,floating,focus,gap:,height:,help,insensitive,position:,verbose,version,width: -n hdrop -- "${HDROP_FLAGS[@]}")
fi

CLASS="$1"
Expand Down Expand Up @@ -263,13 +272,19 @@ if $FLOATING; then
fi

if [[ $(hyprctl clients -j | jq -r ".[] | select(.class==\"$CLASS\" and .workspace.id!=$ACTIVE_WORKSPACE)") ]]; then
# shellcheck disable=SC2140 # erroneous warning
hyprctl dispatch -- movetoworkspacesilent "$ACTIVE_WORKSPACE","^$CLASS$" || notify "hdrop: Error moving '$COMMANDLINE' to current workspace"
if [[ $FOCUS == false ]]; then
# shellcheck disable=SC2140 # erroneous warning
hyprctl dispatch -- movetoworkspacesilent "$ACTIVE_WORKSPACE","^$CLASS$" || notify "hdrop: Error moving '$COMMANDLINE' to current workspace"
if $VERBOSE; then notify_low "hdrop: Matched class '$CLASS' on another workspace and moved it to current workspace"; fi
fi
hyprctl dispatch -- focuswindow "^$CLASS$" || notify "hdrop: Error focusing '$COMMANDLINE' on current workspace"
if $VERBOSE; then notify_low "hdrop: Matched class '$CLASS' on another workspace and moved it to current workspace"; fi
elif [[ $(hyprctl clients -j | jq -r ".[] | select(.class==\"$CLASS\" and .workspace.id==$ACTIVE_WORKSPACE)") ]]; then
hyprctl dispatch -- movetoworkspacesilent special:hdrop,"^$CLASS$" || notify "hdrop: Error moving '$COMMANDLINE' to workspace 'special:hdrop'"
if $VERBOSE; then notify_low "hdrop: Matched class '$CLASS' on current workspace and moved it to workspace 'special:hdrop'"; fi
if [[ $FOCUS == false ]]; then
hyprctl dispatch -- movetoworkspacesilent special:hdrop,"^$CLASS$" || notify "hdrop: Error moving '$COMMANDLINE' to workspace 'special:hdrop'"
if $VERBOSE; then notify_low "hdrop: Matched class '$CLASS' on current workspace and moved it to workspace 'special:hdrop'"; fi
else
hyprctl dispatch -- focuswindow "^$CLASS$" || notify "hdrop: Error focusing '$COMMANDLINE' on current workspace"
fi
else
# 'foot' always throws an error when its window is closed. Thus we disable the notification.
if [[ $COMMAND == "foot" ]]; then
Expand Down
3 changes: 3 additions & 0 deletions hdrop/hdrop.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ hdrop - run, show and hide programs on Hyprland
*-f, --floating*
Spawn as a floating window. Standard is top half, full width, no gap. Can be adjusted with -g, -h, -p and -w.

*-F, --focus*
Changes the default behaviour: focus the specified program's window and switch to its present workspace if necessary. Do not hide it, if it's already on the current workspace."

*-g, --gap*
If using --floating: specify gap to the screen edge in pixels.

Expand Down

0 comments on commit 1e531dc

Please sign in to comment.