# start waybar and programs with tray icons after pause

waybar_loop() {
  # restart waybar on crash (after suspend mode)
  WAYBAR_RESTARTS=0
  while [ $WAYBAR_RESTARTS != 6 ]; do # limited to 5 restars
    pgrep Hyprland || break # exit if Hyprland is not running
    waybar
    let WAYBAR_RESTARTS++
    notify-send -a "start-in-tray.sh" "Waybar crashed!"
    sleep 1
  done
}

# wait for xdg-desktop-portal-hyprland to start
until pgrep -f 'xdg-desktop-portal-hyprland'; do sleep 2; done

waybar_loop &

sleep 1 # wait for waybar

nm-applet --indicator &
blueman-applet &
dunst &
# /run/current-system/sw/bin/input-remapper-control --config-dir /home/wayne/.config/input-remapper-2/ --device 'Hanvon Ugee Shortcut Remote' --preset 'Browsers' &
# /run/current-system/sw/bin/input-remapper-control --config-dir /home/wayne/.config/input-remapper-2/ --device 'MX MCHNCL Keyboard' --preset 'Layer_1' &
# /run/current-system/sw/bin/input-remapper-control --config-dir /home/wayne/.config/input-remapper-2/ --device 'SINO WEALTH Bluetooth Keyboard' --preset 'Layer_1' &
/nix/store/104jb5a21d1d338zkl1f07si6brsmrk2-keybase-gui-6.2.4/bin/keybase-gui %u &

# hyprctl notify -1 10000 "rgb(ff1ea3)" "Launching NextCloud!"
# /home/wayne/.nix-profile/bin/nextcloud --background &
# hyprctl notify -1 10000 "rgb(ff1ea3)" "Launching KeyBase-GUI!"
# /home/wayne/.nix-profile/bin/keybase && /home/wayne/.nix-profile/bin/kbfsfuse &


hyprctl dispatch workspace 1