mirror of
https://github.com/ublue-os/bazzite.git
synced 2025-02-25 21:41:02 +00:00
Merge pull request #82 from ublue-os/inhibitor-reengineer
chore: Re-engineer power button inhibitor for gamescope-session
This commit is contained in:
commit
fade0306cf
@ -7,7 +7,7 @@ License: GPLv3
|
||||
URL: https://github.com/ublue-os/bazzite
|
||||
|
||||
Source: https://gitlab.com/evlaV/jupiter-hw-support/-/archive/5cb8f34ea8047bc208ffc4f93c673e31e3811f4d/jupiter-hw-support-5cb8f34ea8047bc208ffc4f93c673e31e3811f4d.tar.gz
|
||||
Source1: power-button-handler.py
|
||||
Source1: power-button-inhibitor.sh
|
||||
Patch0: fedora.patch
|
||||
Patch1: selinux.patch
|
||||
Patch2: https://gitlab.com/popsulfr/steamos-btrfs/-/raw/main/files/usr/lib/hwsupport/steamos-automount.sh.patch
|
||||
@ -23,8 +23,6 @@ Requires: python3-crcmod
|
||||
Requires: python3-click
|
||||
Requires: python3-progressbar2
|
||||
Requires: python3-hid
|
||||
Requires: python3-daemon
|
||||
Requires: python3-psutil
|
||||
Requires: hidapi
|
||||
Requires: dmidecode
|
||||
Requires: jq
|
||||
@ -58,6 +56,7 @@ cp -rv usr/share/* %{buildroot}%{_datadir}
|
||||
cp -rv usr/lib/systemd/system/* %{buildroot}%{_unitdir}/
|
||||
cp usr/lib/hwsupport/cs35l41-dsp1-spk-prot.bin.mod %{buildroot}%{_prefix}/lib/hwsupport/cs35l41-dsp1-spk-prot.bin.mod
|
||||
cp usr/lib/hwsupport/cs35l41-dsp1-spk-prot.bin.orig %{buildroot}%{_prefix}/lib/hwsupport/cs35l41-dsp1-spk-prot.bin.orig
|
||||
cp usr/lib/hwsupport/power-button-handler.py %{buildroot}%{_prefix}/lib/hwsupport/power-button-handler.py
|
||||
cp usr/lib/hwsupport/cirrus-fixup.sh %{buildroot}%{_sbindir}/cirrus-fixup
|
||||
cp usr/lib/hwsupport/ev2_cirrus_alsa_fixups.sh %{buildroot}%{_sbindir}/ev2_cirrus_alsa_fixups
|
||||
cp usr/lib/hwsupport/format-device.sh %{buildroot}%{_sbindir}/format-device
|
||||
@ -67,7 +66,7 @@ cp usr/lib/hwsupport/steamos-automount.sh %{buildroot}%{_sbindir}/steamos-automo
|
||||
cp usr/lib/hwsupport/trim-devices.sh %{buildroot}%{_sbindir}/trim-devices
|
||||
cp -rv usr/lib/udev %{buildroot}%{_prefix}/lib/udev
|
||||
cp -rv usr/bin/* %{buildroot}%{_bindir}
|
||||
cp %{SOURCE1} %{buildroot}%{_bindir}/power-button-handler
|
||||
cp %{SOURCE1} %{buildroot}%{_bindir}/power-button-inhibitor
|
||||
cp -rv usr/lib/systemd/system/* %{buildroot}%{_unitdir}
|
||||
cp -rv etc/* %{buildroot}%{_sysconfdir}
|
||||
# Remove unneeded files
|
||||
|
@ -6,7 +6,7 @@ License: MIT
|
||||
URL: https://github.com/ublue-os/bazzite
|
||||
|
||||
Source: https://gitlab.com/evlaV/%{name}/-/archive/master/%{name}-master.tar.gz
|
||||
Source1: power-button-handler.py
|
||||
Source1: power-button-inhibitor.sh
|
||||
Patch0: fedora.patch
|
||||
Patch1: selinux.patch
|
||||
|
||||
@ -16,8 +16,6 @@ Requires: python3-crcmod
|
||||
Requires: python3-click
|
||||
Requires: python3-progressbar2
|
||||
Requires: python3-hid
|
||||
Requires: python3-daemon
|
||||
Requires: python3-psutil
|
||||
Requires: hidapi
|
||||
Requires: dmidecode
|
||||
Requires: jq
|
||||
@ -51,6 +49,7 @@ cp -rv usr/share/* %{buildroot}%{_datadir}
|
||||
cp -rv usr/lib/systemd/system/* %{buildroot}%{_unitdir}/
|
||||
cp usr/lib/hwsupport/cs35l41-dsp1-spk-prot.bin.mod %{buildroot}%{_prefix}/lib/hwsupport/cs35l41-dsp1-spk-prot.bin.mod
|
||||
cp usr/lib/hwsupport/cs35l41-dsp1-spk-prot.bin.orig %{buildroot}%{_prefix}/lib/hwsupport/cs35l41-dsp1-spk-prot.bin.orig
|
||||
cp usr/lib/hwsupport/power-button-handler.py %{buildroot}%{_prefix}/lib/hwsupport/power-button-handler.py
|
||||
cp usr/lib/hwsupport/cirrus-fixup.sh %{buildroot}%{_sbindir}/cirrus-fixup
|
||||
cp usr/lib/hwsupport/ev2_cirrus_alsa_fixups.sh %{buildroot}%{_sbindir}/ev2_cirrus_alsa_fixups
|
||||
cp usr/lib/hwsupport/format-device.sh %{buildroot}%{_sbindir}/format-device
|
||||
@ -60,7 +59,7 @@ cp usr/lib/hwsupport/steamos-automount.sh %{buildroot}%{_sbindir}/steamos-automo
|
||||
cp usr/lib/hwsupport/trim-devices.sh %{buildroot}%{_sbindir}/trim-devices
|
||||
cp -rv usr/lib/udev %{buildroot}%{_prefix}/lib/udev
|
||||
cp -rv usr/bin/* %{buildroot}%{_bindir}
|
||||
cp %{SOURCE1} %{buildroot}%{_bindir}/power-button-handler
|
||||
cp %{SOURCE1} %{buildroot}%{_bindir}/power-button-inhibitor
|
||||
cp -rv usr/lib/systemd/system/* %{buildroot}%{_unitdir}
|
||||
cp -rv etc/* %{buildroot}%{_sysconfdir}
|
||||
# Remove unneeded files
|
||||
|
@ -1,63 +0,0 @@
|
||||
#!/bin/env python3 -u
|
||||
|
||||
import evdev
|
||||
import threading
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import daemon
|
||||
import psutil
|
||||
|
||||
powerbuttondev = None
|
||||
|
||||
devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
|
||||
for device in devices:
|
||||
if device.phys == "isa0060/serio0/input0":
|
||||
powerbuttondev = device;
|
||||
else:
|
||||
device.close()
|
||||
|
||||
longpresstimer = None
|
||||
|
||||
systemd_inhibit = ['systemd-inhibit',
|
||||
'--what=handle-power-key:handle-suspend-key:handle-hibernate-key',
|
||||
'sleep',
|
||||
'infinity']
|
||||
|
||||
def inhibit():
|
||||
for proc in psutil.process_iter():
|
||||
if systemd_inhibit == proc.cmdline():
|
||||
return
|
||||
|
||||
print ( "Starting inhibitor" )
|
||||
with daemon.DaemonContext():
|
||||
subprocess.call(systemd_inhibit)
|
||||
|
||||
def uninhibit():
|
||||
print ( "Stopping inhibitor" )
|
||||
subprocess.call(['pkill', '-f', ' '.join(systemd_inhibit)])
|
||||
|
||||
def longpress():
|
||||
os.system( "~/.steam/root/ubuntu12_32/steam -ifrunning steam://longpowerpress" )
|
||||
global longpresstimer
|
||||
longpresstimer = None
|
||||
|
||||
if powerbuttondev != None:
|
||||
inhibit()
|
||||
|
||||
for event in powerbuttondev.read_loop():
|
||||
if event.type == evdev.ecodes.EV_KEY and event.code == 116: # KEY_POWER
|
||||
if event.value == 1:
|
||||
longpresstimer = threading.Timer( 1.0, longpress )
|
||||
longpresstimer.start()
|
||||
elif event.value == 0:
|
||||
if longpresstimer != None:
|
||||
os.system( "~/.steam/root/ubuntu12_32/steam -ifrunning steam://shortpowerpress" )
|
||||
longpresstimer.cancel()
|
||||
longpresstimer = None
|
||||
|
||||
powerbuttondev.close()
|
||||
uninhibit()
|
||||
exit()
|
||||
|
||||
print ( "power-button-handler.py: Can't find device for power button!" )
|
2
spec_files/jupiter-hw-support/power-button-inhibitor.sh
Executable file
2
spec_files/jupiter-hw-support/power-button-inhibitor.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/sh
|
||||
systemd-inhibit --what=handle-suspend-key:handle-power-key:handle-hibernate-key --who=gamescope-session --why="gamescope-session handles power button events" sleep infinity
|
@ -7,6 +7,17 @@
|
||||
<vendor>Bazzite</vendor>
|
||||
<vendor_url>https://github.com/ublue-os/bazzite/</vendor_url>
|
||||
|
||||
<action id="org.bazzite.power.button.pkexec">
|
||||
<description>Allow inhibition of power button</description>
|
||||
<icon_name>package-x-generic</icon_name>
|
||||
<defaults>
|
||||
<allow_any>yes</allow_any>
|
||||
<allow_inactive>yes</allow_inactive>
|
||||
<allow_active>yes</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/power-button-inhibitor</annotate>
|
||||
</action>
|
||||
|
||||
<action id="org.bazzite.dmidecode.pkexec">
|
||||
<description>Dump SMBIOS table contents</description>
|
||||
<icon_name>package-x-generic</icon_name>
|
Loading…
x
Reference in New Issue
Block a user