From 1a1fc5f0c200dfd0f31a12d9ad09f2d89d69fc2c Mon Sep 17 00:00:00 2001
From: Jessie Hildebrandt <jessieh@jessieh.net>
Date: Thu, 11 Apr 2024 18:46:41 -0400
Subject: [PATCH] Initial commit

---
 applications/blender.desktop                  | 17 ++++++
 applications/calf.desktop                     | 10 ++++
 ....nextcloud.desktopclient.nextcloud.desktop | 17 ++++++
 applications/emacs.desktop                    | 14 +++++
 applications/emacsclient.desktop              | 22 +++++++
 applications/fish.desktop                     | 11 ++++
 applications/freecad.desktop                  | 11 ++++
 applications/org.gnome.Weather.desktop        | 13 +++++
 applications/uefi-firmware-settings.desktop   |  9 +++
 applications/windows.desktop                  |  9 +++
 applications/yelp.desktop                     | 14 +++++
 bin/gdm-lock-screen                           | 10 ++++
 bin/gdm-update-display-settings               | 30 ++++++++++
 bin/gnome-toggle-night-light                  | 49 ++++++++++++++++
 bin/gnome-toggle-touchpad-lock                | 49 ++++++++++++++++
 bin/projector                                 | 24 ++++++++
 bin/reboot-uefi                               | 17 ++++++
 bin/reboot-windows                            | 37 ++++++++++++
 bin/set-icon                                  | 25 ++++++++
 bin/themer                                    | 58 +++++++++++++++++++
 20 files changed, 446 insertions(+)
 create mode 100644 applications/blender.desktop
 create mode 100644 applications/calf.desktop
 create mode 100644 applications/com.nextcloud.desktopclient.nextcloud.desktop
 create mode 100644 applications/emacs.desktop
 create mode 100644 applications/emacsclient.desktop
 create mode 100644 applications/fish.desktop
 create mode 100644 applications/freecad.desktop
 create mode 100644 applications/org.gnome.Weather.desktop
 create mode 100644 applications/uefi-firmware-settings.desktop
 create mode 100644 applications/windows.desktop
 create mode 100644 applications/yelp.desktop
 create mode 100755 bin/gdm-lock-screen
 create mode 100755 bin/gdm-update-display-settings
 create mode 100755 bin/gnome-toggle-night-light
 create mode 100755 bin/gnome-toggle-touchpad-lock
 create mode 100755 bin/projector
 create mode 100755 bin/reboot-uefi
 create mode 100755 bin/reboot-windows
 create mode 100755 bin/set-icon
 create mode 100755 bin/themer

diff --git a/applications/blender.desktop b/applications/blender.desktop
new file mode 100644
index 0000000..ca868fa
--- /dev/null
+++ b/applications/blender.desktop
@@ -0,0 +1,17 @@
+[Desktop Entry]
+Name=Blender 2.91
+GenericName=3D modeler
+Comment=3D modeling, animation, rendering and post-production
+Keywords=3d;cg;modeling;animation;painting;sculpting;texturing;video editing;video tracking;rendering;render engine;cycles;game engine;python;
+Exec=blender %f
+Icon=blender
+Terminal=false
+Type=Application
+Categories=3DGraphics;Graphics;
+MimeType=application/x-blender;
+Name[en_US.UTF-8]=Blender
+X-GNOME-FullName[en_US.UTF-8]=Blender
+Comment[en_US.UTF-8]=3D modeling, animation, rendering and post-production
+NoDisplay=false
+Path=
+X-GNOME-UsesNotifications=false
diff --git a/applications/calf.desktop b/applications/calf.desktop
new file mode 100644
index 0000000..b09ca3e
--- /dev/null
+++ b/applications/calf.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Version=1.1
+Type=Application
+Name=Calf Plugin Pack for JACK
+NoDisplay=true
+Comment=Process and produce sounds using a set of plugins with JACK interface
+Icon=calf
+Exec=calfjackhost
+Actions=
+Categories=AudioVideo;Music;
diff --git a/applications/com.nextcloud.desktopclient.nextcloud.desktop b/applications/com.nextcloud.desktopclient.nextcloud.desktop
new file mode 100644
index 0000000..8871753
--- /dev/null
+++ b/applications/com.nextcloud.desktopclient.nextcloud.desktop
@@ -0,0 +1,17 @@
+[Desktop Entry]
+Version=1.1
+Type=Application
+Name=Nextcloud Desktop
+GenericName=Folder Sync
+NoDisplay=true
+Comment=Nextcloud desktop synchronization client
+Icon=Nextcloud
+Exec=nextcloud
+Actions=Quit;
+MimeType=application/vnd.nextcloud;
+Categories=Utility;X-SuSE-SyncUtility;
+Keywords=Nextcloud;syncing;file;sharing;
+
+[Desktop Action Quit]
+Name=Quit Nextcloud
+Exec=nextcloud --quit
diff --git a/applications/emacs.desktop b/applications/emacs.desktop
new file mode 100644
index 0000000..a156f0b
--- /dev/null
+++ b/applications/emacs.desktop
@@ -0,0 +1,14 @@
+[Desktop Entry]
+Version=1.1
+Type=Application
+Name=Emacs (New Instance)
+GenericName=Text Editor
+NoDisplay=true
+Comment=Edit text
+Icon=emacs
+Exec=emacs %F
+Actions=
+MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
+Categories=Development;TextEditor;Utility;
+StartupNotify=true
+StartupWMClass=Emacs
diff --git a/applications/emacsclient.desktop b/applications/emacsclient.desktop
new file mode 100644
index 0000000..cb04547
--- /dev/null
+++ b/applications/emacsclient.desktop
@@ -0,0 +1,22 @@
+[Desktop Entry]
+Version=1.1
+Type=Application
+Name=Emacs
+GenericName=Text Editor
+Comment=Edit text
+Icon=emacs
+Exec=emacsclient -cn %F
+Actions=new-window;new-instance;
+MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;
+Categories=Development;TextEditor;Utility;
+Keywords=emacsclient;
+StartupNotify=true
+StartupWMClass=Emacs
+
+[Desktop Action new-window]
+Name=New Window
+Exec=emacsclient -cn %F
+
+[Desktop Action new-instance]
+Name=New Instance
+Exec=emacs %F
diff --git a/applications/fish.desktop b/applications/fish.desktop
new file mode 100644
index 0000000..c5227b8
--- /dev/null
+++ b/applications/fish.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Version=1.1
+Type=Application
+Name=fish
+GenericName=Command-line interpreter
+NoDisplay=true
+Icon=fish
+Exec=fish
+Terminal=true
+Actions=
+Categories=ConsoleOnly;System;System-Tools;TerminalEmulator;
diff --git a/applications/freecad.desktop b/applications/freecad.desktop
new file mode 100644
index 0000000..6f5af36
--- /dev/null
+++ b/applications/freecad.desktop
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Name=FreeCAD
+GenericName=CAD Application
+Comment=Feature-based parametric modeling software
+Keywords=3d;cad;modeling;engineering;
+Exec=FreeCAD %F
+Icon=freecad
+Terminal=false
+Type=Application
+Categories=Engineering;
+MimeType=application/x-extension-fcstd;model/obj;model/iges;image/vnd.dwg;image/vnd.dxf;model/vnd.collada+xml;application/iges;model/iges;model/step;model/step+zip;model/stl;application/vnd.shp;model/vrml;
diff --git a/applications/org.gnome.Weather.desktop b/applications/org.gnome.Weather.desktop
new file mode 100644
index 0000000..f3881ae
--- /dev/null
+++ b/applications/org.gnome.Weather.desktop
@@ -0,0 +1,13 @@
+[Desktop Entry]
+Version=1.1
+Type=Application
+Name=Weather
+NoDisplay=true
+Comment=Show weather conditions and forecast
+Icon=org.gnome.Weather
+DBusActivatable=true
+Exec=gapplication launch org.gnome.Weather
+Actions=
+Categories=Core;GNOME;GTK;Utility;X-SuSE-DesktopUtility;
+Keywords=Weather;Forecast;
+StartupNotify=true
diff --git a/applications/uefi-firmware-settings.desktop b/applications/uefi-firmware-settings.desktop
new file mode 100644
index 0000000..c242e22
--- /dev/null
+++ b/applications/uefi-firmware-settings.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Version=1.1
+Type=Application
+Name=UEFI Setup
+Comment=Reboot to UEFI setup
+Icon=mx-boot-options
+Exec=reboot-uefi
+Actions=
+Categories=Utility;
diff --git a/applications/windows.desktop b/applications/windows.desktop
new file mode 100644
index 0000000..53a214c
--- /dev/null
+++ b/applications/windows.desktop
@@ -0,0 +1,9 @@
+[Desktop Entry]
+Version=1.1
+Type=Application
+Name=Windows
+Comment=Reboot to Microsoft Windows
+Icon=windows95
+Exec=reboot-windows
+Actions=
+Categories=Utility;
diff --git a/applications/yelp.desktop b/applications/yelp.desktop
new file mode 100644
index 0000000..98f42af
--- /dev/null
+++ b/applications/yelp.desktop
@@ -0,0 +1,14 @@
+[Desktop Entry]
+Version=1.1
+Type=Application
+Name=Help
+NoDisplay=true
+Comment=Get help with GNOME
+Icon=org.gnome.Yelp
+OnlyShowIn=GNOME;Unity;
+Exec=yelp %u
+Actions=
+MimeType=x-scheme-handler/ghelp;x-scheme-handler/help;x-scheme-handler/info;x-scheme-handler/man;
+Categories=Core;Documentation;GNOME;GTK;Utility;
+Keywords=documentation;information;manual;help;
+StartupNotify=true
diff --git a/bin/gdm-lock-screen b/bin/gdm-lock-screen
new file mode 100755
index 0000000..2826649
--- /dev/null
+++ b/bin/gdm-lock-screen
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+################################################################################
+#
+# gdm-lock-screen
+# Instructs GDM to lock the screen via D-Bus
+#
+################################################################################
+
+dbus-send --type=method_call --dest=org.gnome.ScreenSaver /org/gnome/ScreenSaver org.gnome.ScreenSaver.Lock
diff --git a/bin/gdm-update-display-settings b/bin/gdm-update-display-settings
new file mode 100755
index 0000000..a250098
--- /dev/null
+++ b/bin/gdm-update-display-settings
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+################################################################################
+#
+# gdm-update-display-settings
+# Copies user's current display settings to GDM's config folder
+#
+################################################################################
+
+# Ensure we're not running as root
+if [[ "${EUID}" == 0 ]]; then
+    echo "DO NOT RUN THIS SCRIPT AS ROOT!"
+    echo "Please run this script as a regular user."
+    exit 1
+fi
+
+# Update display settings
+sudo cp ${HOME}/.config/monitors.xml /var/lib/gdm/.config/ && echo "Copied .config/monitors.xml to /var/lib/gdm/.config"
+
+# Update pointer settings
+MOUSE_SPEED=$(gsettings get org.gnome.desktop.peripherals.mouse speed)
+MOUSE_ACCEL_PROFILE=$(gsettings get org.gnome.desktop.peripherals.mouse accel-profile)
+TOUCHPAD_SPEED=$(gsettings get org.gnome.desktop.peripherals.touchpad speed)
+TOUCHPAD_ACCEL_PROFILE=$(gsettings get org.gnome.desktop.peripherals.touchpad accel-profile)
+sudo su -c \
+"sudo -u gdm dbus-launch gsettings set org.gnome.desktop.peripherals.mouse speed ${MOUSE_SPEED} &&
+sudo -u gdm dbus-launch gsettings set org.gnome.desktop.peripherals.mouse accel-profile "${MOUSE_ACCEL_PROFILE}" &&
+sudo -u gdm dbus-launch gsettings set org.gnome.desktop.peripherals.touchpad speed ${TOUCHPAD_SPEED} &&
+sudo -u gdm dbus-launch gsettings set org.gnome.desktop.peripherals.touchpad accel-profile "${TOUCHPAD_ACCEL_PROFILE}" &&
+echo Applied pointer speed and acceleration profiles"
diff --git a/bin/gnome-toggle-night-light b/bin/gnome-toggle-night-light
new file mode 100755
index 0000000..05ee73b
--- /dev/null
+++ b/bin/gnome-toggle-night-light
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+################################################################################
+#
+# gnome-toggle-night-light
+# Toggles GNOME's Night Light feature
+#
+# Requires notify-send
+#
+################################################################################
+
+################################################################################
+# User configuration
+################################################################################
+
+title="Night Light"
+body_enabled="Night light has been enabled."
+body_disabled="Night light has been disabled."
+icon_enabled="night-light"
+icon_disabled="night-light-disabled"
+key="org.gnome.settings-daemon.plugins.color night-light-enabled"
+
+################################################################################
+# GSettings toggle code
+################################################################################
+
+# Get original value of key
+value=$(gsettings get $key)
+
+# Determine a temp file to store the notification ID in
+notif_id_file_name=/tmp/tmp.$(echo $key | tr -d ' ').nid
+{ prev_notif_id=$(<$notif_id_file_name); } 2> /dev/null
+
+# If we have an ID from a previous notification,
+# set the replace flag so that we override it
+replace_flag=""
+case $prev_notif_id in
+    ''|*[!0-9]*) ;;
+    *) replace_flag="--replace-id=$prev_notif_id" ;;
+esac
+
+# Toggle the key and send the notification
+if [[ $value == "true" ]]; then
+    gsettings set $key false
+    notify-send "$title Disabled" "$body_disabled" --app-name "$title" --icon "$icon_disabled" $replace_flag --transient --expire-time=0 --print-id > "$notif_id_file_name"
+else
+    gsettings set $key true
+    notify-send "$title Enabled" "$body_enabled" --app-name "$title" --icon "$icon_enabled" $replace_flag --transient --expire-time=0 --print-id > "$notif_id_file_name"
+fi
diff --git a/bin/gnome-toggle-touchpad-lock b/bin/gnome-toggle-touchpad-lock
new file mode 100755
index 0000000..82f2c78
--- /dev/null
+++ b/bin/gnome-toggle-touchpad-lock
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+################################################################################
+#
+# gnome-toggle-touchpad-lock
+# Toggles GNOME's touchpad typing lock feature
+#
+# Requires notify-send to be installed
+#
+################################################################################
+
+################################################################################
+# User configuration
+################################################################################
+
+title="Touchpad Lock"
+body_enabled="Touchpad will be locked while typing."
+body_disabled="Touchpad will be unlocked while typing."
+icon_enabled="touchpad-disabled"
+icon_disabled="input-touchpad"
+key="org.gnome.desktop.peripherals.touchpad disable-while-typing"
+
+################################################################################
+# GSettings toggle code
+################################################################################
+
+# Get original value of key
+value=$(gsettings get $key)
+
+# Determine a temp file to store the notification ID in
+notif_id_file_name=/tmp/tmp.$(echo $key | tr -d ' ').nid
+{ prev_notif_id=$(<$notif_id_file_name); } 2> /dev/null
+
+# If we have an ID from a previous notification,
+# set the replace flag so that we override it
+replace_flag=""
+case $prev_notif_id in
+    ''|*[!0-9]*) ;;
+    *) replace_flag="--replace-id=$prev_notif_id" ;;
+esac
+
+# Toggle the key and send the notification
+if [[ $value == "true" ]]; then
+    gsettings set $key false
+    notify-send "$title Disabled" "$body_disabled" --app-name "$title" --icon "$icon_disabled" $replace_flag --transient --expire-time=0 --print-id > "$notif_id_file_name"
+else
+    gsettings set $key true
+    notify-send "$title Enabled" "$body_enabled" --app-name "$title" --icon "$icon_enabled" $replace_flag --transient --expire-time=0 --print-id > "$notif_id_file_name"
+fi
diff --git a/bin/projector b/bin/projector
new file mode 100755
index 0000000..1b7afeb
--- /dev/null
+++ b/bin/projector
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+################################################################################
+#
+# projector
+# Updates ${HOME}/Projects against the public repos at git.tty.dog
+#
+# Requires jq
+#
+################################################################################
+
+# Ensure ${HOME}/Projects exists and set it as the working directory
+PROJECTS_DIR="${HOME}/Projects"
+if [ ! -d "${PROJECTS_DIR}" ]; then
+    mkdir "${PROJECTS_DIR}"
+    set-icon "${PROJECTS_DIR}" folder-code
+fi
+cd "${PROJECTS_DIR}"
+
+# Perform a blobless clone of all public repos at git.tty.dog
+API_URL="https://git.tty.dog/api/v1/repos/search"
+for CLONE_URL in $(curl -s "${API_URL}?uid=1" | jq -r ".data.[].clone_url"); do
+    git clone --no-checkout --filter=blob:none "${CLONE_URL}"
+done
diff --git a/bin/reboot-uefi b/bin/reboot-uefi
new file mode 100755
index 0000000..4e8110c
--- /dev/null
+++ b/bin/reboot-uefi
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+################################################################################
+#
+# reboot-uefi
+# Prompts the user to reboot to system firmware (UEFI) setup
+#
+################################################################################
+
+########################################
+# Prompt user and execute reboot seq.
+########################################
+
+if zenity --question --icon device_pci --text="Reboot to UEFI setup?" --title "UEFI Setup" --default-cancel --no-wrap --timeout=10
+then
+	pkexec systemctl reboot --firmware-setup
+fi
diff --git a/bin/reboot-windows b/bin/reboot-windows
new file mode 100755
index 0000000..b79e155
--- /dev/null
+++ b/bin/reboot-windows
@@ -0,0 +1,37 @@
+#!/bin/bash
+
+################################################################################
+#
+# reboot-windows
+# Finds and flags a Windows menuentry in GRUB, and then reboots the system
+#
+################################################################################
+
+########################################
+# Reboot command
+########################################
+
+REBOOT_CMD=$(cat <<EOF
+
+# Find the exact name of the first Windows menuentry in grub.cfg
+WINDOWS_ENTRY=\$(sudo grep menuentry /boot/grub2/grub.cfg  | grep -Po "'.*Windows.*?'" | grep -o "[^'].*[^']")
+
+# Set next_entry in grubenv to the Windows menuentry
+sudo grub2-reboot "\$WINDOWS_ENTRY";
+
+# Copy grubenv to the OpenSUSE grub EFI folder (/boot/grub2/ is not visible on UEFI installs)
+sudo cp /boot/grub2/grubenv /boot/efi/EFI/opensuse/grubenv
+
+# Reboot!
+sudo reboot;
+EOF
+)
+
+########################################
+# Prompt user and execute reboot seq.
+########################################
+
+if zenity --question --icon distributor-logo-windows --text="Reboot to Microsoft Windows?" --title "Windows" --default-cancel --no-wrap --timeout=10
+then
+	pkexec --disable-internal-agent bash -c "$REBOOT_CMD"
+fi
diff --git a/bin/set-icon b/bin/set-icon
new file mode 100755
index 0000000..78fa155
--- /dev/null
+++ b/bin/set-icon
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+################################################################################
+#
+# set-icon
+# Sets an icon for a file or directory by name
+#
+################################################################################
+
+LOCATION="${1}"
+ICON_NAME="${2}"
+
+if [[ -z "${LOCATION}" ]]; then
+    echo "Please specify a location"
+    echo "Usage: set-icon LOCATION [ICON_NAME]"
+    exit 1
+fi
+
+if [[ -z "${ICON_NAME}" ]]; then
+    echo "Unsetting metadata::custom-icon-name for ${LOCATION}"
+    gio set "${LOCATION}" metadata::custom-icon-name -t unset
+else
+    echo "Setting metadata::custom-icon-name for ${LOCATION} to ${ICON_NAME}"
+    gio set "${LOCATION}" metadata::custom-icon-name "${ICON_NAME}"
+fi
diff --git a/bin/themer b/bin/themer
new file mode 100755
index 0000000..16c92a3
--- /dev/null
+++ b/bin/themer
@@ -0,0 +1,58 @@
+#!/bin/bash
+
+################################################################################
+#
+# themer
+# Installs/updates unofficial libadwaita themes for various programs
+#
+################################################################################
+
+########################################
+# Install adw-gtk3 for legacy GTK3 applications
+
+echo
+echo "*** Installing adw-gtk3 theme for GTK3 applications... ***"
+echo
+
+# Download and install adw-gtk3
+DOWNLOAD_URL=$(curl -s https://api.github.com/repos/lassekongo83/adw-gtk3/releases/latest | grep browser_download_url | cut -d '"' -f 4)
+wget "${DOWNLOAD_URL}" -O /tmp/adw-gtk3.tar
+mkdir -p ${HOME}/.local/share/themes
+tar xf /tmp/adw-gtk3.tar -C ${HOME}/.local/share/themes/
+
+# Install adw-gtk3 for Flatpak applications
+sudo flatpak install --noninteractive org.gtk.Gtk3theme.adw-gtk3 org.gtk.Gtk3theme.adw-gtk3-dark
+
+# Apply adw-gtk3-dark theme to legacy applications
+# (Using the dark variant here until GNOME re-adds per-application dark theme support for legacy apps)
+gsettings set org.gnome.desktop.interface gtk-theme "adw-gtk3-dark"
+
+# Ensure GTK2 applications still use regular Adwaita
+echo 'include "/usr/share/themes/Adwaita/gtk-2.0/gtkrc"' > ${HOME}/.gtkrc-2.0
+
+########################################
+# Install Adwaita theme for Firefox
+
+echo
+echo "*** Installing Adwaita theme for Firefox... ***"
+echo
+
+# Download and install gnome-firefox-theme
+rm -rf /tmp/firefox-gnome-theme/
+git clone https://github.com/rafaelmardojai/firefox-gnome-theme.git /tmp/firefox-gnome-theme/
+(
+    cd /tmp/firefox-gnome-theme/
+    git checkout v$(firefox --version | sed -nr 's/[^0-9]*([0-9]*).*/\1/p') # Making sure to use the appropriate version
+    bash ./scripts/auto-install.sh
+)
+
+# Set user flags for theme
+function set_ff_flag ()
+{
+    USER_JS_FILE=${HOME}/.mozilla/firefox/*.default-release/user.js
+    sed -i 's/user_pref("'${1}'",.*);/user_pref("'${1}'",'${2}');/' $USER_JS_FILE
+    grep -q ${1} $USER_JS_FILE || echo "user_pref(\"$1\",$2);" >> $USER_JS_FILE
+}
+set_ff_flag gnomeTheme.dragWindowHeaderbarButtons true
+set_ff_flag gnomeTheme.bookmarksToolbarUnderTabs true
+set_ff_flag gnomeTheme.hideSingleTab true