feat(ags): add brightness slider
All checks were successful
Discord / discord commits (push) Has been skipped
All checks were successful
Discord / discord commits (push) Has been skipped
This commit is contained in:
parent
eaecd0eec5
commit
7acb86fd98
3 changed files with 58 additions and 3 deletions
|
@ -8,6 +8,7 @@ import AudioWindow from '../widgets/audio/wim';
|
|||
import Bar from '../widgets/bar/wim';
|
||||
import BgLayer from '../widgets/bg-layer';
|
||||
import BluetoothWindow from '../widgets/bluetooth/wim';
|
||||
import BrightnessSlider from '../widgets/brightness-slider/main';
|
||||
import Calendar from '../widgets/date/wim';
|
||||
import Clipboard from '../widgets/clipboard';
|
||||
import Corners from '../widgets/corners';
|
||||
|
@ -97,6 +98,7 @@ export default () => {
|
|||
AudioWindow();
|
||||
Bar();
|
||||
BluetoothWindow();
|
||||
BrightnessSlider();
|
||||
Calendar();
|
||||
Clipboard();
|
||||
Corners();
|
||||
|
|
|
@ -1,13 +1,31 @@
|
|||
import { bind } from 'astal';
|
||||
import { App } from 'astal/gtk3';
|
||||
|
||||
import Brightness from '../../../services/brightness';
|
||||
|
||||
import PopupWindow from '../../misc/popup-window';
|
||||
|
||||
|
||||
export default () => {
|
||||
const brightness = Brightness.get_default();
|
||||
|
||||
return (
|
||||
<box className="bar-item brightness">
|
||||
<overlay>
|
||||
<button
|
||||
cursor="pointer"
|
||||
className="bar-item brightness"
|
||||
|
||||
onButtonReleaseEvent={(self) => {
|
||||
const win = App.get_window('win-brightness-slider') as PopupWindow;
|
||||
|
||||
win.set_x_pos(
|
||||
self.get_allocation(),
|
||||
'right',
|
||||
);
|
||||
|
||||
win.set_visible(!win.get_visible());
|
||||
}}
|
||||
>
|
||||
<overlay passThrough>
|
||||
<circularprogress
|
||||
startAt={0.75}
|
||||
endAt={0.75}
|
||||
|
@ -17,6 +35,6 @@ export default () => {
|
|||
|
||||
<icon icon={bind(brightness, 'screenIcon')} />
|
||||
</overlay>
|
||||
</box>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
|
35
modules/ags/config/widgets/brightness-slider/main.tsx
Normal file
35
modules/ags/config/widgets/brightness-slider/main.tsx
Normal file
|
@ -0,0 +1,35 @@
|
|||
import { bind } from 'astal';
|
||||
import { Astal, Gtk } from 'astal/gtk3';
|
||||
|
||||
import Brightness from '../../services/brightness';
|
||||
|
||||
import PopupWindow from '../misc/popup-window';
|
||||
|
||||
|
||||
export default () => {
|
||||
const brightness = Brightness.get_default();
|
||||
|
||||
return (
|
||||
<PopupWindow
|
||||
name="brightness-slider"
|
||||
anchor={Astal.WindowAnchor.RIGHT | Astal.WindowAnchor.TOP}
|
||||
>
|
||||
<box className="widget" widthRequest={500}>
|
||||
<slider
|
||||
hexpand
|
||||
halign={Gtk.Align.FILL}
|
||||
drawValue
|
||||
cursor="pointer"
|
||||
|
||||
min={0}
|
||||
max={100}
|
||||
|
||||
value={bind(brightness, 'screen').as((v) => v * 100)}
|
||||
onDragged={(self) => {
|
||||
brightness.screen = Number((self.value / 100).toFixed(2));
|
||||
}}
|
||||
/>
|
||||
</box>
|
||||
</PopupWindow>
|
||||
);
|
||||
};
|
Loading…
Reference in a new issue