add pid and start flag for gui, add systemd service file and .desktop file with new setup.sh
This commit is contained in:
7
README
7
README
@@ -1,6 +1,6 @@
|
|||||||
Install
|
Install
|
||||||
|
|
||||||
pip install --user -e .
|
./setup.sh
|
||||||
|
|
||||||
Requirements:
|
Requirements:
|
||||||
- For volume buttons: libpulse
|
- For volume buttons: libpulse
|
||||||
@@ -14,3 +14,8 @@ Configuration
|
|||||||
|
|
||||||
~/.config/controldeck/controldeck.conf
|
~/.config/controldeck/controldeck.conf
|
||||||
See example in example directory.
|
See example in example directory.
|
||||||
|
|
||||||
|
systemctl --user start controldeck.service
|
||||||
|
systemctl --user enable controldeck.service
|
||||||
|
|
||||||
|
journalctl --user-unit=controldeck -e
|
||||||
|
|||||||
@@ -342,16 +342,23 @@ async def reload_all_instances(self, msg):
|
|||||||
await page.reload()
|
await page.reload()
|
||||||
|
|
||||||
async def kill_gui(self, msg):
|
async def kill_gui(self, msg):
|
||||||
await process("pkill controldeck-gui")
|
if 'pid' in msg.page.request.query_params:
|
||||||
|
pid = msg.page.request.query_params.get('pid')
|
||||||
|
await process(f"kill {pid}")
|
||||||
|
else:
|
||||||
|
await process("pkill controldeck-gui")
|
||||||
|
|
||||||
def ishexcolor(code):
|
def ishexcolor(code):
|
||||||
return bool(search(r'^#(?:[0-9a-fA-F]{3}){1,2}$', code))
|
return bool(search(r'^#(?:[0-9a-fA-F]{3}){1,2}$', code))
|
||||||
|
|
||||||
@SetRoute('/')
|
@SetRoute('/')
|
||||||
def application(request):
|
def application(request):
|
||||||
|
|
||||||
wp = WebPage(title=APP_NAME, body_classes="bg-gray-900")
|
wp = WebPage(title=APP_NAME, body_classes="bg-gray-900")
|
||||||
wp.page_type = 'main'
|
wp.page_type = 'main'
|
||||||
wp.head_html = '<meta name="viewport" content="width=device-width, initial-scale=1">'
|
wp.head_html = '<meta name="viewport" content="width=device-width, initial-scale=1">'
|
||||||
|
# can be accessed via msg.page.request
|
||||||
|
wp.request = request
|
||||||
|
|
||||||
menu = Div(classes="fixed bottom-0 right-0 p-1 grid grid-col-1 select-none text-gray-500", a=wp)
|
menu = Div(classes="fixed bottom-0 right-0 p-1 grid grid-col-1 select-none text-gray-500", a=wp)
|
||||||
I(classes="w-10 h-10 w-1 fa-2x fa-fw fas fa-redo-alt", click=reload, a=menu)
|
I(classes="w-10 h-10 w-1 fa-2x fa-fw fas fa-redo-alt", click=reload, a=menu)
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import sys
|
import sys
|
||||||
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
from webview import create_window, start
|
from webview import create_window, start
|
||||||
from controldeck import config_load, process
|
from controldeck import config_load, process
|
||||||
|
|
||||||
def main(conf=''):
|
def main(args, pid=-1):
|
||||||
if process("ps -ef | grep -i controldeck | grep -v controldeck-gui | grep -v grep") == "":
|
if args.start and \
|
||||||
|
process("ps -ef | grep -i controldeck | grep -v controldeck-gui | grep -v grep") == "":
|
||||||
process("controldeck &", output=False)
|
process("controldeck &", output=False)
|
||||||
|
|
||||||
config = config_load(conf=conf)
|
config = config_load(conf=args.config)
|
||||||
url = config.get('gui', 'url', fallback='http://0.0.0.0:8000') + "/?gui"
|
url = config.get('gui', 'url', fallback='http://0.0.0.0:8000') + "/?gui&pid=" + str(pid)
|
||||||
try:
|
try:
|
||||||
width = int(config.get('gui', 'width', fallback=800))
|
width = int(config.get('gui', 'width', fallback=800))
|
||||||
except ValueError as e:
|
except ValueError as e:
|
||||||
@@ -76,14 +78,16 @@ def cli():
|
|||||||
)
|
)
|
||||||
parser.add_argument('-c', '--config', nargs='?', type=str, default='',
|
parser.add_argument('-c', '--config', nargs='?', type=str, default='',
|
||||||
help="Specify a path to a custom config file (default: ~/.config/controldeck/controldeck.conf)")
|
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('-v', '--verbose', action="store_true", help="Verbose output")
|
||||||
parser.add_argument('-D', '--debug', dest='debug', action='store_true', help=argparse.SUPPRESS)
|
parser.add_argument('-D', '--debug', action='store_true', help=argparse.SUPPRESS)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if args.debug:
|
if args.debug:
|
||||||
print(args)
|
print(args)
|
||||||
|
|
||||||
main(conf=args.config)
|
main(args, pid=os.getpid())
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|||||||
7
data/controldeck.desktop
Normal file
7
data/controldeck.desktop
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=ControlDeck
|
||||||
|
Exec=${HOME}/.local/bin/controldeck-gui
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
StartupNotify=true
|
||||||
|
StartupWMClass=controldeck
|
||||||
12
data/controldeck.service
Normal file
12
data/controldeck.service
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=ControlDeck
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment=PYTHONUNBUFFERED=1
|
||||||
|
ExecStart=%h/.local/bin/controldeck
|
||||||
|
Restart=always
|
||||||
|
RestartSec=10
|
||||||
|
StandardOutput=journal
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
@@ -7,9 +7,9 @@ install_requires =
|
|||||||
pywebview
|
pywebview
|
||||||
py_modules =
|
py_modules =
|
||||||
controldeck
|
controldeck
|
||||||
controldeck-gui
|
controldeck_gui
|
||||||
|
|
||||||
[options.entry_points]
|
[options.entry_points]
|
||||||
console_scripts =
|
console_scripts =
|
||||||
controldeck = controldeck:main
|
controldeck = controldeck:main
|
||||||
controldeck-gui = controldeck_gui:main
|
controldeck-gui = controldeck_gui:cli
|
||||||
|
|||||||
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 $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 $HOME/.config/systemd/user/controldeck.service
|
||||||
|
#cp data/controldeck.service $HOME/.config/systemd/user/controldeck.service
|
||||||
Reference in New Issue
Block a user