]> git.mar77i.info Git - zenbook_conf/commitdiff
add create_desktop_file.sh
authormar77i <mar77i@protonmail.ch>
Tue, 17 Dec 2024 19:54:38 +0000 (20:54 +0100)
committermar77i <mar77i@protonmail.ch>
Tue, 17 Dec 2024 19:54:38 +0000 (20:54 +0100)
Zenbook Settings.desktop [deleted file]
create_desktop_file.sh [new file with mode: 0755]
zenbook_conf.py

diff --git a/Zenbook Settings.desktop b/Zenbook Settings.desktop
deleted file mode 100644 (file)
index 84e9aad..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-[Desktop Entry]
-Type=Application
-Exec=/home/martti/src/python/zenbook_conf/zenbook_conf.py
-X-Environment=VIRTUAL_ENV=/home/martti/src/python/zenbook_conf/venv
-Icon=/home/martti/src/python/zenbook_conf/laptop-single.svg
-
-Name=Zenbook Duo settings
diff --git a/create_desktop_file.sh b/create_desktop_file.sh
new file mode 100755 (executable)
index 0000000..3c57e9d
--- /dev/null
@@ -0,0 +1,58 @@
+#!/usr/bin/env bash
+
+script_dir="$(realpath -Pe "$(dirname "${0}")")"
+executable="${script_dir}/zenbook_conf.py"
+icon="${script_dir}/laptop-single.svg"
+virtual_env=
+
+help() {
+    echo " ${0} [--executable PATH] [--icon PATH] [--virtual-env PATH] | -h|--help"
+    echo "Create a desktop launcher for zenbook_conf.py"
+    echo "  --executable PATH   specify the executable"
+    echo "  --icon PATH         specify the icon"
+    echo "  --virtual-env PATH  specify a VIRTUAL_ENV path"
+    echo "  -h | --help        show this help message"
+    exit 0
+}
+
+help=0
+
+while (( $# )); do
+    case "${1}" in
+    --executable)
+        executable="${2}"
+        shift
+        ;;
+    --icon)
+        icon="${2}"
+        shift
+        ;;
+    --virtual-env)
+        virtual_env="${2}"
+        shift
+        ;;
+    -h|--help)
+        help=1
+        ;;
+    *)
+        echo "Error: invalid argument: ${1}" >&2
+        exit 1
+        ;;
+    esac
+    shift
+done
+
+if (( help )); then
+    help
+    exit 0
+fi
+
+echo "[Desktop Entry]"
+echo "Type=Application"
+echo "Exec=$(realpath -Pe "${executable}")"
+if [[ "${virtual_env}" ]]; then
+    echo "X-Environment=$(realpath -Pe "${virtual_env}")"
+fi
+echo "Icon=$(realpath -Pe "${icon}")"
+echo ""
+echo "Name=Zenbook Duo settings"
index 86b262de18297bf2d63ed588d3ca71920efcac1a..b72ae0e794e7b2e6b37a40d43b827398fee8a893 100755 (executable)
@@ -86,8 +86,13 @@ class ZenbookConf:
                     if item["name"] != "single":
                         self.bluetooth_conf.update(True)
                         self.bt_switch.update(True)
-                    self.xinput_conf.update_touch(self.touch_switch.setting)
-                    self.xinput_conf.update_stylus(self.stylus_switch.setting)
+                    settings_per_device_type = {
+                        "touchpad": self.touch_switch.setting,
+                        "stylus": self.stylus_switch.setting,
+                    }
+                    for device_type, setting in settings_per_device_type.items():
+                        if setting is not None:
+                            self.xinput_conf.update_by_type(device_type, setting)
                     self.dirty = True
             else:
                 self.bt_switch.handle_mousebuttondown(ev)