From 1810e862be354f8ce5b74a3d4e61a5404c4c49b7 Mon Sep 17 00:00:00 2001 From: lynxhug <22722489+lynxhug@users.noreply.github.com> Date: Sat, 20 Jun 2020 22:52:27 +0300 Subject: [PATCH 1/2] Add systemd service to start driver with udev rule --- huion-tablet-driver.py | 3 +++ systemd/80-uclogic.rules | 1 + systemd/huion-tablet-driver.service | 13 +++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 systemd/80-uclogic.rules create mode 100644 systemd/huion-tablet-driver.service diff --git a/huion-tablet-driver.py b/huion-tablet-driver.py index 658637b..4baf7e7 100755 --- a/huion-tablet-driver.py +++ b/huion-tablet-driver.py @@ -548,6 +548,9 @@ def read_config(): if os.path.exists('config.ini'): config = ConfigParser(interpolation=ExtendedInterpolation()) config.read('config.ini') + elif os.path.exists('/etc/huion/config.ini'): + config = ConfigParser(interpolation=ExtendedInterpolation()) + config.read('/etc/huion/config.ini') else: print("ERROR: Couldn't locate config.ini") sys.exit(2) diff --git a/systemd/80-uclogic.rules b/systemd/80-uclogic.rules new file mode 100644 index 0000000..18a5599 --- /dev/null +++ b/systemd/80-uclogic.rules @@ -0,0 +1 @@ +ACTION=="add", SUBSYSTEMS=="hid", DRIVERS=="uclogic", TAG+="systemd", ENV{SYSTEMD_WANTS}="huion-tablet-driver.service" diff --git a/systemd/huion-tablet-driver.service b/systemd/huion-tablet-driver.service new file mode 100644 index 0000000..7ca5de3 --- /dev/null +++ b/systemd/huion-tablet-driver.service @@ -0,0 +1,13 @@ +[Unit] +Description=Service to start userspace huion driver in user session +After=graphical.target + +[Service] +Environment=DISPLAY=:0 +#replace %%USER%% for system user (e.g. /home/bob/.Xauthority) +Environment=XAUTHORITY=/home/%%USER%%/.Xauthority +#be shure to change permissions to root:root 755. +ExecStart=/usr/local/bin/huion-tablet-driver.py + +[Install] +WantedBy=default.target From 38a26f7ae3552336788fd3a114b76e1c4db60806 Mon Sep 17 00:00:00 2001 From: lynxhug <22722489+lynxhug@users.noreply.github.com> Date: Sun, 20 Sep 2020 18:07:24 +0300 Subject: [PATCH 2/2] Update udev rules and systemd unit to works as systemd user service --- systemd/80-uclogic.rules | 1 - systemd/81-huion-tablet.rules | 2 ++ systemd/huion-tablet-driver.service | 13 ------------- systemd/huion-tablet.service | 8 ++++++++ 4 files changed, 10 insertions(+), 14 deletions(-) delete mode 100644 systemd/80-uclogic.rules create mode 100644 systemd/81-huion-tablet.rules delete mode 100644 systemd/huion-tablet-driver.service create mode 100644 systemd/huion-tablet.service diff --git a/systemd/80-uclogic.rules b/systemd/80-uclogic.rules deleted file mode 100644 index 18a5599..0000000 --- a/systemd/80-uclogic.rules +++ /dev/null @@ -1 +0,0 @@ -ACTION=="add", SUBSYSTEMS=="hid", DRIVERS=="uclogic", TAG+="systemd", ENV{SYSTEMD_WANTS}="huion-tablet-driver.service" diff --git a/systemd/81-huion-tablet.rules b/systemd/81-huion-tablet.rules new file mode 100644 index 0000000..4aaabc9 --- /dev/null +++ b/systemd/81-huion-tablet.rules @@ -0,0 +1,2 @@ +ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="256c", ATTR{idProduct}=="006d", MODE="0666", TAG+="systemd", ENV{SYSTEMD_USER_WANTS}="huion-tablet.service" +ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="256c", ATTR{idProduct}=="006e", MODE="0666", TAG+="systemd", ENV{SYSTEMD_USER_WANTS}="huion-tablet.service" diff --git a/systemd/huion-tablet-driver.service b/systemd/huion-tablet-driver.service deleted file mode 100644 index 7ca5de3..0000000 --- a/systemd/huion-tablet-driver.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Service to start userspace huion driver in user session -After=graphical.target - -[Service] -Environment=DISPLAY=:0 -#replace %%USER%% for system user (e.g. /home/bob/.Xauthority) -Environment=XAUTHORITY=/home/%%USER%%/.Xauthority -#be shure to change permissions to root:root 755. -ExecStart=/usr/local/bin/huion-tablet-driver.py - -[Install] -WantedBy=default.target diff --git a/systemd/huion-tablet.service b/systemd/huion-tablet.service new file mode 100644 index 0000000..cf97248 --- /dev/null +++ b/systemd/huion-tablet.service @@ -0,0 +1,8 @@ +[Unit] +Description=service to start userspace huion driver + +[Service] +ExecStart=huion-tablet-driver.py + +[Install] +WantedBy=default.target