feat(ags): add autorotate toggle button
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
b37246474c
commit
09fa6eba73
4 changed files with 38 additions and 22 deletions
|
@ -17,7 +17,6 @@
|
|||
margin-left: 15px;
|
||||
margin-right: 10px;
|
||||
min-width: 50px;
|
||||
transition: color 0.3s ease-in-out;
|
||||
}
|
||||
|
||||
.scrolled-indicator {
|
||||
|
@ -147,6 +146,7 @@
|
|||
|
||||
.slider {
|
||||
min-height: 55px;
|
||||
margin-right: -15px;
|
||||
|
||||
scale {
|
||||
min-width: 400px;
|
||||
|
|
|
@ -25,6 +25,7 @@ class Tablet extends Service {
|
|||
'device-fetched': ['boolean'],
|
||||
'autorotate-started': ['boolean'],
|
||||
'autorotate-destroyed': ['boolean'],
|
||||
'autorotate-toggled': ['boolean'],
|
||||
'inputs-blocked': ['boolean'],
|
||||
'inputs-unblocked': ['boolean'],
|
||||
'laptop-mode': ['boolean'],
|
||||
|
@ -43,6 +44,10 @@ class Tablet extends Service {
|
|||
return this.#tabletMode;
|
||||
}
|
||||
|
||||
get autorotateState() {
|
||||
return this.#autorotate !== null;
|
||||
}
|
||||
|
||||
get oskState() {
|
||||
return this.#oskState;
|
||||
}
|
||||
|
@ -144,6 +149,7 @@ class Tablet extends Service {
|
|||
},
|
||||
);
|
||||
this.emit('autorotate-started', true);
|
||||
this.emit('autorotate-toggled', true);
|
||||
}
|
||||
|
||||
killAutorotate() {
|
||||
|
@ -151,6 +157,7 @@ class Tablet extends Service {
|
|||
this.#autorotate.force_exit();
|
||||
this.#autorotate = null;
|
||||
this.emit('autorotate-destroyed', true);
|
||||
this.emit('autorotate-toggled', false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
const Bluetooth = await Service.import('bluetooth');
|
||||
const Network = await Service.import('network');
|
||||
|
||||
import Tablet from '../../services/tablet.ts';
|
||||
|
||||
const { Box, Icon, Label, Revealer } = Widget;
|
||||
const { execAsync } = Utils;
|
||||
|
||||
|
@ -11,25 +13,29 @@ import Separator from '../misc/separator.ts';
|
|||
import { NetworkMenu } from './network.ts';
|
||||
import { BluetoothMenu } from './bluetooth.ts';
|
||||
|
||||
// Types
|
||||
/* Types */
|
||||
import GObject from 'types/@girs/gobject-2.0/gobject-2.0';
|
||||
import { Variable as Var } from 'types/variable.ts';
|
||||
|
||||
import {
|
||||
BoxGeneric,
|
||||
IconGeneric,
|
||||
LabelGeneric,
|
||||
RevealerGeneric,
|
||||
} from 'global-types';
|
||||
|
||||
type IconTuple = [
|
||||
GObject.Object,
|
||||
(self: IconGeneric) => void,
|
||||
(self: IconGeneric, state?: boolean) => void,
|
||||
signal?: string,
|
||||
];
|
||||
|
||||
type IndicatorTuple = [
|
||||
GObject.Object,
|
||||
(self: LabelGeneric) => void,
|
||||
signal?: string,
|
||||
];
|
||||
|
||||
type GridButtonType = {
|
||||
command?(): void
|
||||
secondary_command?(): void
|
||||
|
@ -40,10 +46,11 @@ type GridButtonType = {
|
|||
menu?: Widget
|
||||
};
|
||||
|
||||
|
||||
// TODO: do vpn button
|
||||
const SPACING = 28;
|
||||
const ButtonStates = [] as Array<Var<boolean>>;
|
||||
|
||||
|
||||
const GridButton = ({
|
||||
command = () => {/**/},
|
||||
secondary_command = () => {/**/},
|
||||
|
@ -240,19 +247,6 @@ const FirstRow = () => Row({
|
|||
on_open: () => Network.wifi.scan(),
|
||||
}),
|
||||
|
||||
// TODO: do vpn
|
||||
GridButton({
|
||||
command: () => {
|
||||
//
|
||||
},
|
||||
|
||||
secondary_command: () => {
|
||||
//
|
||||
},
|
||||
|
||||
icon: 'airplane-mode-disabled-symbolic',
|
||||
}),
|
||||
|
||||
GridButton({
|
||||
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({
|
||||
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'],
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
|
|
@ -49,7 +49,7 @@ export default () => {
|
|||
|
||||
TouchGestures.addGesture({
|
||||
name: 'openOverview',
|
||||
nFingers: '4',
|
||||
nFingers: '3',
|
||||
gesture: 'UD',
|
||||
command: 'hyprctl dispatch hyprexpo:expo on',
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue