r/hyprland•
Jojos_BA

Difference between in-config sh -c "..." and call for external script execution

QUESTION
Why does the following work:

```hyprlang
bind = $mainMod SHIFT, RETURN, exec, ~/bin/LaunchTerm.sh
```

```Bash
#!/bin/bash

# Check if the launcher is already running
if pgrep -f "ghostty --class=app.launcher" >/dev/null 2>&1; then
    # If running, kill it
    pkill -f "ghostty --class=app.launcher"
else
    # If not running, launch it
    hyprctl dispatch exec "ghostty --class=app.launcher --background-opacity=1"
fi
```
 
but this doesnt:
```hyprlang
bind = $mainMod SHIFT, I, exec, bash -c 'pgrep -f "ghostty --class=app.launcher" >/dev/null 2>&1 && pkill -f "ghostty --class=app.launcher" || hyprctl dispatch exec "ghostty --class=app.launcher --background-opacity=1"'
```

a simpler working example is:
```hyprlang
bind = $mainMod, Y, exec, pgrep wofi >/dev/null 2>&1 && killall wofi || wofi
```

Posted Nov 14, 2025, 6:57 PM UTC

311
Loading comments…