Files
dotfiles/files/workspace-run.sh
T
Pierre MARTINandClaude Opus 5.5 967a31d574 feat(hyprland): session Hyprland en test à côté d'i3
- Hyprland via UWSM (comme Omarchy), à choisir à la connexion ;
  i3 reste la session par défaut
- config Lua (format Hyprland >= 0.55) : raccourcis bépo d'i3,
  apparence Omarchy, Ghostty comme terminal
- waybar, hyprlock, swaybg, grim/slurp, wl-clipboard, brightnessctl
- workspace-run : support de hyprctl et des options en --opt=
- stt-dictate : wtype sous Wayland au lieu de xdotool

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 01:33:19 +02:00

57 lines
1.5 KiB
Bash

#!/usr/bin/env bash
# Usage: workspace-run.sh <command> [args...] -- dir is appended as last argument
# Examples:
# workspace-run.sh zeditor
# workspace-run.sh sakura --working-directory
# workspace-run.sh ghostty --working-directory= (un argument finissant par = est collé au dossier)
cmd=${1:?usage: workspace-run.sh <command> [args...]}
shift
if [ -n "${HYPRLAND_INSTANCE_SIGNATURE:-}" ]; then
workspace=$(hyprctl activeworkspace -j | jq -r '.name')
else
workspace=$(i3-msg -t get_workspaces | jq -r '.[] | select(.focused) | .name')
fi
window_pids() {
if [ -n "${HYPRLAND_INSTANCE_SIGNATURE:-}" ]; then
hyprctl clients -j | jq -r --arg ws "$workspace" '.[] | select(.workspace.name == $ws) | .pid'
return
fi
local wids
wids=$(i3-msg -t get_tree | jq -r "
.nodes[].nodes[].nodes[]
| select(.name == \"$workspace\")
| .. | objects | select(.window? != null) | .window
")
for wid in $wids; do
xdotool getwindowpid "$wid" 2>/dev/null
done
}
terminal_cwd() {
for pid in $(window_pids); do
local shell_pid
shell_pid=$(pgrep -P "$pid" -x zsh | head -1) || continue
local cwd
cwd=$(readlink "/proc/$shell_pid/cwd" 2>/dev/null) || continue
echo "$cwd"
return
done
}
dir=$(terminal_cwd)
if [ -z "$dir" ]; then
dir_file="$HOME/.config/i3/workspace-dirs"
dir=$(grep "^${workspace}=" "$dir_file" 2>/dev/null | cut -d= -f2-)
fi
dir=${dir:-$HOME}
if [ $# -gt 0 ] && [[ "${!#}" == *= ]]; then
set -- "${@:1:$#-1}" "${!#}$dir"
exec "$cmd" "$@"
fi
exec "$cmd" "$@" "$dir"