tabletcfg: Make huion-tablet more generic

This commit is contained in:
Simon Bruder 2022-11-27 18:00:56 +01:00
parent 61ef98c688
commit f59ab31d54
Signed by: simon
GPG key ID: 8D3C82F9F309F8EC

View file

@ -1,11 +1,11 @@
#!/usr/bin/env cached-nix-shell
#!nix-shell -i python3 -p "python3.withPackages(ps: [ ps.pyyaml ])"
# Set Huion H430P parameters from saved profiles using swaymsg
# Set Digitizer parameters from saved profiles using swaymsg
#
# This currently only works for setting the screen and area but not for setting
# the buttons.
#
# Write your config into ~/.config/huion-tablet.yml
# Write your config into ~/.config/tabletcfg.yml
# Example:
#
# presets:
@ -13,7 +13,7 @@
# screen: DP-4
# area: 0 0 1 1
#
# then run huion-tablet.py my-preset
# then run tabletcfg.py my-preset
from subprocess import run
import os.path
import sys
@ -23,7 +23,7 @@ import yaml
def _set_parameter(parameter, *args):
args = map(str, args)
run(
["swaymsg", "input", "9580:109:HUION_Huion_Tablet_Pen", parameter, *args],
["swaymsg", "input", "type:tablet_tool", parameter, *args],
check=True,
)
@ -38,7 +38,7 @@ def map_from_region(x1, y1, x2, y2):
preset = sys.argv[1]
with open(os.path.expanduser("~/.config/huion-tablet.yml"), "r") as f:
with open(os.path.expanduser("~/.config/tabletcfg.yml"), "r") as f:
config = yaml.load(f, Loader=yaml.SafeLoader)
preset = config["presets"][preset]