qports/qubes-input-proxy/qubes-input-trigger_use-openrc.patch

92 lines
3.2 KiB
Diff

diff --git a/qubes-rpc/qubes-input-trigger.orig b/qubes-rpc/qubes-input-trigger
index 5fa0e5a..0dd3773 100755
--- a/qubes-rpc/qubes-input-trigger.orig
+++ b/qubes-rpc/qubes-input-trigger
@@ -42,48 +42,68 @@ def get_service_name(udevreturn, input_dev):
('ID_INPUT_TOUCHPAD' in udevreturn) or
('QEMU_USB_Tablet' in udevreturn)
) and 'ID_INPUT_KEY' not in udevreturn:
- service = 'qubes-input-sender-tablet'
+ service = 'qubes-input-sender.tablet'
# PiKVM "mouse" is special, as it sends absolute events
elif 'ID_INPUT_MOUSE' in udevreturn and 'ID_USB_VENDOR=PiKVM' in udevreturn:
- service = 'qubes-input-sender-tablet'
+ service = 'qubes-input-sender.tablet'
elif 'ID_INPUT_MOUSE' in udevreturn and 'ID_INPUT_KEY' not in udevreturn:
- service = 'qubes-input-sender-mouse'
+ service = 'qubes-input-sender.mouse'
elif 'ID_INPUT_KEY' in udevreturn and 'ID_INPUT_MOUSE' not in udevreturn:
- service = 'qubes-input-sender-keyboard'
+ service = 'qubes-input-sender.keyboard'
elif 'ID_INPUT_MOUSE' in udevreturn and 'ID_INPUT_KEY' in udevreturn:
- service = 'qubes-input-sender-keyboard-mouse'
+ service = 'qubes-input-sender.keyboardmouse'
if service:
- service = '{}@{}.service'.format(service, input_dev)
+ service = '{}.{}'.format(service, input_dev)
return service
def handle_service(service, action):
- retcode = subprocess.call(
- ["/bin/systemctl", "is-active", "--quiet", "service", service])
+ serviceFile = os.path.join("/etc/init.d", service)
+
+ sudo = []
+ if os.getuid() != 0:
+ sudo = ["sudo"]
+
if action == "add":
- systemctl_action = "start"
+ # create service link is not created
+ serviceFile = os.path.join("/etc/init.d", service)
+ if not os.path.exists(serviceFile):
+ subprocess.call(
+ ["/bin/ln", "-s", "/etc/init.d/qubes-input-sender", serviceFile])
+
# Ignore if service is already started
+ retcode = subprocess.call(
+ ["/sbin/rc-service","--quiet", service, "status"])
if retcode == 0:
return
+
+ subprocess.call(
+ sudo + ["/sbin/service", service, "start"])
+
elif action == "remove":
- systemctl_action = "stop"
+ # Ignore if service does not exist
+ if not os.path.exists(serviceFile):
+ return
+
# Ignore if service is not active
- if retcode != 0:
+ retcode = subprocess.call(
+ ["/sbin/rc-service", "--quiet", service, "status"])
+ if retcode == 3:
return
+
+ subprocess.call(
+ sudo + ["/sbin/service", service, "stop"])
+
+ # remove ln once stopped
+ if os.path.exists(serviceFile):
+ subprocess.call(
+ sudo + ["/bin/rm", serviceFile])
else:
print("Unknown action: %s" % action)
sys.exit(1)
- sudo = []
- if os.getuid() != 0:
- sudo = ["sudo"]
-
- subprocess.call(
- sudo + ["/bin/systemctl", "--no-block", systemctl_action, service])
-
-
def handle_event(input_dev, action, dom0):
udevreturn = None
if 'event' in input_dev: # if filename contains 'event'