Compare commits
69 Commits
37358ec8d4
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| eeb18679e6 | |||
| 2046adfc79 | |||
| bb8709bdf5 | |||
| 212a6ab426 | |||
| 2622d514c4 | |||
| b8d94b271f | |||
| 7c3cd04c1b | |||
| 6d502ea67e | |||
| 165879eb0d | |||
| ed851b0eed | |||
| 6abaf515ae | |||
| b972354e97 | |||
| dec5642e26 | |||
| 310d396407 | |||
| 4594b55bf4 | |||
| d1581e866f | |||
| c50b5e1ce9 | |||
| bbda532246 | |||
| ead2b06eca | |||
| db0a3b1655 | |||
| 180f571018 | |||
| 707453a513 | |||
| 21c91b0b9c | |||
| b32a63d9b4 | |||
| a9636a4112 | |||
| 18af7036bb | |||
| 310d31e98d | |||
| 6a3995f69a | |||
| bc7a5d7239 | |||
| 596e188c75 | |||
| 9e0ecced8b | |||
| a21babbf8d | |||
| 7b205c761b | |||
| 528dccb255 | |||
| 00cdcd0cc9 | |||
| c78b767958 | |||
| cd13c8d021 | |||
| 78e27a8460 | |||
| fba0e91224 | |||
| e83c347442 | |||
| 87a2e4542e | |||
| d9bdd5c9e8 | |||
| 65c37e636c | |||
| fec87df9c9 | |||
| 96829d0b6a | |||
| b8f26d6965 | |||
| 7342721715 | |||
| ad79872631 | |||
| 2f257a1ee7 | |||
| 25834e99da | |||
| b31e12d148 | |||
| b09e1d680e | |||
| e5ddc47587 | |||
| 7581078bba | |||
| bbc8d22abb | |||
| d82503b4ff | |||
| 67ff81900d | |||
| 3447f5b545 | |||
| 1b3d915de6 | |||
| bd738d600e | |||
| cfed2fb677 | |||
| 8d7c2523f4 | |||
| f108910b87 | |||
| e563470b64 | |||
| ea1b8f558e | |||
| 8c4a6a495c | |||
| c54817edc2 | |||
| 4ceaad99a3 | |||
| 431fa906b1 |
25
README
25
README
@@ -1,16 +1,33 @@
|
||||
Install
|
||||
|
||||
pip install --user -e .
|
||||
|
||||
Requirements:
|
||||
- For volume buttons: libpulse
|
||||
- controldeck
|
||||
- python package justpy, the framework: pip install justpy --upgrade
|
||||
- (optionally) for volume buttons: libpulse
|
||||
- controldeck-gui
|
||||
- render engine
|
||||
- GTK: python-gobject, python-cairo, webkit2gtk>=2.22
|
||||
- QT: qt5-webkit, python-qtpy
|
||||
- QT5: python-pyqt5-webengine, python-pyqt5
|
||||
- QT: pyside2, pyside6
|
||||
|
||||
local:
|
||||
./setup.sh
|
||||
|
||||
Uninstall
|
||||
|
||||
pip uninstall controldeck
|
||||
|
||||
rm ~/.local/share/application/controldeck.desktop
|
||||
rm ~/.config/systemd/user/controldeck.service
|
||||
|
||||
Configuration
|
||||
|
||||
~/.config/controldeck/controldeck.conf
|
||||
See example in example directory.
|
||||
|
||||
Start (autostart) with systemd
|
||||
systemctl --user start controldeck.service
|
||||
systemctl --user enable controldeck.service
|
||||
|
||||
journalctl --user-unit=controldeck -e
|
||||
journalctl --user-unit=controldeck -f
|
||||
|
||||
1377
controldeck.py
Normal file → Executable file
1377
controldeck.py
Normal file → Executable file
File diff suppressed because it is too large
Load Diff
215
controldeck_gui.py
Executable file
215
controldeck_gui.py
Executable file
@@ -0,0 +1,215 @@
|
||||
#!/usr/bin/env python
|
||||
import sys
|
||||
import os
|
||||
import argparse
|
||||
from tkinter import Tk, messagebox
|
||||
import webview
|
||||
from controldeck import config_load, process
|
||||
import threading
|
||||
import time
|
||||
|
||||
def thread_function(name):
|
||||
# print("Thread %s: starting", name)
|
||||
for i in range(10):
|
||||
# print("Thread %s: finishing", name)
|
||||
# p = process("xdotool search --name 'ControlDeck'")
|
||||
# intersection of ControlDeck window name and empty classname
|
||||
p = process("comm -12 <(xdotool search --name 'ControlDeck' | sort) <(xdotool search --classname '^$' | sort)", shell=True)
|
||||
if p:
|
||||
# print(p)
|
||||
# process("xdotool search --name 'ControlDeck' set_window --class 'controldeck'", output=False)
|
||||
# process("xdotool search --name 'ControlDeck' set_window --classname 'controldeck' --class 'ControlDeck' windowunmap windowmap", output=False) # will find to many wrong ids
|
||||
process(f"xdotool set_window --classname 'controldeck' --class 'ControlDeck' {p} windowunmap {p} windowmap {p}", shell=True, output=False)
|
||||
time.sleep(0.1)
|
||||
|
||||
def main(args, pid=-1):
|
||||
config = config_load(conf=args.config)
|
||||
host = config.get('default', 'host', fallback='0.0.0.0')
|
||||
port = config.get('default', 'port', fallback='8000')
|
||||
url = f"http://{host}:{port}/?gui&pid={str(pid)}"
|
||||
try:
|
||||
width = config.getint('gui', 'width', fallback=800)
|
||||
except ValueError as e:
|
||||
width = 800
|
||||
print(f"Error width: {e}. fallback to: {width}")
|
||||
try:
|
||||
height = config.getint('gui', 'height', fallback=600)
|
||||
except ValueError as e:
|
||||
width = 600
|
||||
print(f"Error height: {e}. fallback to {width}")
|
||||
try:
|
||||
x = config.getint('gui', 'x', fallback='')
|
||||
except ValueError as e:
|
||||
x = None
|
||||
print(f"Error x: {e}. fallback to {x}")
|
||||
try:
|
||||
y = config.getint('gui', 'y', fallback='')
|
||||
except ValueError as e:
|
||||
y = None
|
||||
print(f"Error y: {e}. fallback to: {y}")
|
||||
resizable = config.get('gui', 'resizable', fallback='True').title() == 'True'
|
||||
fullscreen = config.get('gui', 'fullscreen', fallback='False').title() == 'True'
|
||||
try:
|
||||
min_width = config.getint('gui', 'min_width', fallback=200)
|
||||
except ValueError as e:
|
||||
min_width = 200
|
||||
print(f"Error min_width: {e}. fallback to: {min_width}")
|
||||
try:
|
||||
min_height = config.getint('gui', 'min_height', fallback=100)
|
||||
except ValueError as e:
|
||||
min_height = 100
|
||||
print(f"Error min_height: {e}. fallback to: {min_height}")
|
||||
min_size = (min_width, min_height)
|
||||
frameless = config.get('gui', 'frameless', fallback='False').title() == 'True'
|
||||
minimized = config.get('gui', 'minimized', fallback='False').title() == 'True'
|
||||
maximized = config.get('gui', 'maximized', fallback='False').title() == 'True'
|
||||
on_top = config.get('gui', 'always_on_top', fallback='False').title() == 'True'
|
||||
confirm_close = config.get('gui', 'confirm_close', fallback='False').title() == 'True'
|
||||
transparent = config.get('gui', 'transparent', fallback='True').title() == 'True'
|
||||
gui_type = config.get('gui', 'gui_type', fallback=None)
|
||||
gui_type = gui_type if gui_type != "" else None
|
||||
menu = config.get('gui', 'menu', fallback='True').title() == 'True'
|
||||
if args.debug:
|
||||
print(f"config file [default]: {config.items('default')}")
|
||||
print(f"config file [gui]: {config.items('gui')}")
|
||||
|
||||
#controldeck_process = process("ps --no-headers -C controldeck")
|
||||
controldeck_process = process("ps --no-headers -C controldeck || ps aux | grep -e 'python.*controldeck.py' | grep -v grep", shell=True, output=True)
|
||||
|
||||
if args.start and controldeck_process == "":
|
||||
cmd = "controldeck"
|
||||
cmd += " --config={args.config}" if args.config else ""
|
||||
print(cmd)
|
||||
process(cmd, shell=True, output=False)
|
||||
|
||||
elif controldeck_process == "":
|
||||
# cli output
|
||||
print("controldeck is not running!")
|
||||
|
||||
# gui output
|
||||
# Tkinter must have a root window. If you don't create one, one will be created for you. If you don't want this root window, create it and then hide it:
|
||||
root = Tk()
|
||||
root.withdraw()
|
||||
messagebox.showinfo("ControlDeck", "controldeck is not running!")
|
||||
# Other option would be to use the root window to display the information (Label, Button)
|
||||
|
||||
sys.exit(2)
|
||||
|
||||
window = webview.create_window(
|
||||
title="ControlDeck",
|
||||
url=url,
|
||||
html=None,
|
||||
js_api=None,
|
||||
width=width,
|
||||
height=height,
|
||||
x=x,
|
||||
y=y,
|
||||
screen=None,
|
||||
resizable=resizable,
|
||||
fullscreen=fullscreen,
|
||||
min_size=min_size,
|
||||
hidden=False,
|
||||
frameless=frameless,
|
||||
easy_drag=True,
|
||||
focus=True,
|
||||
minimized=minimized,
|
||||
maximized=maximized,
|
||||
on_top=on_top,
|
||||
confirm_close=confirm_close,
|
||||
background_color='#000000',
|
||||
transparent=transparent, # TODO: bug in qt; menu bar is transparent
|
||||
text_select=False,
|
||||
zoomable=False, # zoom via js
|
||||
draggable=False,
|
||||
vibrancy=False,
|
||||
localization=None,
|
||||
)
|
||||
x = threading.Thread(target=thread_function, args=(1,))
|
||||
x.start()
|
||||
|
||||
def menu_reload():
|
||||
window = webview.active_window()
|
||||
if window:
|
||||
url = window.get_current_url()
|
||||
window.load_url(url)
|
||||
print(window.get_current_url())
|
||||
print(window)
|
||||
print(dir(window))
|
||||
def menu_zoomin():
|
||||
window = webview.active_window()
|
||||
if window:
|
||||
zoom = window.evaluate_js('document.documentElement.style.zoom')
|
||||
if zoom == "":
|
||||
zoom = 1.0
|
||||
else:
|
||||
zoom = float(zoom)
|
||||
zoom += 0.1
|
||||
print(f"zoom-in: {zoom}")
|
||||
window.evaluate_js(f'document.documentElement.style.zoom = {zoom}')
|
||||
print(f"set document.documentElement.style.zoom = {zoom}")
|
||||
def menu_zoomout():
|
||||
window = webview.active_window()
|
||||
if window:
|
||||
zoom = window.evaluate_js('document.documentElement.style.zoom')
|
||||
if zoom == "":
|
||||
zoom = 1.0
|
||||
else:
|
||||
zoom = float(zoom)
|
||||
zoom -= 0.1
|
||||
print(f"zoom-out: {zoom}")
|
||||
window.evaluate_js(f'document.documentElement.style.zoom = {zoom}')
|
||||
print(f"set document.documentElement.style.zoom = {zoom}")
|
||||
def menu_zoomreset():
|
||||
window = webview.active_window()
|
||||
if window:
|
||||
zoom = 1.0
|
||||
print(f"zoom-reset: {zoom}")
|
||||
window.evaluate_js(f'document.documentElement.style.zoom = {zoom}')
|
||||
print(f"set document.documentElement.style.zoom = {zoom}")
|
||||
menu_items = []
|
||||
if menu:
|
||||
menu_items = [webview.menu.Menu(
|
||||
'Main', [
|
||||
webview.menu.MenuAction('Reload', menu_reload),
|
||||
webview.menu.MenuAction('zoom +', menu_zoomin),
|
||||
webview.menu.MenuAction('zoom -', menu_zoomout),
|
||||
webview.menu.MenuAction('zoom reset', menu_zoomreset),
|
||||
]
|
||||
)]
|
||||
# TODO: zoom reset on reload (both from menu and within justpy)
|
||||
# TODO: add zoom in config
|
||||
# TODO: move zoom logic to justpy but then it is fix for all,
|
||||
# maybe better a zoom argument in url address
|
||||
|
||||
def win_func(window):
|
||||
print(window.get_current_url())
|
||||
webview.start(
|
||||
func=win_func,
|
||||
args=window,
|
||||
gui=gui_type, # TODO: bug in qt; any menu action is always the last action
|
||||
debug=args.debug,
|
||||
menu=menu_items,
|
||||
)
|
||||
|
||||
def cli():
|
||||
parser = argparse.ArgumentParser(
|
||||
description=__doc__, prefix_chars='-',
|
||||
formatter_class=argparse.RawTextHelpFormatter,
|
||||
)
|
||||
parser.add_argument('-c', '--config', nargs='?', type=str, default='',
|
||||
help="Specify a path to a custom config file (default: ~/.config/controldeck/controldeck.conf)")
|
||||
parser.add_argument('-s', '--start', action="store_true",
|
||||
help="Start also controldeck program")
|
||||
parser.add_argument('-v', '--verbose', action="store_true", help="Verbose output")
|
||||
parser.add_argument('-D', '--debug', action='store_true', help=argparse.SUPPRESS)
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.debug:
|
||||
print(args)
|
||||
|
||||
main(args, pid=os.getpid())
|
||||
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
sys.exit(cli())
|
||||
BIN
data/controldeck-48.png
Normal file
BIN
data/controldeck-48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
8
data/controldeck.desktop
Normal file
8
data/controldeck.desktop
Normal file
@@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Name=ControlDeck
|
||||
Exec=/usr/bin/controldeck-gui
|
||||
Terminal=false
|
||||
Type=Application
|
||||
StartupNotify=true
|
||||
StartupWMClass=controldeck
|
||||
Icon=controldeck
|
||||
7
data/controldeck.desktop.local
Normal file
7
data/controldeck.desktop.local
Normal file
@@ -0,0 +1,7 @@
|
||||
[Desktop Entry]
|
||||
Name=ControlDeck
|
||||
Exec=${HOME}/.local/bin/controldeck-gui
|
||||
Terminal=false
|
||||
Type=Application
|
||||
StartupNotify=true
|
||||
StartupWMClass=controldeck
|
||||
22
data/controldeck.service
Normal file
22
data/controldeck.service
Normal file
@@ -0,0 +1,22 @@
|
||||
[Unit]
|
||||
Description=ControlDeck
|
||||
ConditionFileIsExecutable=/usr/bin/controldeck
|
||||
After=systemd-user-sessions.service getty@tty1.service plymouth-quit.service systemd-logind.service network.target
|
||||
PartOf=graphical-session.target
|
||||
|
||||
[Service]
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
# add a pause to assure /etc/X11/xinit/xinitrc.d/50-systemd-user.sh to run
|
||||
# this will add DISPLAY and XAUTHORITY env
|
||||
# ExecStartPre=/bin/sleep 5
|
||||
ExecStartPre=/bin/sh -c '(while test ! -v DISPLAY -o ! -v XAUTHORITY; do echo "wait for DISPLAY and XAUTHORITY"; sleep 2; done; echo "DISPLAY and XAUTHORITY found");'
|
||||
# allowed time for the start
|
||||
TimeoutStartSec=30
|
||||
ExecStart=/usr/bin/controldeck -D
|
||||
Restart=on-failure
|
||||
RestartSec=4
|
||||
StandardOutput=journal
|
||||
|
||||
[Install]
|
||||
#WantedBy=default.target
|
||||
WantedBy=graphical-session.target
|
||||
16
data/controldeck.service.local
Normal file
16
data/controldeck.service.local
Normal file
@@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=ControlDeck
|
||||
ConditionFileIsExecutable=%h/.local/bin/controldeck
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Environment=PYTHONUNBUFFERED=1
|
||||
TimeoutStartSec=30
|
||||
#ExecStartPre=/bin/sh -c 'source /etc/profile'
|
||||
ExecStart=%h/.local/bin/controldeck -D
|
||||
Restart=on-failure
|
||||
RestartSec=4
|
||||
StandardOutput=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -1,20 +1,105 @@
|
||||
# Examples:
|
||||
#
|
||||
# [N.volume.NAME]
|
||||
# name = sink_name
|
||||
# : N. optional group/row specification
|
||||
# : NAME name of the button
|
||||
# : name sink name, see name with either:
|
||||
# pactl list sinks short
|
||||
# pamixer --list-sinks
|
||||
# [TAB:N.empty.NAME]
|
||||
# : TAB optional tab name to specify tab group
|
||||
# : N. optional number to specify group/row
|
||||
# : NAME id of the empty spot
|
||||
#
|
||||
# [N.button.NAME]
|
||||
# command = shell command
|
||||
# second command
|
||||
# ...
|
||||
# : N. optional group/row specification
|
||||
# : NAME name of the button
|
||||
# : command command(s) to run
|
||||
# [TAB:N.label.NAME]
|
||||
# : TAB optional tab name to specify tab group
|
||||
# : N. optional number to specify group/row
|
||||
# : NAME id, name of the label
|
||||
#
|
||||
# [TAB:N.sink.NAME]
|
||||
# : TAB optional tab name to specify tab group
|
||||
# : N. optional number to specify group/row
|
||||
# : NAME sink id name, see name with either:
|
||||
# pactl list sinks short
|
||||
# pamixer --list-sinks
|
||||
# description = text for the sink
|
||||
#
|
||||
# [TAB:N.source.NAME]
|
||||
# : TAB optional tab name to specify tab group
|
||||
# : N. optional number to specify group/row
|
||||
# : NAME source id name, see name with either:
|
||||
# pactl list sources short
|
||||
# pamixer --list-sources
|
||||
# description = text for the source
|
||||
#
|
||||
# [TAB:N.sink-inputs]
|
||||
# : TAB optional tab name to specify tab group
|
||||
# : N. optional number to specify group/row
|
||||
#
|
||||
# [TAB:N.button.NAME]
|
||||
# : TAB optional tab name to specify tab group
|
||||
# : N. optional group/row specification
|
||||
# : NAME id, name of the button
|
||||
# text-alt = optional alternative burron text
|
||||
# color-fg = foreground color as hex color code, e.g. #aa5500
|
||||
# color-bg = background color as hex color code, e.g. #0055aa
|
||||
# command = command(s) to run, seperated by new lines: shell command
|
||||
# second command ...
|
||||
# command-alt = optinal back-switch command(s) to run: shell command ...
|
||||
# state-alt = string to define the alternative state (pressed)
|
||||
# state-command = command to get the state: shell command ...
|
||||
# icon = add icon in front of NAME, e.g. fas fa-play
|
||||
# icon-alt = optional alternative icon
|
||||
# image = absolte path to image file (svg, png)
|
||||
# image-alt = optional alternative absolue path to image file
|
||||
|
||||
# [TAB:N.slider.NAME]
|
||||
# : TAB optional tab name to specify tab group
|
||||
# : N. optional group/row specification
|
||||
# : NAME id, name of the button
|
||||
# description = text for the slider
|
||||
# icon = add icon in front of slider, e.g. tune
|
||||
# min = minimum int value, e.g. 0
|
||||
# max = maximum int value, e.g. 100
|
||||
# step = step size, e.g. 1
|
||||
# state-command = command to get the state: shell command
|
||||
# command = command to run to get the value, using {value} in the command to
|
||||
# interpolate the value: shell command
|
||||
|
||||
[default]
|
||||
host = 0.0.0.0
|
||||
port = 8000
|
||||
# status = False
|
||||
# volume-decrease-icon = fas fa-volume-down
|
||||
# volume-increase-icon = fas fa-volume-up
|
||||
# volume-mute-icon = fas fa-volume-off
|
||||
# volume-mute-icon-alt = fas fa-volume-mute
|
||||
# volume-decrease-image =
|
||||
# volume-increase-image =
|
||||
# volume-mute-image =
|
||||
# volume-mute-image-alt =
|
||||
# mic-decrease-icon = fas fa-volume-down
|
||||
# mic-increase-icon = fas fa-volume-up
|
||||
# mic-mute-icon = fas fa-microphone-alt
|
||||
# mic-mute-icon-alt = fas fa-microphone-alt-slash
|
||||
# mic-decrease-image =
|
||||
# mic-increase-image =
|
||||
# mic-mute-image =
|
||||
# mic-mute-image-alt =
|
||||
|
||||
[gui]
|
||||
width = 800
|
||||
height = 600
|
||||
# x and y specifying the window coordinate (empty = centered)
|
||||
x =
|
||||
y =
|
||||
resizable = True
|
||||
fullscreen = False
|
||||
min_width = 200
|
||||
min_height = 100
|
||||
frameless = False
|
||||
minimized = False
|
||||
maximized = False
|
||||
always_on_top = False
|
||||
confirm_close = False
|
||||
transparent = True
|
||||
# gui_type: qt, gtk, cef, mshtml, edgechromium. or set env PYWEBVIEW_GUI
|
||||
gui_type =
|
||||
menu = True
|
||||
|
||||
[4.button.Test]
|
||||
command = notify-send -a foo baz
|
||||
|
||||
16
setup.cfg
Normal file
16
setup.cfg
Normal file
@@ -0,0 +1,16 @@
|
||||
[metadata]
|
||||
name = ControlDeck
|
||||
version = file: VERSION
|
||||
|
||||
[options]
|
||||
install_requires =
|
||||
justpy
|
||||
pywebview
|
||||
py_modules =
|
||||
controldeck
|
||||
controldeck_gui
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
controldeck = controldeck:cli
|
||||
controldeck-gui = controldeck_gui:cli
|
||||
8
setup.py
8
setup.py
@@ -1,8 +1,2 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='ControlDeck',
|
||||
py_modules=['controldeck'],
|
||||
entry_points={
|
||||
'console_scripts': ['controldeck = controldeck:main', ],},
|
||||
)
|
||||
setup()
|
||||
|
||||
10
setup.sh
Executable file
10
setup.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
pip install --user -e .
|
||||
|
||||
mkdir -p $HOME/.local/share/applications
|
||||
#ln -sf $PWD/data/controldeck.desktop $HOME/.local/share/applications/controldeck.desktop
|
||||
cp data/controldeck.desktop.local $HOME/.local/share/applications/controldeck.desktop
|
||||
sed -i "s|\${HOME}|${HOME}|" ~/.local/share/applications/controldeck.desktop
|
||||
mkdir -p $HOME/.config/systemd/user
|
||||
ln -sf $PWD/data/controldeck.service.local $HOME/.config/systemd/user/controldeck.service
|
||||
#cp data/controldeck.service $HOME/.config/systemd/user/controldeck.service
|
||||
Reference in New Issue
Block a user