diff --git a/toggle-gdctl-scale b/toggle-gdctl-scale index 638038c..58b6645 100755 --- a/toggle-gdctl-scale +++ b/toggle-gdctl-scale @@ -1,17 +1,25 @@ #!/bin/bash +# -----------------------------------------------------------------------------# +# Display Scale Toggling Script for GNOME RDP Session. +# -----------------------------------------------------------------------------# -# Check if gnome-shell is running as `gdctl` is GNOME only +# Only for GNOME shell. if ! pgrep -x "gnome-shell" > /dev/null; then echo "Error: gnome-shell is not running." - return 1 + exit 1 fi -# Set scale explicitly to argument value. +# Only for remote session. +if ! gdctl show | grep -q "Meta-0"; then + echo "Could not find monitor Meta-0, seems not a remote session." + exit 2 +fi + +# Explicit scale. if [ $# -eq 1 ]; then - # gdctl set -LM Meta-0 --primary --scale $1 SCALE=$1 else - # If no argument is given, toggle between 1.0 and 1.5 scales. + # Toggle if not specified. if gdctl show | grep -q "Scale: 1.0"; then #gdctl set -LM Meta-0 --primary --scale 1.5 SCALE=1.5 @@ -21,6 +29,8 @@ else fi fi -# Apply and output. +# Apply gdctl set -LM Meta-0 --primary --scale $SCALE + +# Print output for the check-command. printf "Setting display scale to: $SCALE\n"