Improve disabling of screensaver on macOS
authorSimon Hausmann <simon.hausmann@qt.io>
Thu, 8 Dec 2016 07:18:50 +0000 (08:18 +0100)
committerSimon Hausmann <simon.hausmann@qt.io>
Thu, 8 Dec 2016 08:18:56 +0000 (08:18 +0000)
Setting the idleTime on currentHost works well, until the hardware UUID changes
and thus the host ID for the setting. With kvm that happens quite frequently,
with vmware less but also occasionally (deep clone for example). By disabling
the screensaver on start-up we can cover all cases quite easily.

Change-Id: Ibdcf404430656f9caa47386ca3c732366ddfc8c7
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
coin/provisioning/qtci-osx-10.10-x86_64/002-disable-screensaver.sh
coin/provisioning/qtci-osx-10.11-x86_64/002-disable-screensaver.sh
coin/provisioning/qtci-osx-10.8-x86_64/002-disable-screensaver.sh
coin/provisioning/qtci-osx-10.9-x86_64/002-disable-screensaver.sh

index 6f4de5f..44df94e 100644 (file)
@@ -1,3 +1,26 @@
 #!/bin/sh
 
-defaults -currentHost write com.apple.screensaver idleTime 0
+mkdir -p $HOME/Library/LaunchAgents
+cat >$HOME/Library/LaunchAgents/no-screensaver.plist <<EOT
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+    <dict>
+        <key>Label</key>
+        <string>org.qt.io.screensaver_disable</string>
+        <key>ProgramArguments</key>
+        <array>
+            <string>defaults</string>
+            <string>-currentHost</string>
+            <string>write</string>
+            <string>com.apple.screensaver</string>
+            <string>idleTime</string>
+            <string>0</string>
+        </array>
+        <key>RunAtLoad</key>
+        <true/>
+        <key>KeepAlive</key>
+        <false/>
+    </dict>
+</plist>
+EOT
index 6f4de5f..44df94e 100644 (file)
@@ -1,3 +1,26 @@
 #!/bin/sh
 
-defaults -currentHost write com.apple.screensaver idleTime 0
+mkdir -p $HOME/Library/LaunchAgents
+cat >$HOME/Library/LaunchAgents/no-screensaver.plist <<EOT
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+    <dict>
+        <key>Label</key>
+        <string>org.qt.io.screensaver_disable</string>
+        <key>ProgramArguments</key>
+        <array>
+            <string>defaults</string>
+            <string>-currentHost</string>
+            <string>write</string>
+            <string>com.apple.screensaver</string>
+            <string>idleTime</string>
+            <string>0</string>
+        </array>
+        <key>RunAtLoad</key>
+        <true/>
+        <key>KeepAlive</key>
+        <false/>
+    </dict>
+</plist>
+EOT
index 6f4de5f..44df94e 100644 (file)
@@ -1,3 +1,26 @@
 #!/bin/sh
 
-defaults -currentHost write com.apple.screensaver idleTime 0
+mkdir -p $HOME/Library/LaunchAgents
+cat >$HOME/Library/LaunchAgents/no-screensaver.plist <<EOT
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+    <dict>
+        <key>Label</key>
+        <string>org.qt.io.screensaver_disable</string>
+        <key>ProgramArguments</key>
+        <array>
+            <string>defaults</string>
+            <string>-currentHost</string>
+            <string>write</string>
+            <string>com.apple.screensaver</string>
+            <string>idleTime</string>
+            <string>0</string>
+        </array>
+        <key>RunAtLoad</key>
+        <true/>
+        <key>KeepAlive</key>
+        <false/>
+    </dict>
+</plist>
+EOT
index 6f4de5f..44df94e 100644 (file)
@@ -1,3 +1,26 @@
 #!/bin/sh
 
-defaults -currentHost write com.apple.screensaver idleTime 0
+mkdir -p $HOME/Library/LaunchAgents
+cat >$HOME/Library/LaunchAgents/no-screensaver.plist <<EOT
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple/DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+    <dict>
+        <key>Label</key>
+        <string>org.qt.io.screensaver_disable</string>
+        <key>ProgramArguments</key>
+        <array>
+            <string>defaults</string>
+            <string>-currentHost</string>
+            <string>write</string>
+            <string>com.apple.screensaver</string>
+            <string>idleTime</string>
+            <string>0</string>
+        </array>
+        <key>RunAtLoad</key>
+        <true/>
+        <key>KeepAlive</key>
+        <false/>
+    </dict>
+</plist>
+EOT