Skip to content

service/upower: add upower service #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2024
Merged

service/upower: add upower service #3

merged 1 commit into from
Jul 10, 2024

Conversation

bdebiase
Copy link
Contributor

@bdebiase bdebiase commented Jul 6, 2024

Adds a UPower service to interact with system battery devices. I only implemented properties I thought would be useful, but more can be added later on.

This is my first shot at C++ so any suggestions would be greatly appreciated!

Copy link
Member

@outfoxxed outfoxxed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

Looks pretty good overall, just a few UAFs and nitpicks.

@bdebiase bdebiase requested a review from outfoxxed July 8, 2024 16:22
Copy link
Member

@outfoxxed outfoxxed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed a few more things while testing.

Here's my tester if you don't have one, but I assume you do

import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell
import Quickshell.Services.UPower

ShellRoot {
	Component {
		id: comp

		Rectangle {
			required property var modelData;

			implicitWidth: layout.implicitWidth + 10
			implicitHeight: layout.implicitHeight + 10
			color: palette.active.base

			ColumnLayout {
				id: layout

				Label { text: `is display device: ${modelData == UPower.displayDevice}` }
				Label { text: `device type: ${UPowerDeviceType.toString(modelData.type)}` }
				Label { text: `is power supply: ${modelData.powerSupply}` }
				Label { text: `energy: ${modelData.energy}` }
				Label { text: `energy capacity: ${modelData.energyCapacity}` }
				Label { text: `change rate: ${modelData.changeRate}` }
				Label { text: `time to empty: ${modelData.timeToEmpty}` }
				Label { text: `time to full: ${modelData.timeToFull}` }
				Label { text: `percentage: ${modelData.percentage}` }
				Label { text: `is present: ${modelData.isPresent}` }
				Label { text: `state: ${UPowerDeviceState.toString(modelData.state)}` }
				Label { text: `health percentage: ${modelData.healthPercentage}` }
				Label { text: `health supported: ${modelData.healthSupported}` }
				Label { text: `icon name: ${modelData.iconName}` }
				Label { text: `is laptop battery: ${modelData.isLaptopBattery}` }
			}
		}
	}

	FloatingWindow {
		color: contentItem.palette.active.window

		ListView {
			anchors.fill: parent
			spacing: 10

			model: UPower.devices
			delegate: comp
		}

		Loader {
			anchors.right: parent.right
			active: UPower.displayDevice != null

			sourceComponent: BoundComponent {
				sourceComponent: comp
				property var modelData: UPower.displayDevice
			}
		}
	}
}

Copy link
Member

@outfoxxed outfoxxed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this please squash+rebase and it should be good to merge.

@bdebiase bdebiase requested a review from outfoxxed July 10, 2024 18:22
@outfoxxed
Copy link
Member

LGTM, thanks!

@outfoxxed outfoxxed merged commit 24f54f5 into quickshell-mirror:master Jul 10, 2024
@bdebiase bdebiase deleted the service/upower branch July 10, 2024 19:25
@bdebiase
Copy link
Contributor Author

Thanks for everything!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants