aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2024-06-19 15:01:10 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2024-06-19 22:57:57 +0200
commit0b74a97428ab694446263bc13d6dbbd0ad2ccadc (patch)
tree88ad1965b4dfffa9c78c8a84ba41e49395484f24
parentd9736d7141f5173ab7f07d2d1813b58400575c13 (diff)
downloadarctica-greeter-0b74a97428ab694446263bc13d6dbbd0ad2ccadc.tar.gz
arctica-greeter-0b74a97428ab694446263bc13d6dbbd0ad2ccadc.tar.bz2
arctica-greeter-0b74a97428ab694446263bc13d6dbbd0ad2ccadc.zip
arctica-greeter-check-hidpi: Don't fail if no DISPLAY variable is set, silently return scaling factor 1.
This also includes a typo fix of a variable name.
-rwxr-xr-xarctica-greeter-check-hidpi41
1 files changed, 21 insertions, 20 deletions
diff --git a/arctica-greeter-check-hidpi b/arctica-greeter-check-hidpi
index 8674300..980dd21 100755
--- a/arctica-greeter-check-hidpi
+++ b/arctica-greeter-check-hidpi
@@ -29,29 +29,30 @@ def get_window_scale():
window_scale = 1
try:
display = Gdk.Display.get_default()
- monitor = display.get_primary_monitor()
- rect = monitor.get_geometry()
- width_mm = monitor.get_width_mm()
- height_mm = monitor.get_height_mm()
- monitor_scale = monitor.get_scale_factor()
+ if display != None:
+ monitor = display.get_primary_monitor()
+ rect = monitor.get_geometry()
+ width_mm = monitor.get_width_mm()
+ height_mm = monitor.get_height_mm()
+ monitor_scale = monitor.get_scale_factor()
- # Return 1 if the screen size isn't available (some TVs report their aspect ratio instead ... 16/9 or 16/10)
- if ((width_mm == 160 and height_mm == 90) \
- or (width_mm == 160 and height_mm == 100) \
- or (width_mm == 16 and height_mm == 9) \
- or (width_mm == 16 and height_mm == 10)):
- return 1
+ # Return 1 if the screen size isn't available (some TVs report their aspect ratio instead ... 16/9 or 16/10)
+ if ((width_mm == 160 and height_mm == 90) \
+ or (width_mm == 160 and height_mm == 100) \
+ or (width_mm == 16 and height_mm == 9) \
+ or (width_mm == 16 and height_mm == 10)):
+ return 1
- if rect.height * monitor_scale < 1500:
- return 1
+ if rect.height * monitor_scale < 1500:
+ return 1
- if width_mm > 0 and height_mm > 0:
- witdh_inch = width_mm / 25.4
- height_inch = height_mm / 25.4
- dpi_x = rect.width * monitor_scale / witdh_inch
- dpi_y = rect.height * monitor_scale / height_inch
- if dpi_x > HIDPI_LIMIT and dpi_y > HIDPI_LIMIT:
- window_scale = 2
+ if width_mm > 0 and height_mm > 0:
+ width_inch = width_mm / 25.4
+ height_inch = height_mm / 25.4
+ dpi_x = rect.width * monitor_scale / width_inch
+ dpi_y = rect.height * monitor_scale / height_inch
+ if dpi_x > HIDPI_LIMIT and dpi_y > HIDPI_LIMIT:
+ window_scale = 2
except Exception as detail:
syslog.syslog("Error while detecting hidpi mode: %s" % detail)