feat(ags): use Hyprland.sendMessage instead of hyprctl
This commit is contained in:
parent
1e4fe115ad
commit
c0a97e044c
13 changed files with 79 additions and 71 deletions
|
@ -1,15 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
APP="$1"
|
|
||||||
EXEC="$2"
|
|
||||||
|
|
||||||
if [[ "$APP" == "thunderbird" ]]; then
|
|
||||||
hyprctl dispatch togglespecialworkspace thunder
|
|
||||||
elif [[ "$APP" == "Spotify" ]]; then
|
|
||||||
hyprctl dispatch togglespecialworkspace spot
|
|
||||||
elif [[ $(hyprctl clients | grep "$APP") != "" ]]; then
|
|
||||||
hyprctl dispatch focuswindow "^($APP)$"
|
|
||||||
else
|
|
||||||
hyprctl dispatch workspace empty
|
|
||||||
hyprctl dispatch exec "$EXEC"
|
|
||||||
fi
|
|
|
@ -1,8 +1,8 @@
|
||||||
import App from 'resource:///com/github/Aylur/ags/app.js';
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
||||||
import Applications from 'resource:///com/github/Aylur/ags/service/applications.js';
|
import Applications from 'resource:///com/github/Aylur/ags/service/applications.js';
|
||||||
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
|
|
||||||
import { Label, Box, Icon, Button, Scrollable, Entry } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { Label, Box, Icon, Button, Scrollable, Entry } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
|
|
||||||
|
|
||||||
import Separator from '../misc/separator.js';
|
import Separator from '../misc/separator.js';
|
||||||
import PopupWindow from '../misc/popup.js';
|
import PopupWindow from '../misc/popup.js';
|
||||||
|
@ -23,7 +23,7 @@ const AppItem = (app, window) => {
|
||||||
className: 'app',
|
className: 'app',
|
||||||
connections: [['clicked', () => {
|
connections: [['clicked', () => {
|
||||||
App.closeWindow(window);
|
App.closeWindow(window);
|
||||||
execAsync(['hyprctl', 'dispatch', 'exec', `sh -c ${app.executable}`]);
|
Hyprland.sendMessage(`dispatch exec sh -c ${app.executable}`);
|
||||||
// TODO: focus on new client. Is this only needed after launch?
|
// TODO: focus on new client. Is this only needed after launch?
|
||||||
++app.frequency;
|
++app.frequency;
|
||||||
}]],
|
}]],
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
import { exec } from 'resource:///com/github/Aylur/ags/utils.js';
|
|
||||||
import { Box, Icon, Label } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { Box, Icon, Label } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
|
|
||||||
const DEFAULT_KB = 'at-translated-set-2-keyboard';
|
const DEFAULT_KB = 'at-translated-set-2-keyboard';
|
||||||
|
|
||||||
export default () => Box({
|
export default () => Box({
|
||||||
className: 'toggle-off',
|
className: 'toggle-off',
|
||||||
|
css: 'padding: 0 10px;',
|
||||||
children: [
|
children: [
|
||||||
Icon({
|
Icon({
|
||||||
icon: 'input-keyboard-symbolic',
|
icon: 'input-keyboard-symbolic',
|
||||||
|
@ -14,16 +14,24 @@ export default () => Box({
|
||||||
Label({
|
Label({
|
||||||
connections: [[Hyprland, (self, _n, layout) => {
|
connections: [[Hyprland, (self, _n, layout) => {
|
||||||
if (!layout) {
|
if (!layout) {
|
||||||
const obj = exec('hyprctl devices -j');
|
Hyprland.sendMessage('j/devices').then(obj => {
|
||||||
const keyboards = JSON.parse(obj)['keyboards'];
|
const kb = JSON.parse(obj)['keyboards']
|
||||||
const kb = keyboards.find(val => val.name === DEFAULT_KB);
|
.find(val => val.name === DEFAULT_KB);
|
||||||
|
|
||||||
layout = kb['active_keymap'];
|
layout = kb['active_keymap'];
|
||||||
|
|
||||||
self.label = layout;
|
const shortName = layout.match(/\(([A-Za-z]+)\)/);
|
||||||
|
|
||||||
|
self.label = shortName ? shortName[1] : layout;
|
||||||
|
}).catch(print);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
self.label = layout;
|
if (layout === 'error')
|
||||||
|
return;
|
||||||
|
|
||||||
|
const shortName = layout.match(/\(([A-Za-z]+)\)/);
|
||||||
|
|
||||||
|
self.label = shortName ? shortName[1] : layout;
|
||||||
}
|
}
|
||||||
}, 'keyboard-layout']],
|
}, 'keyboard-layout']],
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -13,7 +13,7 @@ import Battery from './battery.js';
|
||||||
import Brightness from './brightness.js';
|
import Brightness from './brightness.js';
|
||||||
import Audio from './audio.js';
|
import Audio from './audio.js';
|
||||||
import Revealer from './fullscreen.js';
|
import Revealer from './fullscreen.js';
|
||||||
//import KeyboardLayout from './keyboard-layout.js';
|
import KeyboardLayout from './keyboard-layout.js';
|
||||||
|
|
||||||
|
|
||||||
export const BgGradient = () => Window({
|
export const BgGradient = () => Window({
|
||||||
|
@ -82,9 +82,9 @@ export const Bar = () => Window({
|
||||||
|
|
||||||
Separator(12),
|
Separator(12),
|
||||||
|
|
||||||
//KeyboardLayout(),
|
KeyboardLayout(),
|
||||||
|
|
||||||
//Separator(12),
|
Separator(12),
|
||||||
|
|
||||||
Clock(),
|
Clock(),
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
import { execAsync, timeout } from 'resource:///com/github/Aylur/ags/utils.js';
|
import { timeout } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
import { Box, Overlay, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { Box, Overlay, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
|
|
||||||
import EventBox from '../misc/cursorbox.js';
|
import EventBox from '../misc/cursorbox.js';
|
||||||
|
@ -12,10 +12,7 @@ const Workspace = ({ i } = {}) =>
|
||||||
|
|
||||||
child: EventBox({
|
child: EventBox({
|
||||||
tooltipText: `${i}`,
|
tooltipText: `${i}`,
|
||||||
onPrimaryClickRelease: () => {
|
onPrimaryClickRelease: () => Hyprland.sendMessage(`dispatch workspace ${i}`),
|
||||||
execAsync(`hyprctl dispatch workspace ${i}`)
|
|
||||||
.catch(print);
|
|
||||||
},
|
|
||||||
child: Box({
|
child: Box({
|
||||||
vpack: 'center',
|
vpack: 'center',
|
||||||
className: 'button',
|
className: 'button',
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
import Applications from 'resource:///com/github/Aylur/ags/service/applications.js';
|
import Applications from 'resource:///com/github/Aylur/ags/service/applications.js';
|
||||||
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
import Notifications from 'resource:///com/github/Aylur/ags/service/notifications.js';
|
import Notifications from 'resource:///com/github/Aylur/ags/service/notifications.js';
|
||||||
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
|
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
|
||||||
import { Box, Icon, Label, Button } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { Box, Icon, Label, Button } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
import { lookUpIcon, execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
|
import { lookUpIcon } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
|
|
||||||
import GLib from 'gi://GLib';
|
import GLib from 'gi://GLib';
|
||||||
|
|
||||||
|
@ -32,11 +33,32 @@ const NotificationIcon = notif => {
|
||||||
if (wmClass != null) {
|
if (wmClass != null) {
|
||||||
iconCmd = box => {
|
iconCmd = box => {
|
||||||
if (!getDragState(box)) {
|
if (!getDragState(box)) {
|
||||||
execAsync(['bash', '-c',
|
if (wmClass === 'thunderbird') {
|
||||||
`$AGS_PATH/launch-app.sh
|
Hyprland.sendMessage('dispatch togglespecialworkspace thunder');
|
||||||
${wmClass}
|
}
|
||||||
${app.app.get_string('Exec')}`,
|
else if (wmClass === 'Spotify') {
|
||||||
]).catch(print);
|
Hyprland.sendMessage('dispatch togglespecialworkspace spot');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Hyprland.sendMessage('j/clients').then(out => {
|
||||||
|
out = JSON.parse(out);
|
||||||
|
const classes = [];
|
||||||
|
for (const key of out) {
|
||||||
|
if (key.class)
|
||||||
|
classes.push(key.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (classes.includes(wmClass)) {
|
||||||
|
Hyprland.sendMessage(`dispatch focuswindow ^(${wmClass})`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Hyprland.sendMessage('[[BATCH]] ' +
|
||||||
|
'dispatch workspace empty; ' +
|
||||||
|
`dispatch exec sh -c ${app.executable}
|
||||||
|
`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
globalThis.closeAll();
|
globalThis.closeAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import App from 'resource:///com/github/Aylur/ags/app.js';
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
||||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
import { Icon, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { Icon, Revealer } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
import { execAsync, timeout } from 'resource:///com/github/Aylur/ags/utils.js';
|
import { timeout } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
|
|
||||||
import { WindowButton } from './dragndrop.js';
|
import { WindowButton } from './dragndrop.js';
|
||||||
import * as VARS from './variables.js';
|
import * as VARS from './variables.js';
|
||||||
|
@ -37,26 +37,21 @@ const Client = (client, active, clients, box) => {
|
||||||
child: WindowButton({
|
child: WindowButton({
|
||||||
mainBox: box,
|
mainBox: box,
|
||||||
address: client.address,
|
address: client.address,
|
||||||
onSecondaryClickRelease: () => {
|
onSecondaryClickRelease: () => Hyprland.sendMessage(`dispatch closewindow ${addr}`),
|
||||||
execAsync(`hyprctl dispatch closewindow ${addr}`)
|
|
||||||
.catch(print);
|
|
||||||
},
|
|
||||||
|
|
||||||
onPrimaryClickRelease: () => {
|
onPrimaryClickRelease: () => {
|
||||||
if (wsId < 0) {
|
if (wsId < 0) {
|
||||||
if (client.workspace.name === 'special') {
|
if (client.workspace.name === 'special') {
|
||||||
execAsync(`hyprctl dispatch
|
Hyprland.sendMessage(`dispatch movetoworkspacesilent special:${wsId},${addr}`)
|
||||||
movetoworkspacesilent special:${wsId},${addr}`)
|
.then(
|
||||||
|
Hyprland.sendMessage(`dispatch togglespecialworkspace ${wsId}`)
|
||||||
.then(
|
.then(
|
||||||
|
|
||||||
execAsync(`hyprctl dispatch togglespecialworkspace ${wsId}`).then(
|
|
||||||
() => App.closeWindow('overview'),
|
() => App.closeWindow('overview'),
|
||||||
).catch(print),
|
).catch(print),
|
||||||
|
|
||||||
).catch(print);
|
).catch(print);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
execAsync(`hyprctl dispatch togglespecialworkspace ${wsName}`).then(
|
Hyprland.sendMessage(`dispatch togglespecialworkspace ${wsName}`).then(
|
||||||
() => App.closeWindow('overview'),
|
() => App.closeWindow('overview'),
|
||||||
).catch(print);
|
).catch(print);
|
||||||
}
|
}
|
||||||
|
@ -68,10 +63,10 @@ const Client = (client, active, clients, box) => {
|
||||||
const currentSpecial = String(currentActive.workspace.name).replace('special:', '');
|
const currentSpecial = String(currentActive.workspace.name).replace('special:', '');
|
||||||
|
|
||||||
if (currentActive && currentActive.workspace.id < 0) {
|
if (currentActive && currentActive.workspace.id < 0) {
|
||||||
execAsync(`hyprctl dispatch togglespecialworkspace ${currentSpecial}`)
|
Hyprland.sendMessage(`dispatch togglespecialworkspace ${currentSpecial}`)
|
||||||
.catch(print);
|
.catch(print);
|
||||||
}
|
}
|
||||||
execAsync(`hyprctl dispatch focuswindow ${addr}`).then(
|
Hyprland.sendMessage(`dispatch focuswindow ${addr}`).then(
|
||||||
() => App.closeWindow('overview'),
|
() => App.closeWindow('overview'),
|
||||||
).catch(print);
|
).catch(print);
|
||||||
}
|
}
|
||||||
|
@ -87,7 +82,7 @@ const Client = (client, active, clients, box) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export function updateClients(box) {
|
export function updateClients(box) {
|
||||||
execAsync('hyprctl clients -j').then(out => {
|
Hyprland.sendMessage('j/clients').then(out => {
|
||||||
const clients = JSON.parse(out).filter(client => client.class);
|
const clients = JSON.parse(out).filter(client => client.class);
|
||||||
|
|
||||||
box._workspaces.forEach(workspace => {
|
box._workspaces.forEach(workspace => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
import { EventBox } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { EventBox } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
|
|
||||||
|
|
||||||
import Gtk from 'gi://Gtk';
|
import Gtk from 'gi://Gtk';
|
||||||
import Gdk from 'gi://Gdk';
|
import Gdk from 'gi://Gdk';
|
||||||
|
@ -42,7 +42,7 @@ export const WorkspaceDrop = props => EventBox({
|
||||||
else if (id === 1000)
|
else if (id === 1000)
|
||||||
id = 'empty';
|
id = 'empty';
|
||||||
|
|
||||||
execAsync(`hyprctl dispatch movetoworkspacesilent ${id},address:${data.get_text()}`)
|
Hyprland.sendMessage(`dispatch movetoworkspacesilent ${id},address:${data.get_text()}`)
|
||||||
.catch(print);
|
.catch(print);
|
||||||
}]],
|
}]],
|
||||||
setup: self => {
|
setup: self => {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
import { CenterBox, Label } from 'resource:///com/github/Aylur/ags/widget.js';
|
import { CenterBox, Label } from 'resource:///com/github/Aylur/ags/widget.js';
|
||||||
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
|
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
|
|
||||||
|
@ -32,7 +33,7 @@ const PowermenuWidget = () => CenterBox({
|
||||||
endWidget: Button({
|
endWidget: Button({
|
||||||
isButton: true,
|
isButton: true,
|
||||||
className: 'logout',
|
className: 'logout',
|
||||||
onPrimaryClickRelease: () => execAsync(['hyprctl', 'dispatch', 'exit']).catch(print),
|
onPrimaryClickRelease: () => Hyprland.sendMessage('dispatch exit').catch(print),
|
||||||
|
|
||||||
child: Label({
|
child: Label({
|
||||||
label: '',
|
label: '',
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import App from 'resource:///com/github/Aylur/ags/app.js';
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
||||||
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
|
import { execAsync } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
|
|
||||||
import Brightness from '../services/brightness.js';
|
import Brightness from '../services/brightness.js';
|
||||||
|
@ -41,13 +42,13 @@ export default () => {
|
||||||
name: 'swipeSpotify1',
|
name: 'swipeSpotify1',
|
||||||
gesture: 'LR',
|
gesture: 'LR',
|
||||||
edge: 'L',
|
edge: 'L',
|
||||||
command: 'hyprctl dispatch togglespecialworkspace spot',
|
command: () => Hyprland.sendMessage('dispatch togglespecialworkspace spot'),
|
||||||
});
|
});
|
||||||
|
|
||||||
TouchGestures.addGesture({
|
TouchGestures.addGesture({
|
||||||
name: 'swipeSpotify2',
|
name: 'swipeSpotify2',
|
||||||
gesture: 'RL',
|
gesture: 'RL',
|
||||||
edge: 'L',
|
edge: 'L',
|
||||||
command: 'hyprctl dispatch togglespecialworkspace spot',
|
command: () => Hyprland.sendMessage('dispatch togglespecialworkspace spot'),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -63,7 +63,7 @@ class Brightness extends Service {
|
||||||
|
|
||||||
monitorKbdState() {
|
monitorKbdState() {
|
||||||
Variable(0, {
|
Variable(0, {
|
||||||
poll: [1000, `brightnessctl -d ${KBD} g`, out => {
|
poll: [500, `brightnessctl -d ${KBD} g`, out => {
|
||||||
if (out !== this._kbd) {
|
if (out !== this._kbd) {
|
||||||
this._kbd = out;
|
this._kbd = out;
|
||||||
this.emit('kbd', this._kbd);
|
this.emit('kbd', this._kbd);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import App from 'resource:///com/github/Aylur/ags/app.js';
|
import App from 'resource:///com/github/Aylur/ags/app.js';
|
||||||
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
||||||
import { execAsync, subprocess } from 'resource:///com/github/Aylur/ags/utils.js';
|
import { subprocess } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
import GUdev from 'gi://GUdev';
|
import GUdev from 'gi://GUdev';
|
||||||
|
|
||||||
const UDEV_POINTERS = [
|
const UDEV_POINTERS = [
|
||||||
|
@ -148,10 +149,10 @@ class Pointers extends Service {
|
||||||
if (!toClose)
|
if (!toClose)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
execAsync('hyprctl layers -j').then(layers => {
|
Hyprland.sendMessage('j/layers').then(layers => {
|
||||||
layers = JSON.parse(layers);
|
layers = JSON.parse(layers);
|
||||||
|
|
||||||
execAsync('hyprctl cursorpos -j').then(pos => {
|
Hyprland.sendMessage('j/cursorpos').then(pos => {
|
||||||
pos = JSON.parse(pos);
|
pos = JSON.parse(pos);
|
||||||
|
|
||||||
Object.values(layers).forEach(key => {
|
Object.values(layers).forEach(key => {
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||||
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
||||||
import TouchGestures from './touch-gestures.js';
|
import TouchGestures from './touch-gestures.js';
|
||||||
import { execAsync, subprocess } from 'resource:///com/github/Aylur/ags/utils.js';
|
import { execAsync, subprocess } from 'resource:///com/github/Aylur/ags/utils.js';
|
||||||
|
@ -116,7 +117,7 @@ class Tablet extends Service {
|
||||||
|
|
||||||
getDevices() {
|
getDevices() {
|
||||||
this.devices = [];
|
this.devices = [];
|
||||||
execAsync(['hyprctl', 'devices', '-j']).then(out => {
|
Hyprland.sendMessage('j/devices').then(out => {
|
||||||
const devices = JSON.parse(out);
|
const devices = JSON.parse(out);
|
||||||
devices['touch'].forEach(dev => {
|
devices['touch'].forEach(dev => {
|
||||||
this.devices.push(dev.name);
|
this.devices.push(dev.name);
|
||||||
|
@ -139,15 +140,12 @@ class Tablet extends Service {
|
||||||
if (output.includes('orientation changed')) {
|
if (output.includes('orientation changed')) {
|
||||||
const orientation = ROTATION_MAPPING[output.split(' ').at(-1)];
|
const orientation = ROTATION_MAPPING[output.split(' ').at(-1)];
|
||||||
|
|
||||||
execAsync(['hyprctl', 'keyword', 'monitor',
|
Hyprland.sendMessage(`keyword monitor ${SCREEN},transform,${orientation}`)
|
||||||
`${SCREEN},transform,${orientation}`])
|
|
||||||
.catch(print);
|
.catch(print);
|
||||||
|
|
||||||
this.devices.forEach(dev => {
|
const batchRotate = this.devices.map(dev =>
|
||||||
execAsync(['hyprctl', 'keyword',
|
`keyword device:${dev}:transform ${orientation}; `);
|
||||||
`device:${dev}:transform`, String(orientation)])
|
Hyprland.sendMessage(`[[BATCH]] ${batchRotate.flat()}`);
|
||||||
.catch(print);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (TouchGestures.gestureDaemon) {
|
if (TouchGestures.gestureDaemon) {
|
||||||
TouchGestures.killDaemon();
|
TouchGestures.killDaemon();
|
||||||
|
|
Loading…
Reference in a new issue