New script to set the background image of the login screen
authorAndrew DeFaria <Andrew@DeFaria.com>
Thu, 6 Aug 2020 22:07:48 +0000 (15:07 -0700)
committerAndrew DeFaria <Andrew@DeFaria.com>
Thu, 6 Aug 2020 22:07:48 +0000 (15:07 -0700)
TODO: Properly escape special characters in the filename

bin/setlogin [new file with mode: 0755]

diff --git a/bin/setlogin b/bin/setlogin
new file mode 100755 (executable)
index 0000000..ee71ada
--- /dev/null
@@ -0,0 +1,104 @@
+#!/bin/bash
+# Simple script to set the login background
+
+if [ "$UID" != 0 ]; then
+  echo "Must be run as root"
+  exit 1
+fi
+
+if [ $# != 1 ]; then
+  echo "Usage: $0 <image file>"
+  exit 1
+fi
+
+# Not sure why Yaru was picked as the source...
+source="/usr/share/gnome-shell/theme/Yaru/gnome-shell-theme.gresource"
+color="#000000"
+
+imagefile=$1
+
+if [ ! -e "$imagefile" ]; then
+  echo "$imagefile not found"
+  exit 1
+fi
+
+imagefile=$(echo $imagefile | sed 's/ /%20/g')
+
+prefix="/org/gnome/shell/theme"
+dest="/usr/local/share/gnome-shell/theme/focalgdm3"
+
+install -D /dev/null $dest/gdm3.css
+install -D /dev/null $dest/focalgdm3.gresource.xml
+install -d $dest/icons/scalable/actions
+
+gresource extract $source $prefix/gdm3.css > $dest/original.css
+gresource extract $source $prefix/checkbox.svg > $dest/checkbox.svg
+gresource extract $source $prefix/checkbox-off.svg > $dest/checkbox-off.svg
+gresource extract $source $prefix/checkbox-focused.svg > $dest/checkbox-focused.svg
+gresource extract $source $prefix/checkbox-off-focused.svg > $dest/checkbox-off-focused.svg
+gresource extract $source $prefix/toggle-on.svg > $dest/toggle-on.svg
+gresource extract $source $prefix/toggle-off.svg > $dest/toggle-off.svg
+gresource extract $source $prefix/icons/scalable/actions/pointer-drag-symbolic.svg > $dest/icons/scalable/actions/pointer-drag-symbolic.svg
+gresource extract $source $prefix/icons/scalable/actions/keyboard-enter-symbolic.svg > $dest/icons/scalable/actions/keyboard-enter-symbolic.svg
+gresource extract $source $prefix/icons/scalable/actions/keyboard-hide-symbolic.svg > $dest/icons/scalable/actions/keyboard-hide-symbolic.svg
+gresource extract $source $prefix/icons/scalable/actions/pointer-secondary-click-symbolic.svg > $dest/icons/scalable/actions/pointer-secondary-click-symbolic.svg
+gresource extract $source $prefix/icons/scalable/actions/keyboard-shift-filled-symbolic.svg > $dest/icons/scalable/actions/keyboard-shift-filled-symbolic.svg
+gresource extract $source $prefix/icons/scalable/actions/keyboard-caps-lock-filled-symbolic.svg > $dest/icons/scalable/actions/keyboard-caps-lock-filled-symbolic.svg
+gresource extract $source $prefix/icons/scalable/actions/pointer-primary-click-symbolic.svg > $dest/icons/scalable/actions/pointer-primary-click-symbolic.svg
+gresource extract $source $prefix/icons/scalable/actions/keyboard-layout-filled-symbolic.svg > $dest/icons/scalable/actions/keyboard-layout-filled-symbolic.svg
+gresource extract $source $prefix/icons/scalable/actions/eye-not-looking-symbolic.svg > $dest/icons/scalable/actions/eye-not-looking-symbolic.svg
+gresource extract $source $prefix/icons/scalable/actions/pointer-double-click-symbolic.svg > $dest/icons/scalable/actions/pointer-double-click-symbolic.svg
+gresource extract $source $prefix/icons/scalable/actions/eye-open-negative-filled-symbolic.svg > $dest/icons/scalable/actions/eye-open-negative-filled-symbolic.svg
+
+echo '@import url("resource:///org/gnome/shell/theme/original.css");
+  #lockDialogGroup {
+  background: '$color' url(file://'$imagefile');
+  background-repeat: no-repeat;
+  background-size: cover;
+  background-position: center; }' > $dest/gdm3.css
+
+echo '<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/shell/theme">
+    <file>original.css</file>
+    <file>gdm3.css</file>
+    <file>toggle-off.svg</file>
+    <file>checkbox-off.svg</file>
+    <file>toggle-on.svg</file>
+    <file>checkbox-off-focused.svg</file>
+    <file>checkbox-focused.svg</file>
+    <file>checkbox.svg</file>
+    <file>icons/scalable/actions/pointer-drag-symbolic.svg</file>
+    <file>icons/scalable/actions/keyboard-enter-symbolic.svg</file>
+    <file>icons/scalable/actions/keyboard-hide-symbolic.svg</file>
+    <file>icons/scalable/actions/pointer-secondary-click-symbolic.svg</file>
+    <file>icons/scalable/actions/keyboard-shift-filled-symbolic.svg</file>
+    <file>icons/scalable/actions/keyboard-caps-lock-filled-symbolic.svg</file>
+    <file>icons/scalable/actions/pointer-primary-click-symbolic.svg</file>
+    <file>icons/scalable/actions/keyboard-layout-filled-symbolic.svg</file>
+    <file>icons/scalable/actions/eye-not-looking-symbolic.svg</file>
+    <file>icons/scalable/actions/pointer-double-click-symbolic.svg</file>
+    <file>icons/scalable/actions/eye-open-negative-filled-symbolic.svg</file>
+  </gresource>
+</gresources>' > $dest/focalgdm3.gresource.xml
+
+cd $dest
+
+glib-compile-resources focalgdm3.gresource.xml
+
+mv focalgdm3.gresource ..
+
+rm -r $dest
+
+update-alternatives --quiet --install /usr/share/gnome-shell/gdm3-theme.gresource gdm3-theme.gresource /usr/local/share/gnome-shell/theme/focalgdm3.gresource 0
+update-alternatives --quiet --set gdm3-theme.gresource /usr/local/share/gnome-shell/theme/focalgdm3.gresource
+
+check=$(update-alternatives --query gdm3-theme.gresource | grep Value | grep /usr/local/share/gnome-shell/theme/focalgdm3.gresource >/dev/null && echo "pass" || echo "fail")
+
+if [ "$check" == "pass" ]; then
+  echo "Success"
+  exit 0
+else
+  echo "Failure"
+  exit 1
+fi