koeqaife / hyprland-material-you

Dynamic and elegant desktop setup inspired by Material You, featuring auto-generated colors, fluid animations, and ripple effects for a cohesive, customizable user experience.
GNU General Public License v3.0
485 stars 22 forks source link

Power Management #92

Open Madcliff opened 1 month ago

Madcliff commented 1 month ago

Might it be possible to get a power management widget to simplify changing the current power governor?

Would be nice to have an easy UI option for putting my laptop into battery saver mode.

koeqaife commented 1 month ago

I'll probably add that feature later

Madcliff commented 1 month ago

Thanks it would be very useful.

Madcliff commented 2 weeks ago

So, I noticed that PPD has an AGS plugin, so I wrote the following and inserted it into bar.ts

const powerProfiles = await Service.import('powerprofiles')
function PowerProfileButton() {
    return Widget.Button({
        class_name: "clock",
        child: Widget.Box({
            orientation: Gtk.Orientation.VERTICAL,
            children: [
                Widget.Label({
                    class_name: "active_profile",
                    label: powerProfiles.bind('active_profile'),
                })
            ]
        }),
        on_clicked: () => {
            switch (powerProfiles.active_profile) {
                case 'balanced':
                    powerProfiles.active_profile = 'performance';
                    break;
                case 'performance':
                    powerProfiles.active_profile = 'power-saver';
                break;                    
                default:
                    powerProfiles.active_profile = 'balanced';
                    break;
            };
        },
    });
}