mirror of
https://git.davidovski.xyz/dot.git
synced 2024-08-15 00:43:28 +00:00
Update tablet script
This commit is contained in:
parent
42984d6686
commit
57aad4d528
6 changed files with 67 additions and 32 deletions
|
@ -45,7 +45,7 @@ bspc config focus_follows_pointer false
|
||||||
bspc config normal_border_color "$COLOR_SECONDARY"
|
bspc config normal_border_color "$COLOR_SECONDARY"
|
||||||
bspc config active_border_color "$COLOR_SECONDARY"
|
bspc config active_border_color "$COLOR_SECONDARY"
|
||||||
bspc config focused_border_color "$COLOR_PRIMARY"
|
bspc config focused_border_color "$COLOR_PRIMARY"
|
||||||
wmname bspwm
|
wmname
|
||||||
|
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
file:///home/david/docs/lmms
|
file:///home/david/docs/lmms
|
||||||
file:///home/x/pics/screenshot
|
|
||||||
file:///home/david/hd1/important
|
|
||||||
file:///home/david/docs docs
|
file:///home/david/docs docs
|
||||||
file:///home/david/pics pics
|
file:///home/david/pics pics
|
||||||
file:///home/david/dl dl
|
file:///home/david/dl dl
|
||||||
|
@ -8,9 +6,6 @@ file:///home/david/video video
|
||||||
file:///home/david/music music
|
file:///home/david/music music
|
||||||
file:///home/david/pics/screenshot screenshot
|
file:///home/david/pics/screenshot screenshot
|
||||||
file:///home/david/docs/proj proj
|
file:///home/david/docs/proj proj
|
||||||
file:///home/david/hd1/library library
|
|
||||||
file:///tmp tmp
|
file:///tmp tmp
|
||||||
file:///home/david/docs/school
|
|
||||||
file:///home/david/video/anime
|
file:///home/david/video/anime
|
||||||
file:///home/david/lmms
|
|
||||||
file:///home/david/docs/proj/ardour
|
file:///home/david/docs/proj/ardour
|
||||||
|
|
|
@ -15,7 +15,7 @@ audio_output {
|
||||||
|
|
||||||
audio_output {
|
audio_output {
|
||||||
type "pulse"
|
type "pulse"
|
||||||
name "mpd pulse"
|
name "mpd pulse"
|
||||||
}
|
}
|
||||||
|
|
||||||
#audio_output {
|
#audio_output {
|
||||||
|
|
5
scripts/mpc_add_query.sh
Executable file
5
scripts/mpc_add_query.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
query=${1}
|
||||||
|
cd ~/music
|
||||||
|
find . -iname "*$query*" -type f | while read -r line; do mpc insert "${line#./}"; done
|
7
scripts/mpc_add_recent.sh
Executable file
7
scripts/mpc_add_recent.sh
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# add recently added files to the playlist
|
||||||
|
|
||||||
|
count=${1:-10}
|
||||||
|
|
||||||
|
cd ~/music
|
||||||
|
find . -type f -print0 | xargs -0 stat -c"%Y %n" | sort -n | tail -${count} |cut -d' ' -f2- | while read -r line; do mpc insert "${line#./}"; done
|
|
@ -2,49 +2,75 @@
|
||||||
import sys
|
import sys
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import os
|
import os
|
||||||
|
from Xlib import X, display
|
||||||
|
from Xlib.ext import randr
|
||||||
|
|
||||||
if len(sys.argv) < 3:
|
import subprocess
|
||||||
print("Usage: tablet [dev number] [property number] [scale factor] [aspect ratio]")
|
import re
|
||||||
|
|
||||||
|
# this is horriffic, gets the list of all screens
|
||||||
|
screens = [ (lambda s: [int(x) for x in (s.split("+")[1], s.split("+")[2], s.split("x")[0].split("/")[0], s.split("x")[1].split("/")[0])])(l.split(" ")[3]) for l in str(subprocess.check_output(["xrandr", "--listmonitors"])).split("\\n") if len(l.split(" ")) > 2]
|
||||||
|
|
||||||
|
#if len(sys.argv) < 3:
|
||||||
|
# print("Usage: tablet [dev number] [property number] [scale factor] [aspect ratio]")
|
||||||
|
|
||||||
#Arguments
|
#Arguments
|
||||||
dev = sys.argv[1]
|
scale = float(sys.argv[1]) if len(sys.argv) > 1 else 1
|
||||||
prop = sys.argv[2]
|
#tablet_ratio = (lambda s: float(s[0]) / float(s[1]))(sys.argv[4].split(":")) if len(sys.argv) > 4 else 16/9
|
||||||
scale = float(sys.argv[3])
|
tablet_ratio = 16/9
|
||||||
tablet_ratio = (lambda s: float(s[0]) / float(s[1]))(sys.argv[4].split(":")) if len(sys.argv) > 4 else 16/9
|
|
||||||
|
|
||||||
#Layout of screens: (x, y, w, h)
|
|
||||||
#screens = [
|
|
||||||
# (0, 0, 1280, 1024),
|
|
||||||
# (1280, 0, 2560, 1440),
|
|
||||||
# (3840, 0, 1080, 1920),
|
|
||||||
# (4920, 0, 1080, 1920),
|
|
||||||
#]
|
|
||||||
|
|
||||||
screens = [
|
input_items = list(filter(lambda i: i[0], zip(subprocess.check_output(["xinput", "list", "--id-only"]).decode("ascii").split("\n"), subprocess.check_output(["xinput", "list", "--name-only"]).decode("ascii").split("\n"))))
|
||||||
(0, 0, 1920, 1080),
|
|
||||||
(1920, 0, 2560, 1440),
|
input_items = sorted(input_items, key=(lambda i: int(i[0])))
|
||||||
]
|
|
||||||
|
print("Input devices found:")
|
||||||
|
|
||||||
|
for item in input_items:
|
||||||
|
print(f"{item[0]}: {item[1]}")
|
||||||
|
|
||||||
|
print()
|
||||||
|
dev = input("Select input device (id) to use: ")
|
||||||
|
|
||||||
|
|
||||||
|
prop = [ re.search(r"\((.+)\)", line).group(1) for line in subprocess.check_output(["xinput", "list-props", dev]).decode("ascii").split("\n") if re.search("Coordinate Transformation Matrix", line) ][0]
|
||||||
|
|
||||||
|
if len(screens) == 1:
|
||||||
|
target = screens[1]
|
||||||
|
else:
|
||||||
|
print("Multiple screens detected:\n")
|
||||||
|
for i, screen in enumerate(screens):
|
||||||
|
print(f"{i}: {screen}")
|
||||||
|
|
||||||
|
print()
|
||||||
|
targetno = input("Enter screen to map to (0): ")
|
||||||
|
|
||||||
|
if targetno:
|
||||||
|
target = screens[int(targetno)]
|
||||||
|
else:
|
||||||
|
target = screens[0]
|
||||||
|
|
||||||
#TODO find this with xrandr
|
|
||||||
|
|
||||||
target = screens[1]
|
|
||||||
|
|
||||||
#Physical offset of the selected screen
|
#Physical offset of the selected screen
|
||||||
offsetx = target[0]
|
offsetx = target[0]
|
||||||
offsety = target[1]
|
offsety = target[1]
|
||||||
|
|
||||||
#Size of the full screen areas
|
#Size of the full screen areas
|
||||||
sh = 1080
|
sh, sw = 0, 0
|
||||||
sw = 1920 + 2560
|
|
||||||
#TODO calculate using list of screens
|
for screen in screens:
|
||||||
|
if screen[0]+screen[2] > sw:
|
||||||
|
sw = screen[0] + screen[2]
|
||||||
|
if screen[1]+screen[3] > sh:
|
||||||
|
sh = screen[1] + screen[3]
|
||||||
|
|
||||||
#Aspect ratio of the tablet, to avoid weird scaling problems
|
#Aspect ratio of the tablet, to avoid weird scaling problems
|
||||||
|
|
||||||
#Size of the tablet
|
#Size of the tablet
|
||||||
#Prioritize the with when scaling between aspect ratios
|
#Prioritize the width when scaling between aspect ratios
|
||||||
tw = target[2]
|
tw = target[2]
|
||||||
th = tw / tablet_ratio
|
th = tw / tablet_ratio
|
||||||
print(tw, "x", th)
|
|
||||||
|
|
||||||
if "-r" in sys.argv or "-l" in sys.argv:
|
if "-r" in sys.argv or "-l" in sys.argv:
|
||||||
th = target[2]
|
th = target[2]
|
||||||
|
@ -84,5 +110,7 @@ if "-l" in sys.argv:
|
||||||
arr = np.squeeze(np.asarray(transform))
|
arr = np.squeeze(np.asarray(transform))
|
||||||
|
|
||||||
|
|
||||||
os.system(" ".join(["xinput set-prop", dev, prop, " ".join([str(x) for x in [arr[0, 0], arr[0, 1], arr[0, 2], arr[1, 0], arr[1, 1], arr[1, 2], arr[2, 0], arr[2, 1], arr[2, 2]]])]))
|
cmd = " ".join(["xinput set-prop", dev, prop, " ".join([str(x) for x in [arr[0, 0], arr[0, 1], arr[0, 2], arr[1, 0], arr[1, 1], arr[1, 2], arr[2, 0], arr[2, 1], arr[2, 2]]])])
|
||||||
|
print(cmd)
|
||||||
|
os.system(cmd)
|
||||||
#alias tablet2="xinput set-prop 18 156 2.45 0 -0.725 0 2.45 -0.725 0 0 1"
|
#alias tablet2="xinput set-prop 18 156 2.45 0 -0.725 0 2.45 -0.725 0 0 1"
|
||||||
|
|
Loading…
Reference in a new issue