11# !/usr/bin/env fish
22
3+ function notify -a message
4+ notify-send --icon windows --app-name Windows Windows " $message "
5+ echo " $message "
6+ end
7+
38function win_start
49 # Check if container is already running
510 if docker ps --format ' {{.Names}}' | grep -q ' ^windows$'
611 return 0
712 end
813
14+ set -l startup_file ~/.cache/win_starting
15+
916 # Container not running, start it
10- echo " Starting windows..."
17+ notify " Starting windows..."
18+ touch $startup_file
1119 docker start windows
1220
1321 # Follow logs and wait for success message (with timeout)
@@ -31,10 +39,12 @@ function win_start
3139
3240 if test $found -eq 1
3341 sleep 2
34- echo " Windows started."
42+ notify " Windows started."
43+ rm -f $startup_file
3544 return 0
3645 else
37- echo " Timeout waiting for Windows to start"
46+ notify " Timeout waiting for Windows to start"
47+ rm -f $startup_file
3848 return 1
3949 end
4050end
@@ -45,6 +55,14 @@ function win_autostop
4555 return 0
4656 end
4757
58+ set -l startup_file ~/.cache/win_starting
59+
60+ # Don't autostop during startup
61+ if test -f $startup_file
62+ echo " Windows is starting up, skipping autostop check."
63+ return 0
64+ end
65+
4866 set -l state_file ~/.cache/win_last_active
4967
5068 # Check for active xfreerdp processes
@@ -72,7 +90,7 @@ function win_autostop
7290end
7391
7492function win_stop
75- echo " Stopping windows..."
93+ notify " Stopping windows..."
7694 pkill xfreerdp3 2> /dev/null
7795 docker stop windows
7896end
@@ -90,7 +108,7 @@ function win_app -a app_path
90108 or return 1
91109
92110 if test -z " $WIN_USER " -o -z " $WIN_PASS "
93- echo " Error: WIN_USER and WIN_PASS environment variables must be set!"
111+ notify " Error: WIN_USER and WIN_PASS environment variables must be set!"
94112 return 1
95113 end
96114
@@ -106,8 +124,9 @@ function win_app -a app_path
106124 set -f wm_class "win-$app_name "
107125 set -f app_args "/app:program:$app_path ,name:$app_name "
108126 set -f hide_windows true
127+ notify "Launching Windows app $app_name "
109128 else
110- # set -f app_args "+f "
129+ notify "Launching Windows desktop "
111130 end
112131
113132 # Check if window already exists and focus it
@@ -142,7 +161,7 @@ function win_app -a app_path
142161
143162 # Check if xfreerdp crashed
144163 if not kill -0 $xfreerdp_pid 2>/dev/null
145- echo "Error: xfreerdp3 crashed during startup!"
164+ notify "Error: xfreerdp3 crashed during startup!"
146165 echo "Log output:"
147166 cat $logfile
148167 rm -f $logfile
@@ -170,7 +189,7 @@ function win_app -a app_path
170189 end
171190 end
172191 cat $logfile
173- echo "Error: Failed to detect window!"
192+ notify "Error: Failed to detect window!"
174193 rm -f $logfile
175194 return 1
176195end
0 commit comments