Skip to content

Commit

Permalink
hdrop: 0.2.1 -> 0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Schweber committed Dec 9, 2023
1 parent d2c35a1 commit 84df9a4
Show file tree
Hide file tree
Showing 6 changed files with 733 additions and 37 deletions.
661 changes: 661 additions & 0 deletions hdrop/LICENSE

Large diffs are not rendered by default.

Empty file modified hdrop/Makefile
100644 → 100755
Empty file.
71 changes: 52 additions & 19 deletions hdrop/README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,37 +1,70 @@
# hdrop

This script emulates the main features of
[tdrop](https://github.com/noctuid/tdrop) in Hyprland:
This Bash script emulates the main features of [tdrop](https://github.com/noctuid/tdrop) in Hyprland:

- if the specified program is not running: launch it and bring it to the
foreground.
- if the specified program is already running on another workspace: bring it to
the current workspace and focus it.
- if the specified program is already on the current workspace: move it to
workspace 'special:hdrop', thereby hiding it until called up again by hdrop.
- if the specified program is not running: launch it and bring it to the foreground.
- if the specified program is already running on another workspace: bring it to the current workspace and focus it.
- if the specified program is already on the current workspace: move it to workspace 'special:hdrop', thereby hiding it until called up again by hdrop.

#### Usage:

```console
hdrop [OPTIONS] [COMMAND]
```
> hdrop [OPTIONS] [COMMAND]
#### Arguments:

> `[COMMAND]`\
> [COMMAND]
> The usual command you would run to start the desired program
#### Options:

> `-b, --background`\
> changes the default behaviour: if the specified program is not running, launch
> it in the background instead of foreground. Thereafter 'hdrop -b' will work
> the same as without this flag.
> -b, --background
> changes the default behaviour: if the specified program is not running, launch it in the background instead of foreground. Thereafter 'hdrop -b' will work the same as without this flag.
>
> `-h, --help`\
> -h, --help
> Print this help message
>
> `-V, --version`\
> -V, --version
> Print version
See man page for further information.
#### Multiple instances:

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' terminal emulator)
> --class (all other programs).
#### Example bindings in Hyprland config:

> bind = $mainMod, b, exec, hdrop librewolf'
> bind = $mainMod, x, exec, hdrop kitty --class kitty_1'
> bind = $mainMod CTRL, x, exec, hdrop kitty --class kitty_2'
> bind = $mainMod, c, exec, hdrop foot -a foot_1'
> bind = $mainMod CTRL, c, exec, hdrop foot -a foot_2'
Note: defining a class name is only necessary when running several instances of the same program.

If you want to run a program on boot and have it wait in the background until called up by hdrop you can use this:

> exec-once = hdrop -b librewolf
Please feel free to report missing flags or peculiarities for other programs!

Dependencies: bash jq hyprland
Author: Schweber (https://github.com/Schweber/hdrop)
License: AGPL3

## Installation

### Repositories

[![Packaging status](https://repology.org/badge/vertical-allrepos/hdrop.svg)](https://repology.org/project/hdrop/versions)

### Manual

Make sure that `bash`, `jq` and `hyprland` are in your PATH.

Download the script, make it executable and add it to your PATH.

### hyprwm/contrib

`hdrop` is part of [hyprwm/contrib](https://github.com/hyprwm/contrib), which is a collection of useful scripts for `Hyprland`.
2 changes: 1 addition & 1 deletion hdrop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
}:
stdenvNoCC.mkDerivation {
pname = "hdrop";
version = "0.2.1";
version = "0.2.4";

src = ./.;

Expand Down
28 changes: 15 additions & 13 deletions hdrop/hdrop
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ print_help() {
echo ""
echo "Usage: hdrop [OPTIONS] [COMMAND]"
echo ""
echo "Arguments:"
echo " [COMMAND]"
echo "Command:"
echo " The usual command you would run to start the desired program"
echo ""
echo "Options:"
Expand Down Expand Up @@ -33,7 +32,7 @@ print_help() {
}

print_version() {
echo "hdrop version: 0.2.1"
echo "hdrop version: 0.2.4"
}

notify() {
Expand Down Expand Up @@ -69,12 +68,15 @@ esac

CLASS="$1"
COMMANDLINE="${*:1}"
ACTIVE_WORKSPACE="$(hyprctl activeworkspace -j | jq -r .id)" || notify "hdrop: error executing dependencies 'hyprctl' or 'jq'" "Check terminal output of 'hdrop $COMMANDLINE'"
ACTIVE_WORKSPACE="$(hyprctl activeworkspace -j | jq -r .id)" || notify "hdrop: Error executing dependencies 'hyprctl' or 'jq'" "Check terminal output of 'hdrop $COMMANDLINE'"

case "$1" in
foot)
OPT=$(getopt --options a: -n hdrop -- "$@")
;;
logseq)
CLASS="Logseq"
;;
telegram-desktop)
CLASS="org.telegram.desktop"
;;
Expand All @@ -85,15 +87,15 @@ esac

if [[ -n $OPT ]]; then
eval set -- "$OPT"
while true; do
case "$1" in
-a | --class)
CLASS="$2"
shift 2
;;
*) break ;;
esac
done
# while true; do
case "$1" in
-a | --class)
CLASS="$2"
# shift 2
;;
# *) break ;;
esac
# done
fi

if [[ $(hyprctl clients -j | jq -r ".[] | select(.class==\"$CLASS\" and .workspace.id!=$ACTIVE_WORKSPACE)") ]]; then
Expand Down
8 changes: 4 additions & 4 deletions hdrop/hdrop.1.scd
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ hdrop - run, show and hide programs on Hyprland
# OPTIONS

*[COMMAND]*
The usual command you would run to start the desired program
The usual command you would run to start the desired program

*-b, --background*
changes the default behaviour: if the specified program is not running, launch it in the background instead of foreground. Thereafter 'hdrop -b' will work the same as without this flag.
changes the default behaviour: if the specified program is not running, launch it in the background instead of foreground. Thereafter 'hdrop -b' will work the same as without this flag.

*-h, --help*
Print help message
Print help message

*-V, --version*
Print version
Print version

# Description

Expand Down

0 comments on commit 84df9a4

Please sign in to comment.