commit 403c95ca181ccd54f36623df30460f01d42b7656 Author: Jeremy Penner Date: Sat Oct 12 19:01:45 2024 -0400 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..fac0647 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# gnome-shell-screenpad + +A simple brightness slider for ASUS Zenbook Duo laptops' second "ScreenPad Plus" screens, that appears in the "Quick Settings" dropdown. + +Requires the [asus-wmi-screenpad](https://github.com/Plippo/asus-wmi-screenpad) or [asus-wmi-screenpad-module](https://github.com/MatthewCash/asus-wmi-screenpad-module) kernel module, which provides the `/sys/class/leds/asus::screenpad/brightness` file. + +This _will_ allow you to quickly turn the second screen back on if it doesn't wake from sleep. diff --git a/extension.js b/extension.js new file mode 100644 index 0000000..141e0e8 --- /dev/null +++ b/extension.js @@ -0,0 +1,60 @@ +/* extension.js + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +import GObject from 'gi://GObject'; +import GLib from 'gi://GLib'; +import Gio from 'gi://Gio'; + +import * as Main from 'resource:///org/gnome/shell/ui/main.js'; + +import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js'; +import {QuickSlider, SystemIndicator} from 'resource:///org/gnome/shell/ui/quickSettings.js'; + +const ScreenpadSlider = GObject.registerClass( + class ScreenpadSlider extends QuickSlider { + constructor() { + super({ iconName: 'keyboard-brightness-symbolic' }); + + this._sliderChangedId = this.slider.connect('notify::value', this._sliderChanged.bind(this)); + this.slider.accessible_name = _('Screenpad'); + this.slider.value = 0.5; + } + + _sliderChanged() { + const byte = Math.round(this.slider.value * 255); + const brightness_file = Gio.File.new_for_path("/sys/class/leds/asus::screenpad/brightness"); + brightness_file.replace_contents(new TextEncoder().encode(byte.toString()), null, false, Gio.FileCreateFlags.NONE, null); + } + } +) + +export default class ScreenpadExtension extends Extension { + enable() { + this._slider = new SystemIndicator(); + this._slider.quickSettingsItems.push(new ScreenpadSlider()); + + Main.panel.statusArea.quickSettings.addExternalIndicator(this._slider, 2); + } + + disable() { + for (const item of this._slider.quickSettingsItems) { + item.destroy(); + } + this._slider.destroy(); + this._slider = null; + } +} diff --git a/metadata.json b/metadata.json new file mode 100644 index 0000000..19421bb --- /dev/null +++ b/metadata.json @@ -0,0 +1,9 @@ +{ + "name": "Screenpad", + "description": "Control Zenbook Duo Screenpad", + "uuid": "screenpad@information-superhighway.net", + "shell-version": [ + "46" + ], + "url": "https://git.information-superhighway.net/SpindleyQ/gnome-shell-screenpad" +}