feat(ags bar): move some buttons to hover revs with qs button
This commit is contained in:
parent
45b486b7a1
commit
559234cbba
7 changed files with 191 additions and 85 deletions
|
@ -1,11 +1,9 @@
|
||||||
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
|
import Audio from 'resource:///com/github/Aylur/ags/service/audio.js';
|
||||||
|
|
||||||
import { Label, Box, Icon } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { Label, Box, EventBox, Icon, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
|
|
||||||
|
|
||||||
import { SpeakerIcon } from '../../misc/audio-icons.js';
|
import { SpeakerIcon } from '../../misc/audio-icons.js';
|
||||||
import Separator from '../../misc/separator.js';
|
import Separator from '../../misc/separator.js';
|
||||||
import EventBox from '../../misc/cursorbox.js';
|
|
||||||
|
|
||||||
|
|
||||||
const SpeakerIndicator = (props) => Icon({
|
const SpeakerIndicator = (props) => Icon({
|
||||||
|
@ -24,17 +22,35 @@ const SpeakerPercentLabel = (props) => Label({
|
||||||
|
|
||||||
const SPACING = 5;
|
const SPACING = 5;
|
||||||
|
|
||||||
export default () => EventBox({
|
export default () => {
|
||||||
className: 'toggle-off',
|
const rev = Revealer({
|
||||||
|
transition: 'slide_right',
|
||||||
onPrimaryClickRelease: () => execAsync(['pavucontrol']).catch(print),
|
|
||||||
|
|
||||||
child: Box({
|
child: Box({
|
||||||
className: 'audio',
|
|
||||||
children: [
|
children: [
|
||||||
SpeakerIndicator(),
|
|
||||||
Separator(SPACING),
|
Separator(SPACING),
|
||||||
SpeakerPercentLabel(),
|
SpeakerPercentLabel(),
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const widget = EventBox({
|
||||||
|
onHover: () => {
|
||||||
|
rev.revealChild = true;
|
||||||
|
},
|
||||||
|
onHoverLost: () => {
|
||||||
|
rev.revealChild = false;
|
||||||
|
},
|
||||||
|
child: Box({
|
||||||
|
className: 'audio',
|
||||||
|
children: [
|
||||||
|
SpeakerIndicator(),
|
||||||
|
|
||||||
|
rev,
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.rev = rev;
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
};
|
||||||
|
|
|
@ -1,13 +1,24 @@
|
||||||
import Battery from 'resource:///com/github/Aylur/ags/service/battery.js';
|
import Battery from 'resource:///com/github/Aylur/ags/service/battery.js';
|
||||||
|
|
||||||
import { Label, Icon, Box } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { Box, EventBox, Icon, Label, Overlay, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
|
|
||||||
import Separator from '../../misc/separator.js';
|
import Separator from '../../misc/separator.js';
|
||||||
|
|
||||||
const LOW_BATT = 20;
|
const LOW_BATT = 20;
|
||||||
|
|
||||||
|
|
||||||
const Indicator = () => Icon({
|
const NumOverlay = () => Label({
|
||||||
|
className: 'bg-text',
|
||||||
|
hpack: 'center',
|
||||||
|
vpack: 'center',
|
||||||
|
connections: [[Battery, (self) => {
|
||||||
|
self.label = `${Math.floor(Battery.percent / 10)}`;
|
||||||
|
self.visible = !Battery.charging;
|
||||||
|
}]],
|
||||||
|
});
|
||||||
|
|
||||||
|
const Indicator = (overlay) => Overlay({
|
||||||
|
child: Icon({
|
||||||
className: 'battery-indicator',
|
className: 'battery-indicator',
|
||||||
|
|
||||||
binds: [['icon', Battery, 'icon-name']],
|
binds: [['icon', Battery, 'icon-name']],
|
||||||
|
@ -17,6 +28,8 @@ const Indicator = () => Icon({
|
||||||
self.toggleClassName('charged', Battery.charged);
|
self.toggleClassName('charged', Battery.charged);
|
||||||
self.toggleClassName('low', Battery.percent < LOW_BATT);
|
self.toggleClassName('low', Battery.percent < LOW_BATT);
|
||||||
}]],
|
}]],
|
||||||
|
}),
|
||||||
|
overlays: [overlay],
|
||||||
});
|
});
|
||||||
|
|
||||||
const LevelLabel = (props) => Label({
|
const LevelLabel = (props) => Label({
|
||||||
|
@ -30,12 +43,44 @@ const LevelLabel = (props) => Label({
|
||||||
|
|
||||||
const SPACING = 5;
|
const SPACING = 5;
|
||||||
|
|
||||||
export default () => Box({
|
export default () => {
|
||||||
className: 'toggle-off battery',
|
const rev1 = NumOverlay();
|
||||||
|
const rev = Revealer({
|
||||||
|
transition: 'slide_right',
|
||||||
|
child: Box({
|
||||||
children: [
|
children: [
|
||||||
Indicator(),
|
|
||||||
Separator(SPACING),
|
Separator(SPACING),
|
||||||
LevelLabel(),
|
LevelLabel(),
|
||||||
],
|
],
|
||||||
});
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const widget = EventBox({
|
||||||
|
onHover: () => {
|
||||||
|
rev.revealChild = true;
|
||||||
|
|
||||||
|
if (!Battery.charging) {
|
||||||
|
rev1.visible = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onHoverLost: () => {
|
||||||
|
rev.revealChild = false;
|
||||||
|
|
||||||
|
if (!Battery.charging) {
|
||||||
|
rev1.visible = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
child: Box({
|
||||||
|
className: 'battery',
|
||||||
|
children: [
|
||||||
|
Indicator(rev1),
|
||||||
|
|
||||||
|
rev,
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.rev = rev;
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
};
|
||||||
|
|
|
@ -1,21 +1,20 @@
|
||||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
|
|
||||||
import { Box, Icon, Label } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { Box, EventBox, Icon, Label, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
|
|
||||||
|
import Separator from '../../misc/separator.js';
|
||||||
|
|
||||||
const DEFAULT_KB = 'at-translated-set-2-keyboard';
|
const DEFAULT_KB = 'at-translated-set-2-keyboard';
|
||||||
|
|
||||||
|
|
||||||
export default () => Box({
|
export default () => {
|
||||||
className: 'toggle-off',
|
const rev = Revealer({
|
||||||
css: 'padding: 0 10px;',
|
transition: 'slide_right',
|
||||||
|
child: Box({
|
||||||
children: [
|
children: [
|
||||||
Icon({
|
Separator(4),
|
||||||
icon: 'input-keyboard-symbolic',
|
|
||||||
css: 'margin-right: 4px;',
|
|
||||||
}),
|
|
||||||
|
|
||||||
Label({
|
Label({
|
||||||
|
css: 'font-size: 20px;',
|
||||||
connections: [[Hyprland, (self, _n, layout) => {
|
connections: [[Hyprland, (self, _n, layout) => {
|
||||||
if (layout) {
|
if (layout) {
|
||||||
if (layout === 'error') {
|
if (layout === 'error') {
|
||||||
|
@ -34,7 +33,8 @@ export default () => Box({
|
||||||
|
|
||||||
layout = kb['active_keymap'];
|
layout = kb['active_keymap'];
|
||||||
|
|
||||||
const shortName = layout.match(/\(([A-Za-z]+)\)/);
|
const shortName = layout
|
||||||
|
.match(/\(([A-Za-z]+)\)/);
|
||||||
|
|
||||||
self.label = shortName ? shortName[1] : layout;
|
self.label = shortName ? shortName[1] : layout;
|
||||||
}).catch(print);
|
}).catch(print);
|
||||||
|
@ -42,4 +42,30 @@ export default () => Box({
|
||||||
}, 'keyboard-layout']],
|
}, 'keyboard-layout']],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
});
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
const widget = EventBox({
|
||||||
|
onHover: () => {
|
||||||
|
rev.revealChild = true;
|
||||||
|
},
|
||||||
|
onHoverLost: () => {
|
||||||
|
rev.revealChild = false;
|
||||||
|
},
|
||||||
|
child: Box({
|
||||||
|
css: 'padding: 0 10px; margin-right: -10px;',
|
||||||
|
children: [
|
||||||
|
Icon({
|
||||||
|
icon: 'input-keyboard-symbolic',
|
||||||
|
size: 20,
|
||||||
|
}),
|
||||||
|
|
||||||
|
rev,
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
widget.rev = rev;
|
||||||
|
|
||||||
|
return widget;
|
||||||
|
};
|
||||||
|
|
|
@ -2,12 +2,22 @@ import App from 'resource:///com/github/Aylur/ags/app.js';
|
||||||
|
|
||||||
import { Box, Label } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { Box, Label } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
|
|
||||||
|
import Audio from './audio.js';
|
||||||
|
import Battery from './battery.js';
|
||||||
|
import KeyboardLayout from './keyboard-layout.js';
|
||||||
|
import Network from './network.js';
|
||||||
|
|
||||||
import EventBox from '../../misc/cursorbox.js';
|
import EventBox from '../../misc/cursorbox.js';
|
||||||
|
import Separator from '../../misc/separator.js';
|
||||||
|
|
||||||
|
const SPACING = 4;
|
||||||
|
|
||||||
|
|
||||||
export default () => EventBox({
|
export default () => EventBox({
|
||||||
className: 'toggle-off',
|
className: 'toggle-off',
|
||||||
|
|
||||||
|
onHoverLost: () => { /**/ },
|
||||||
|
|
||||||
onPrimaryClickRelease: () => App.toggleWindow('quick-settings'),
|
onPrimaryClickRelease: () => App.toggleWindow('quick-settings'),
|
||||||
|
|
||||||
connections: [[App, (self, windowName, visible) => {
|
connections: [[App, (self, windowName, visible) => {
|
||||||
|
@ -19,6 +29,20 @@ export default () => EventBox({
|
||||||
child: Box({
|
child: Box({
|
||||||
className: 'quick-settings-toggle',
|
className: 'quick-settings-toggle',
|
||||||
vertical: false,
|
vertical: false,
|
||||||
child: Label(' '),
|
children: [
|
||||||
|
Separator(SPACING),
|
||||||
|
|
||||||
|
KeyboardLayout(),
|
||||||
|
|
||||||
|
Audio(),
|
||||||
|
|
||||||
|
Battery(),
|
||||||
|
|
||||||
|
Network(),
|
||||||
|
|
||||||
|
Label(' '),
|
||||||
|
|
||||||
|
Separator(SPACING),
|
||||||
|
],
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,12 +2,9 @@ import { Window, CenterBox, Box } from 'resource:///com/github/Aylur/ags/widget.
|
||||||
|
|
||||||
import Separator from '../misc/separator.js';
|
import Separator from '../misc/separator.js';
|
||||||
|
|
||||||
import Audio from './buttons/audio.js';
|
|
||||||
import Battery from './buttons/battery.js';
|
|
||||||
import Brightness from './buttons/brightness.js';
|
import Brightness from './buttons/brightness.js';
|
||||||
import Clock from './buttons/clock.js';
|
import Clock from './buttons/clock.js';
|
||||||
import CurrentWindow from './buttons/current-window.js';
|
import CurrentWindow from './buttons/current-window.js';
|
||||||
import KeyboardLayout from './buttons/keyboard-layout.js';
|
|
||||||
import NotifButton from './buttons/notif-button.js';
|
import NotifButton from './buttons/notif-button.js';
|
||||||
import OskToggle from './buttons/osk-toggle.js';
|
import OskToggle from './buttons/osk-toggle.js';
|
||||||
import QsToggle from './buttons/quick-settings.js';
|
import QsToggle from './buttons/quick-settings.js';
|
||||||
|
@ -44,10 +41,6 @@ export default () => Window({
|
||||||
|
|
||||||
SysTray(),
|
SysTray(),
|
||||||
|
|
||||||
Audio(),
|
|
||||||
|
|
||||||
Separator(SPACING),
|
|
||||||
|
|
||||||
Brightness(),
|
Brightness(),
|
||||||
|
|
||||||
Separator(SPACING),
|
Separator(SPACING),
|
||||||
|
@ -70,14 +63,6 @@ export default () => Window({
|
||||||
endWidget: Box({
|
endWidget: Box({
|
||||||
hpack: 'end',
|
hpack: 'end',
|
||||||
children: [
|
children: [
|
||||||
Battery(),
|
|
||||||
|
|
||||||
Separator(SPACING),
|
|
||||||
|
|
||||||
KeyboardLayout(),
|
|
||||||
|
|
||||||
Separator(SPACING),
|
|
||||||
|
|
||||||
Clock(),
|
Clock(),
|
||||||
|
|
||||||
Separator(SPACING),
|
Separator(SPACING),
|
||||||
|
|
|
@ -50,19 +50,29 @@
|
||||||
|
|
||||||
.clock {
|
.clock {
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
padding-left: 10px;
|
padding: 0 15px;
|
||||||
padding-right: 10px;
|
|
||||||
min-width: 230px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.audio {
|
.audio {
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
margin-right: -10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.network {
|
||||||
|
padding: 0 10px;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg-text {
|
||||||
|
color: $bg;
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
.battery {
|
.battery {
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
font-size: 20px;
|
font-size: 20px;
|
||||||
|
margin-right: -10px;
|
||||||
|
|
||||||
.battery-indicator {
|
.battery-indicator {
|
||||||
&.charging {
|
&.charging {
|
||||||
|
|
BIN
flake.lock
BIN
flake.lock
Binary file not shown.
Loading…
Reference in a new issue