A simple pyudev script to detect if the dGPU is in low power state or not for the Framework Laptop 16; with dGPU attached.
- You need to pip install pyudev.
- Card 1 is assumed to be dGPU, card 2 is assumed to be UMA...change to meet your own needs. (This can be edited into whatever you like, see below for section you can tweak to meet your needs - but uneeded for Framework Laptop 16 with dGPU.)
Below is code I found is correct for a recent Ubuntu LTS install - note card 0 and card 1 in this case.
context = Context()
for device in context.list_devices(subsystem='drm', DEVTYPE='drm_minor'):
# Attempt to dynamically determine which DRM devices correspond to UMA and dGPU
if 'card0' in device.sys_path:
cards['dGPU'] = device.sys_path.split('/')[-1]
elif 'card1' in device.sys_path:
cards['UMA'] = device.sys_path.split('/')[-1]
- Data pulled from /sys/class/drm/ giving us event specific driven data.
- Lists power control as On/Off/Auto.
- Vendor/Device data.
- uevent driver.
- Time suspended and active.
sudo dnf install git pip -y && pip install pyudev
sudo apt update && sudo apt install git pip -y && pip install pyudev
git clone https://github.com/FrameworkComputer/dgpu-power-state-linux.git && cd dgpu-power-state-linux && python3 gpu-power-state-Fedora.py
git clone https://github.com/FrameworkComputer/dgpu-power-state-linux.git && cd dgpu-power-state-linux && python3 gpu-power-state-Ubuntu.py