feat(ags): add brightness widget
This commit is contained in:
parent
55e3c7f52f
commit
24aded8548
2 changed files with 41 additions and 0 deletions
|
@ -11,6 +11,7 @@ import { NotifButton } from './notif-button.js';
|
|||
import { Clock } from './clock.js';
|
||||
import { SysTray } from './systray.js';
|
||||
import { Batt } from './battery.js';
|
||||
import { Brightness } from './brightness.js';
|
||||
|
||||
export const Bar = Window({
|
||||
name: 'bar',
|
||||
|
@ -44,6 +45,10 @@ export const Bar = Window({
|
|||
|
||||
Separator(12),
|
||||
|
||||
Brightness,
|
||||
|
||||
Separator(12),
|
||||
|
||||
Workspaces,
|
||||
|
||||
],
|
||||
|
|
36
config/ags/js/bar/brightness.js
Normal file
36
config/ags/js/bar/brightness.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
const { Label, Icon, Stack, ProgressBar, Overlay, Box } = ags.Widget;
|
||||
import { Separator } from '../common.js';
|
||||
const { exec } = ags.Utils;
|
||||
|
||||
const Indicator = props => Label({
|
||||
...props,
|
||||
label: '',
|
||||
connections: [[500, icon => {
|
||||
const br = `${exec('brightnessctl get')}`;
|
||||
if (br <= 3) icon.label = "";
|
||||
else if (br <= 38) icon.label = "";
|
||||
else if (br <= 77) icon.label = "";
|
||||
else if (br <= 115) icon.label = "";
|
||||
else if (br <= 153) icon.label = "";
|
||||
else if (br <= 191) icon.label = "";
|
||||
else if (br <= 230) icon.label = "";
|
||||
else icon.label = "";
|
||||
}]],
|
||||
});
|
||||
|
||||
const LevelLabel = props => Label({
|
||||
...props,
|
||||
className: 'label',
|
||||
connections: [[500, label => label.label = `${Math.floor(exec('brightnessctl get') / 2.55)}%`]],
|
||||
});
|
||||
|
||||
const BrightnessModule = () => Box({
|
||||
className: 'toggle-off battery',
|
||||
children: [
|
||||
Indicator(),
|
||||
Separator(12),
|
||||
LevelLabel(),
|
||||
],
|
||||
});
|
||||
|
||||
export const Brightness = BrightnessModule();
|
Loading…
Reference in a new issue