mirror of
https://github.com/winapps-org/winapps.git
synced 2025-08-01 16:36:39 +02:00
Merge branch 'main' of github.com:winapps-org/winapps
This commit is contained in:
16
README.md
16
README.md
@@ -469,6 +469,11 @@ RDP_TIMEOUT="30"
|
||||
# DEFAULT VALUE: '60'
|
||||
APP_SCAN_TIMEOUT="60"
|
||||
|
||||
# WINDOWS BOOT
|
||||
# - The maximum time (in seconds) to wait for the Windows VM to boot if it is not running, before attempting to launch an application.
|
||||
# DEFAULT VALUE: '120'
|
||||
BOOT_TIMEOUT="120"
|
||||
|
||||
```
|
||||
|
||||
> [!IMPORTANT]
|
||||
@@ -484,6 +489,7 @@ APP_SCAN_TIMEOUT="60"
|
||||
- On high-resolution (UHD) displays, you can set `RDP_SCALE` to the scale you would like to use (100, 140 or 180).
|
||||
- To add additional flags to the FreeRDP call (e.g. `/prevent-session-lock 120`), uncomment and use the `RDP_FLAGS` configuration option.
|
||||
- For multi-monitor setups, you can try adding `/multimon` to `RDP_FLAGS`. A FreeRDP bug may result in a black screen however, in which case you should revert this change.
|
||||
- To enable non-English input and seamless language switching, you can try adding `/kbd:unicode` to `RDP_FLAGS`. This ensures client inputs are sent as Unicode sequences.
|
||||
- If you enable `DEBUG`, a log will be created on each application start in `~/.local/share/winapps/winapps.log`.
|
||||
- If using a system on which the FreeRDP command is not `xfreerdp` or `xfreerdp3`, the correct command can be specified using `FREERDP_COMMAND`.
|
||||
|
||||
@@ -589,10 +595,6 @@ First, make sure Flakes and the `nix` command are enabled.
|
||||
In your `~/.config/nix/nix.conf`:
|
||||
```
|
||||
experimental-features = nix-command flakes
|
||||
# specify to use binary cache (optional)
|
||||
extra-substituters = https://cache.garnix.io/
|
||||
extra-trusted-public-keys = cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=
|
||||
extra-trusted-users = <your-username> # replace with your username
|
||||
```
|
||||
|
||||
```bash
|
||||
@@ -639,12 +641,6 @@ nix profile install github:winapps-org/winapps#winapps-launcher # optional
|
||||
...
|
||||
}:
|
||||
{
|
||||
# set up binary cache (optional)
|
||||
nix.settings = {
|
||||
substituters = [ "https://cache.garnix.io/" ];
|
||||
trusted-public-keys = [ "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ];
|
||||
};
|
||||
|
||||
environment.systemPackages = [
|
||||
winapps.packages."${system}".winapps
|
||||
winapps.packages."${system}".winapps-launcher # optional
|
||||
|
89
bin/winapps
89
bin/winapps
@@ -50,9 +50,11 @@ RDP_SCALE=100
|
||||
AUTOPAUSE="off"
|
||||
AUTOPAUSE_TIME="300"
|
||||
DEBUG="true"
|
||||
BOOT_TIMEOUT=120
|
||||
|
||||
# OTHER
|
||||
FREERDP_PID=-1
|
||||
NEEDED_BOOT=false
|
||||
|
||||
### TRAPS ###
|
||||
# Catch SIGINT (CTRL+C) to call 'waCleanUp'.
|
||||
@@ -323,6 +325,7 @@ function waCheckVMRunning() {
|
||||
if (virsh list --state-shutoff --name | xargs | grep -wq "$VM_NAME"); then
|
||||
dprint "WINDOWS SHUT OFF. BOOTING WINDOWS."
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Booting Windows."
|
||||
NEEDED_BOOT=true
|
||||
virsh start "$VM_NAME" &>/dev/null || EXIT_STATUS=$EC_FAIL_START
|
||||
if (virsh list --state-paused --name | xargs | grep -wq "$VM_NAME"); then
|
||||
dprint "WINDOWS PAUSED. RESUMING WINDOWS."
|
||||
@@ -344,6 +347,7 @@ function waCheckVMRunning() {
|
||||
dprint "WINDOWS SHUT OFF. BOOTING WINDOWS."
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Booting Windows."
|
||||
virsh start "$VM_NAME" &>/dev/null || EXIT_STATUS=$EC_FAIL_START
|
||||
NEEDED_BOOT=true
|
||||
break
|
||||
fi
|
||||
sleep $TIME_INTERVAL
|
||||
@@ -357,6 +361,7 @@ function waCheckVMRunning() {
|
||||
dprint "WINDOWS DESTROYED. BOOTING WINDOWS."
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Booting Windows."
|
||||
virsh start "$VM_NAME" &>/dev/null || EXIT_STATUS=$EC_FAIL_START
|
||||
NEEDED_BOOT=true
|
||||
fi
|
||||
elif (virsh domstate "$VM_NAME" | xargs | grep -wq "dying"); then
|
||||
dprint "WINDOWS DYING. WAITING."
|
||||
@@ -372,6 +377,7 @@ function waCheckVMRunning() {
|
||||
dprint "WINDOWS DESTROYED. BOOTING WINDOWS."
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Booting Windows."
|
||||
virsh start "$VM_NAME" &>/dev/null || EXIT_STATUS=$EC_FAIL_START
|
||||
NEEDED_BOOT=true
|
||||
fi
|
||||
break
|
||||
elif (virsh list --state-shutoff --name | xargs | grep -wq "$VM_NAME"); then
|
||||
@@ -379,6 +385,7 @@ function waCheckVMRunning() {
|
||||
dprint "WINDOWS SHUT OFF. BOOTING WINDOWS."
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Booting Windows."
|
||||
virsh start "$VM_NAME" &>/dev/null || EXIT_STATUS=$EC_FAIL_START
|
||||
NEEDED_BOOT=true
|
||||
break
|
||||
fi
|
||||
sleep $TIME_INTERVAL
|
||||
@@ -395,6 +402,45 @@ function waCheckVMRunning() {
|
||||
|
||||
# Handle non-zero exit statuses.
|
||||
[ "$EXIT_STATUS" -ne 0 ] && waThrowExit "$EXIT_STATUS"
|
||||
|
||||
# Wait for VM to be fully ready
|
||||
if [[ "$NEEDED_BOOT" == "true" ]]; then
|
||||
dprint "WAITING FOR VM TO BE FULLY READY..."
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Waiting for Windows to be ready..."
|
||||
|
||||
TIME_ELAPSED=0
|
||||
|
||||
while (( TIME_ELAPSED < BOOT_TIMEOUT )); do
|
||||
# Check if VM is running
|
||||
if (virsh list --state-running --name | xargs | grep -wq "$VM_NAME"); then
|
||||
# Try to connect to RDP port to verify it's ready
|
||||
if timeout 1 bash -c ">/dev/tcp/$RDP_IP/$RDP_PORT" 2>/dev/null; then
|
||||
dprint "VM IS READY"
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Windows is ready."
|
||||
# Add a delay after Windows is ready
|
||||
if [ "$NEEDED_BOOT" = "true" ]; then
|
||||
sleep 10
|
||||
fi
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 5
|
||||
TIME_ELAPSED=$((TIME_ELAPSED + 5))
|
||||
|
||||
# Show progress every 30 seconds
|
||||
if (( TIME_ELAPSED % 30 == 0 )); then
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Still waiting for Windows to be ready... ($TIME_ELAPSED seconds elapsed)"
|
||||
fi
|
||||
done
|
||||
|
||||
# If we timed out waiting for the VM
|
||||
if (( TIME_ELAPSED >= BOOT_TIMEOUT )); then
|
||||
dprint "TIMEOUT WAITING FOR VM TO BE READY"
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Timeout waiting for Windows to be ready. Please try again."
|
||||
waThrowExit $EC_FAIL_START
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Name: 'waCheckContainerRunning'
|
||||
@@ -426,6 +472,7 @@ function waCheckContainerRunning() {
|
||||
dprint "WINDOWS CREATED. BOOTING WINDOWS."
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Booting Windows."
|
||||
$COMPOSE_COMMAND --file "$COMPOSE_PATH" start &>/dev/null
|
||||
NEEDED_BOOT=true
|
||||
;;
|
||||
"restarting")
|
||||
dprint "WINDOWS RESTARTING. WAITING."
|
||||
@@ -436,6 +483,7 @@ function waCheckContainerRunning() {
|
||||
EXIT_STATUS=0
|
||||
dprint "WINDOWS RESTARTED."
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Restarted Windows."
|
||||
NEEDED_BOOT=true
|
||||
break
|
||||
fi
|
||||
sleep $TIME_INTERVAL
|
||||
@@ -451,11 +499,13 @@ function waCheckContainerRunning() {
|
||||
dprint "WINDOWS SHUT OFF. BOOTING WINDOWS."
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Booting Windows."
|
||||
$COMPOSE_COMMAND --file "$COMPOSE_PATH" start &>/dev/null
|
||||
NEEDED_BOOT=true
|
||||
;;
|
||||
"dead")
|
||||
dprint "WINDOWS DEAD. RECREATING WINDOWS CONTAINER."
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Re-creating and booting Windows."
|
||||
$COMPOSE_COMMAND --file "$COMPOSE_PATH" down &>/dev/null && $COMPOSE_COMMAND --file "$COMPOSE_PATH" up -d &>/dev/null
|
||||
NEEDED_BOOT=true
|
||||
;;
|
||||
"unknown")
|
||||
EXIT_STATUS=$EC_UNKNOWN
|
||||
@@ -464,6 +514,45 @@ function waCheckContainerRunning() {
|
||||
|
||||
# Handle non-zero exit statuses.
|
||||
[ "$EXIT_STATUS" -ne 0 ] && waThrowExit "$EXIT_STATUS"
|
||||
|
||||
# Wait for container to be fully ready
|
||||
if [[ "$CONTAINER_STATE" == "created" || "$CONTAINER_STATE" == "exited" || "$CONTAINER_STATE" == "dead" || "$CONTAINER_STATE" == "restarting" ]]; then
|
||||
dprint "WAITING FOR CONTAINER TO BE FULLY READY..."
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Waiting for Windows to be ready..."
|
||||
|
||||
TIME_ELAPSED=0
|
||||
|
||||
while (( TIME_ELAPSED < BOOT_TIMEOUT )); do
|
||||
# Check if container is running
|
||||
if [[ $("$WAFLAVOR" inspect --format='{{.State.Status}}' "$CONTAINER_NAME") == "running" ]]; then
|
||||
# Try to connect to RDP port to verify it's ready
|
||||
if timeout 1 bash -c ">/dev/tcp/$RDP_IP/$RDP_PORT" 2>/dev/null; then
|
||||
dprint "CONTAINER IS READY"
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Windows is ready."
|
||||
# Add a delay after Windows is ready
|
||||
if [ "$NEEDED_BOOT" = "true" ]; then
|
||||
sleep 10
|
||||
fi
|
||||
break
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 5
|
||||
TIME_ELAPSED=$((TIME_ELAPSED + 5))
|
||||
|
||||
# Show progress every 30 seconds
|
||||
if (( TIME_ELAPSED % 30 == 0 )); then
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Still waiting for Windows to be ready... ($TIME_ELAPSED seconds elapsed)"
|
||||
fi
|
||||
done
|
||||
|
||||
# If we timed out waiting for the container
|
||||
if (( TIME_ELAPSED >= BOOT_TIMEOUT )); then
|
||||
dprint "TIMEOUT WAITING FOR CONTAINER TO BE READY"
|
||||
notify-send --expire-time=4000 --icon="dialog-info" --app-name="WinApps" --urgency="low" "WinApps" "Timeout waiting for Windows to be ready. Please try again."
|
||||
waThrowExit $EC_FAIL_START
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Name: 'waCheckPortOpen'
|
||||
|
Reference in New Issue
Block a user