Code Monkey home page Code Monkey logo

Comments (12)

JongAnYoo avatar JongAnYoo commented on July 20, 2024

In desktop mode, you can use the sleep function through the power button.

from holoiso.

theVakhovskeIsTaken avatar theVakhovskeIsTaken commented on July 20, 2024

Huh? Can you unpack this and run sudo python powerbutton.py in terminal and send me the output?
powerbutton.zip

I suppose powerbutton handler requires some tuning...

from holoiso.

JongAnYoo avatar JongAnYoo commented on July 20, 2024

Output Here!

[yjaking@SteamOSPC Downloads]$ sudo python powerbutton.py
/dev/input/event15 Microsoft X-Box 360 pad 0
/dev/input/event17 B.O.W Mouse e0:d4:64:da:0c:9f
/dev/input/event16 B.O.W Keyboard e0:d4:64:da:0c:9f
/dev/input/event8 Logitech USB Optical Mouse usb-0000:03:00.4-1.1/input0
/dev/input/event14 HD-Audio Generic Front Headphone ALSA
/dev/input/event13 HD-Audio Generic Mic ALSA
/dev/input/event12 HD-Audio Generic HDMI/DP,pcm=9 ALSA
/dev/input/event11 HD-Audio Generic HDMI/DP,pcm=8 ALSA
/dev/input/event10 HD-Audio Generic HDMI/DP,pcm=7 ALSA
/dev/input/event9 HD-Audio Generic HDMI/DP,pcm=3 ALSA
/dev/input/event7 Microsoft X-Box 360 pad usb-0000:03:00.3-4/input0
/dev/input/event6 PC Speaker isa0061/input0
/dev/input/event5 Video Bus LNXVIDEO/video/input0
/dev/input/event4 Goodix Capacitive TouchScreen input/ts
/dev/input/event3 AT Translated Set 2 keyboard isa0060/serio0/input0
/dev/input/event2 Power Button LNXPWRBN/button/input0
/dev/input/event1 Power Button PNP0C0C/button/input0
/dev/input/event0 Lid Switch PNP0C0D/button/input0

from holoiso.

theVakhovskeIsTaken avatar theVakhovskeIsTaken commented on July 20, 2024

Output Here!

[yjaking@SteamOSPC Downloads]$ sudo python powerbutton.py /dev/input/event15 Microsoft X-Box 360 pad 0 /dev/input/event17 B.O.W Mouse e0:d4:64:da:0c:9f /dev/input/event16 B.O.W Keyboard e0:d4:64:da:0c:9f /dev/input/event8 Logitech USB Optical Mouse usb-0000:03:00.4-1.1/input0 /dev/input/event14 HD-Audio Generic Front Headphone ALSA /dev/input/event13 HD-Audio Generic Mic ALSA /dev/input/event12 HD-Audio Generic HDMI/DP,pcm=9 ALSA /dev/input/event11 HD-Audio Generic HDMI/DP,pcm=8 ALSA /dev/input/event10 HD-Audio Generic HDMI/DP,pcm=7 ALSA /dev/input/event9 HD-Audio Generic HDMI/DP,pcm=3 ALSA /dev/input/event7 Microsoft X-Box 360 pad usb-0000:03:00.3-4/input0 /dev/input/event6 PC Speaker isa0061/input0 /dev/input/event5 Video Bus LNXVIDEO/video/input0 /dev/input/event4 Goodix Capacitive TouchScreen input/ts /dev/input/event3 AT Translated Set 2 keyboard isa0060/serio0/input0 /dev/input/event2 Power Button LNXPWRBN/button/input0 /dev/input/event1 Power Button PNP0C0C/button/input0 /dev/input/event0 Lid Switch PNP0C0D/button/input0

So, let's try tinkering with it then!
Can you run sudo sed -i 's/isa0060\/serio0\/input0/PNP0C0C\/button\/input0/g' /usr/lib/hwsupport/power-button-handler.py and run SteamOS session, then try to use power button?

from holoiso.

JongAnYoo avatar JongAnYoo commented on July 20, 2024

First of all, thank you for your quick response.
You are a wonderful person.

But the results are not good.
Still in the same SteamOS session, pressing the power button does not go into sleep mode.
This is also a common symptom of people using AYA Neo around them.

from holoiso.

JongAnYoo avatar JongAnYoo commented on July 20, 2024

source code is here!

#!/usr/bin/python

import evdev
import threading
import os

powerbuttondev = None

devices = [evdev.InputDevice(path) for path in evdev.list_devices()]
for device in devices:
if device.phys == "PNP0C0C/button/input0":
powerbuttondev = device;
else:
device.close()

longpresstimer = None

def longpress():
os.system( "~/.steam/root/ubuntu12_32/steam -ifrunning steam://longpowerpress" )
global longpresstimer
longpresstimer = None

if powerbuttondev != None:
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()
exit()

print ( "power-button-handler.py: Can't find device for power button!" )

from holoiso.

JongAnYoo avatar JongAnYoo commented on July 20, 2024

I modified the source code arbitrarily

Even after changing to PNP0C0C --> LNXPWRBN and testing, the slim mode did not work.

from holoiso.

JongAnYoo avatar JongAnYoo commented on July 20, 2024

Investigating the event with hexdump, the event that responds when the power button is pressed seems to be 'event2'.

from holoiso.

FayeSpica avatar FayeSpica commented on July 20, 2024

after sudo sed -i 's/isa0060\/serio0\/input0/PNP0C0C\/button\/input0/g' /usr/lib/hwsupport/power-button-handler.py
aya neo shutdown immediately

from holoiso.

FayeSpica avatar FayeSpica commented on July 20, 2024

I clear all codes in power-button-handler.py, it's same

from holoiso.

NightHammer1000 avatar NightHammer1000 commented on July 20, 2024

Can you try this?
#247 (comment)

This worked for the Steam Deck. I am curious if it works on other devices as well.
If yes it means the Gaming Mode follows standard ACPI Events.

from holoiso.

gfl699468 avatar gfl699468 commented on July 20, 2024

I have a oxp mini amd, and find a solution for my device, you could try it:
Step 1.

According #247
Edit:
/etc/systemd/logind.conf
Change:
#HandlePowerKey=poweroff
to
HandlePowerKey=ignore
now, press the power button will not shutdown the device immediately, device only poweroff with long press

Step 2.

Run sudo evtest, select an input and press power button, by doing this on all input, find which eventX fire a event when you press button.
Get phys of the device from cat /proc/bus/input/devices and update the /usr/lib/hwsupport/power-button-handler.py accordingly(or just create the InputDevice with the path '/dev/input/eventX')

Step 2.5.(Maybe only for oxp mini amd)

For oxp mini amd, press power button will not fire a event, it will fire a press event and a release event when you release the button, so long press will never be triggered. An solution is to update /usr/lib/hwsupport/power-button-handler.py script, change logic from detect long press to detect double press

Step 3.

Run ~/.steam/root/ubuntu12_32/steam -ifrunning steam://longpowerpress in ssh brings up the power menu with no problem, but sudo will cause a coredump.
So update /usr/bin/gamescope-session @ line 188,
change

(while true; do
/usr/lib/hwsupport/power-button-handler.py
done) &

to

(while true; do
sudo -E /usr/lib/hwsupport/power-button-handler.py
done) &

should fix the problem

from holoiso.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.