launch: mitigate on-created-empty race condition
Signed-off-by: Myned <dev@bjork.tech>
This commit is contained in:
parent
d9f5d3eb28
commit
f9377d7686
2 changed files with 15 additions and 2 deletions
|
@ -24,6 +24,8 @@ in {
|
||||||
|
|
||||||
config.home-manager.users.${config.custom.username} = mkIf cfg.enable {
|
config.home-manager.users.${config.custom.username} = mkIf cfg.enable {
|
||||||
wayland.windowManager.hyprland.settings = {
|
wayland.windowManager.hyprland.settings = {
|
||||||
|
# BUG: on-created-empty race condition with delayed windows
|
||||||
|
# https://github.com/hyprwm/Hyprland/issues/5663
|
||||||
# https://wiki.hyprland.org/Configuring/Workspace-Rules
|
# https://wiki.hyprland.org/Configuring/Workspace-Rules
|
||||||
#?? workspace = WORKSPACE, RULES
|
#?? workspace = WORKSPACE, RULES
|
||||||
workspace = [
|
workspace = [
|
||||||
|
@ -32,7 +34,7 @@ in {
|
||||||
"special:android, on-created-empty:${waydroid} app launch com.YoStarEN.Arknights"
|
"special:android, on-created-empty:${waydroid} app launch com.YoStarEN.Arknights"
|
||||||
"special:music, on-created-empty:${youtube-music}"
|
"special:music, on-created-empty:${youtube-music}"
|
||||||
"special:office, on-created-empty:[tile] ${onlyoffice}"
|
"special:office, on-created-empty:[tile] ${onlyoffice}"
|
||||||
"special:password, on-created-empty:${launch} --tile ${_1password}"
|
"special:password, on-created-empty:${launch} --empty --tile --workspace special:password ${_1password}"
|
||||||
"special:steam, on-created-empty:${steam}"
|
"special:steam, on-created-empty:${steam}"
|
||||||
"special:terminal, on-created-empty:${kitty}"
|
"special:terminal, on-created-empty:${kitty}"
|
||||||
"special:vm, on-created-empty:${pgrep} -x vm || ${virt-manager}"
|
"special:vm, on-created-empty:${pgrep} -x vm || ${virt-manager}"
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
# @option -W --workspace Move next window to workspace
|
# @option -W --workspace Move next window to workspace
|
||||||
# @flag -a --active Focus and raise next window (raise requires floating)
|
# @flag -a --active Focus and raise next window (raise requires floating)
|
||||||
# @flag -c --center Center next window (requires floating)
|
# @flag -c --center Center next window (requires floating)
|
||||||
|
# @flag -e --empty Only launch if workspace is empty (requires workspace)
|
||||||
# @flag -f --float Float next window
|
# @flag -f --float Float next window
|
||||||
# @flag -g --group Add next window to the active group
|
# @flag -g --group Add next window to the active group
|
||||||
# @flag -l --lock Lock next window's group
|
# @flag -l --lock Lock next window's group
|
||||||
|
@ -24,6 +25,16 @@
|
||||||
|
|
||||||
eval "$(argc --argc-eval "$0" "$@")"
|
eval "$(argc --argc-eval "$0" "$@")"
|
||||||
|
|
||||||
|
if [[ "${argc_empty:-}" ]]; then
|
||||||
|
# Delay to mitigate on-created-empty window race condition
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# Silently exit if window exists on specified workspace
|
||||||
|
if hyprctl -j clients | jq -r .[].workspace.name | grep "${argc_workspace:-}"; then
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Get initial count of open windows
|
# Get initial count of open windows
|
||||||
count="$(hyprctl -j clients | jq length)"
|
count="$(hyprctl -j clients | jq length)"
|
||||||
|
|
||||||
|
@ -40,7 +51,7 @@ while (("$(hyprctl -j clients | jq length)" <= "$count")); do
|
||||||
# Time out after 60 seconds
|
# Time out after 60 seconds
|
||||||
if (("$c" >= 60 * 10)); then
|
if (("$c" >= 60 * 10)); then
|
||||||
notify-send "> launch" "Polling timed out" --urgency critical
|
notify-send "> launch" "Polling timed out" --urgency critical
|
||||||
break
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 0.1
|
sleep 0.1
|
||||||
|
|
Loading…
Reference in a new issue