feat(ags): make brightness widget a progress bar
This commit is contained in:
parent
2d9f758dae
commit
aca5725ade
4 changed files with 54 additions and 22 deletions
|
@ -2,35 +2,45 @@ const { Label, Icon, Stack, ProgressBar, Overlay, Box } = ags.Widget;
|
||||||
import { Separator } from '../common.js';
|
import { Separator } from '../common.js';
|
||||||
const { exec } = ags.Utils;
|
const { exec } = ags.Utils;
|
||||||
|
|
||||||
const Indicator = props => Label({
|
const Indicator = props => Icon({
|
||||||
...props,
|
...props,
|
||||||
label: '',
|
size: 28,
|
||||||
connections: [[500, icon => {
|
style: 'margin-left: -5px',
|
||||||
const br = `${exec('brightnessctl get')}`;
|
icon: 'display-brightness-symbolic',
|
||||||
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({
|
const LevelLabel = props => Label({
|
||||||
...props,
|
...props,
|
||||||
className: 'label',
|
className: 'label',
|
||||||
connections: [[500, label => label.label = `${Math.floor(exec('brightnessctl get') / 2.55)}%`]],
|
connections: [[200, label => label.label = `${Math.floor(exec('brightnessctl get') / 2.55)}%`]],
|
||||||
});
|
});
|
||||||
|
|
||||||
const BrightnessModule = () => Box({
|
const BrightnessModule = () => Overlay({
|
||||||
className: 'toggle-off battery',
|
child: ProgressBar({
|
||||||
|
className: 'toggle-off brightness',
|
||||||
|
connections: [
|
||||||
|
[ 200, progress => {
|
||||||
|
let br = exec('brightnessctl get') / 255;
|
||||||
|
if (br > 0.33) {
|
||||||
|
progress.value = br;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
progress.value = 0.33;
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
overlays: [
|
||||||
|
Box({
|
||||||
|
className: 'battery',
|
||||||
|
style: 'color: #CBA6F7;',
|
||||||
children: [
|
children: [
|
||||||
Indicator(),
|
Indicator(),
|
||||||
Separator(12),
|
Separator(2),
|
||||||
LevelLabel(),
|
LevelLabel(),
|
||||||
],
|
],
|
||||||
|
}),
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
export const Brightness = BrightnessModule();
|
export const Brightness = BrightnessModule();
|
||||||
|
|
|
@ -87,3 +87,16 @@
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.brightness {
|
||||||
|
trough {
|
||||||
|
margin-right: -50px;
|
||||||
|
progress {
|
||||||
|
margin-right: 50px;
|
||||||
|
margin-top: -30px;
|
||||||
|
border-radius: 80px;
|
||||||
|
min-height: 37px;
|
||||||
|
background: $bgSecondary;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -103,6 +103,15 @@
|
||||||
.battery .label {
|
.battery .label {
|
||||||
font-size: 20px; }
|
font-size: 20px; }
|
||||||
|
|
||||||
|
.brightness trough {
|
||||||
|
margin-right: -50px; }
|
||||||
|
.brightness trough progress {
|
||||||
|
margin-right: 50px;
|
||||||
|
margin-top: -30px;
|
||||||
|
border-radius: 80px;
|
||||||
|
min-height: 37px;
|
||||||
|
background: rgba(56, 44, 74, 0.8); }
|
||||||
|
|
||||||
.workspaces {
|
.workspaces {
|
||||||
background-color: rgba(40, 42, 54, 0.8);
|
background-color: rgba(40, 42, 54, 0.8);
|
||||||
border-radius: 80px;
|
border-radius: 80px;
|
||||||
|
|
|
@ -231,5 +231,5 @@ bind =, XF86AudioMicMute, exec, swayosd-client --input-volume mute-toggle
|
||||||
bindr = CAPS, Caps_Lock, exec, swayosd-client --caps-lock
|
bindr = CAPS, Caps_Lock, exec, swayosd-client --caps-lock
|
||||||
|
|
||||||
# Brightness control
|
# Brightness control
|
||||||
binde =, XF86MonBrightnessUp, exec, swayosd-client --brightness raise
|
binde =, XF86MonBrightnessUp, exec, swayosd-client --brightness 5
|
||||||
binde =, XF86MonBrightnessDown, exec, swayosd-client --brightness lower
|
binde =, XF86MonBrightnessDown, exec, swayosd-client --brightness -5
|
||||||
|
|
Loading…
Reference in a new issue