From 0d3abb5c9c5b3912ae91fdddbbace5187ceeb7b6 Mon Sep 17 00:00:00 2001 From: mar77i Date: Tue, 17 Dec 2024 20:54:38 +0100 Subject: [PATCH] add create_desktop_file.sh --- Zenbook Settings.desktop | 7 ----- create_desktop_file.sh | 58 ++++++++++++++++++++++++++++++++++++++++ zenbook_conf.py | 9 +++++-- 3 files changed, 65 insertions(+), 9 deletions(-) delete mode 100644 Zenbook Settings.desktop create mode 100755 create_desktop_file.sh diff --git a/Zenbook Settings.desktop b/Zenbook Settings.desktop deleted file mode 100644 index 84e9aad..0000000 --- a/Zenbook Settings.desktop +++ /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 index 0000000..3c57e9d --- /dev/null +++ b/create_desktop_file.sh @@ -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" diff --git a/zenbook_conf.py b/zenbook_conf.py index 86b262d..b72ae0e 100755 --- a/zenbook_conf.py +++ b/zenbook_conf.py @@ -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) -- 2.47.1