feat(ags): add autorotate toggle button
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-06-17 21:30:02 -04:00
parent b37246474c
commit 09fa6eba73
4 changed files with 38 additions and 22 deletions

View file

@ -17,7 +17,6 @@
margin-left: 15px; margin-left: 15px;
margin-right: 10px; margin-right: 10px;
min-width: 50px; min-width: 50px;
transition: color 0.3s ease-in-out;
} }
.scrolled-indicator { .scrolled-indicator {
@ -147,6 +146,7 @@
.slider { .slider {
min-height: 55px; min-height: 55px;
margin-right: -15px;
scale { scale {
min-width: 400px; min-width: 400px;

View file

@ -25,6 +25,7 @@ class Tablet extends Service {
'device-fetched': ['boolean'], 'device-fetched': ['boolean'],
'autorotate-started': ['boolean'], 'autorotate-started': ['boolean'],
'autorotate-destroyed': ['boolean'], 'autorotate-destroyed': ['boolean'],
'autorotate-toggled': ['boolean'],
'inputs-blocked': ['boolean'], 'inputs-blocked': ['boolean'],
'inputs-unblocked': ['boolean'], 'inputs-unblocked': ['boolean'],
'laptop-mode': ['boolean'], 'laptop-mode': ['boolean'],
@ -43,6 +44,10 @@ class Tablet extends Service {
return this.#tabletMode; return this.#tabletMode;
} }
get autorotateState() {
return this.#autorotate !== null;
}
get oskState() { get oskState() {
return this.#oskState; return this.#oskState;
} }
@ -144,6 +149,7 @@ class Tablet extends Service {
}, },
); );
this.emit('autorotate-started', true); this.emit('autorotate-started', true);
this.emit('autorotate-toggled', true);
} }
killAutorotate() { killAutorotate() {
@ -151,6 +157,7 @@ class Tablet extends Service {
this.#autorotate.force_exit(); this.#autorotate.force_exit();
this.#autorotate = null; this.#autorotate = null;
this.emit('autorotate-destroyed', true); this.emit('autorotate-destroyed', true);
this.emit('autorotate-toggled', false);
} }
} }

View file

@ -1,6 +1,8 @@
const Bluetooth = await Service.import('bluetooth'); const Bluetooth = await Service.import('bluetooth');
const Network = await Service.import('network'); const Network = await Service.import('network');
import Tablet from '../../services/tablet.ts';
const { Box, Icon, Label, Revealer } = Widget; const { Box, Icon, Label, Revealer } = Widget;
const { execAsync } = Utils; const { execAsync } = Utils;
@ -11,25 +13,29 @@ import Separator from '../misc/separator.ts';
import { NetworkMenu } from './network.ts'; import { NetworkMenu } from './network.ts';
import { BluetoothMenu } from './bluetooth.ts'; import { BluetoothMenu } from './bluetooth.ts';
// Types /* Types */
import GObject from 'types/@girs/gobject-2.0/gobject-2.0'; import GObject from 'types/@girs/gobject-2.0/gobject-2.0';
import { Variable as Var } from 'types/variable.ts'; import { Variable as Var } from 'types/variable.ts';
import { import {
BoxGeneric, BoxGeneric,
IconGeneric, IconGeneric,
LabelGeneric, LabelGeneric,
RevealerGeneric, RevealerGeneric,
} from 'global-types'; } from 'global-types';
type IconTuple = [ type IconTuple = [
GObject.Object, GObject.Object,
(self: IconGeneric) => void, (self: IconGeneric, state?: boolean) => void,
signal?: string, signal?: string,
]; ];
type IndicatorTuple = [ type IndicatorTuple = [
GObject.Object, GObject.Object,
(self: LabelGeneric) => void, (self: LabelGeneric) => void,
signal?: string, signal?: string,
]; ];
type GridButtonType = { type GridButtonType = {
command?(): void command?(): void
secondary_command?(): void secondary_command?(): void
@ -40,10 +46,11 @@ type GridButtonType = {
menu?: Widget menu?: Widget
}; };
// TODO: do vpn button
const SPACING = 28; const SPACING = 28;
const ButtonStates = [] as Array<Var<boolean>>; const ButtonStates = [] as Array<Var<boolean>>;
const GridButton = ({ const GridButton = ({
command = () => {/**/}, command = () => {/**/},
secondary_command = () => {/**/}, secondary_command = () => {/**/},
@ -240,19 +247,6 @@ const FirstRow = () => Row({
on_open: () => Network.wifi.scan(), on_open: () => Network.wifi.scan(),
}), }),
// TODO: do vpn
GridButton({
command: () => {
//
},
secondary_command: () => {
//
},
icon: 'airplane-mode-disabled-symbolic',
}),
GridButton({ GridButton({
command: () => Bluetooth.toggle(), command: () => Bluetooth.toggle(),
@ -285,6 +279,13 @@ const FirstRow = () => Row({
}, },
}), }),
GridButton({
command: () => {
execAsync(['lock']).catch(print);
},
secondary_command: () => App.openWindow('win-powermenu'),
icon: 'system-lock-screen-symbolic',
}),
], ],
}); });
@ -322,13 +323,21 @@ const SecondRow = () => Row({
}], }],
}), }),
// TODO: replace this with Rotation Toggle and move lock to a separate section
GridButton({ GridButton({
command: () => { command: () => {
execAsync(['lock']).catch(print); if (Tablet.autorotateState) {
Tablet.killAutorotate();
}
else {
Tablet.startAutorotate();
}
}, },
secondary_command: () => App.openWindow('win-powermenu'),
icon: 'system-lock-screen-symbolic', icon: [Tablet, (self, state) => {
self.icon = state ?
'screen-rotate-auto-on-symbolic' :
'screen-rotate-auto-off-symbolic';
}, 'autorotate-toggled'],
}), }),
], ],
}); });

View file

@ -49,7 +49,7 @@ export default () => {
TouchGestures.addGesture({ TouchGestures.addGesture({
name: 'openOverview', name: 'openOverview',
nFingers: '4', nFingers: '3',
gesture: 'UD', gesture: 'UD',
command: 'hyprctl dispatch hyprexpo:expo on', command: 'hyprctl dispatch hyprexpo:expo on',
}); });