ags: sync

This commit is contained in:
end-4
2024-01-25 22:25:27 +07:00
parent ed24fe4ae3
commit 7e73e24dd8
64 changed files with 2674 additions and 1723 deletions
-1
View File
@@ -6,7 +6,6 @@ function moveClientToWorkspace(address, workspace) {
}
export function dumpToWorkspace(from, to) {
console.log('dump', from, to);
if (from == to) return;
Hyprland.clients.forEach(client => {
if (client.workspace.id == from) {
@@ -66,9 +66,9 @@ export function execAndClose(command, terminal) {
execAsync(command).catch(print);
}
export function startsWithNumber(str) {
var pattern = /^\d/;
return pattern.test(str);
export function couldBeMath(str) {
const regex = /^[0-9.+*/-]/;
return regex.test(str);
}
export function expandTilde(path) {
@@ -1,6 +1,7 @@
const { Gdk, Gtk } = imports.gi;
import { SCREEN_HEIGHT, SCREEN_WIDTH } from '../../imports.js';
import App from 'resource:///com/github/Aylur/ags/app.js';
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
@@ -14,6 +15,8 @@ const OVERVIEW_WS_NUM_SCALE = 0.09;
const OVERVIEW_WS_NUM_MARGIN_SCALE = 0.07;
const TARGET = [Gtk.TargetEntry.new('text/plain', Gtk.TargetFlags.SAME_APP, 0)];
const overviewTick = Variable(false);
function truncateTitle(str) {
let lastDash = -1;
let found = -1; // 0: em dash, 1: en dash, 2: minus, 3: vertical bar, 4: middle dot
@@ -213,6 +216,7 @@ const workspace = index => {
eventbox.drag_dest_set(Gtk.DestDefaults.ALL, TARGET, Gdk.DragAction.COPY);
eventbox.connect('drag-data-received', (_w, _c, _x, _y, data) => {
Hyprland.sendMessage(`dispatch movetoworkspacesilent ${index},address:${data.get_text()}`)
overviewTick.setValue(!overviewTick.value);
});
},
child: fixed,
@@ -275,18 +279,19 @@ const OverviewRow = ({ startWorkspace, workspaces, windowName = 'overview' }) =>
}).catch(print);
}
},
setup: (box) => {
box
// .hook(Hyprland, (box, name, data) => { // idk, does this make it lag occasionally?
// if (["changefloatingmode", "movewindow"].includes(name))
// box.attribute.update(box);
// }, 'event')
.hook(Hyprland, (box) => box.attribute.update(box), 'client-added')
.hook(Hyprland, (box) => box.attribute.update(box), 'client-removed')
.hook(App, (box, name, visible) => { // Update on open
if (name == 'overview' && visible) box.attribute.update(box);
})
},
setup: (box) => box
.hook(overviewTick, (box) => box.attribute.update(box))
// .hook(Hyprland, (box, name, data) => { // idk, does this make it lag occasionally?
// console.log(name)
// if (["changefloatingmode", "movewindow"].includes(name))
// box.attribute.update(box);
// }, 'event')
.hook(Hyprland, (box) => box.attribute.update(box), 'client-added')
.hook(Hyprland, (box) => box.attribute.update(box), 'client-removed')
.hook(App, (box, name, visible) => { // Update on open
if (name == 'overview' && visible) box.attribute.update(box);
})
,
});
@@ -4,7 +4,7 @@ import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
const { execAsync, exec } = Utils;
import { searchItem } from './searchitem.js';
import { execAndClose, startsWithNumber, launchCustomCommand } from './miscfunctions.js';
import { execAndClose, couldBeMath, launchCustomCommand } from './miscfunctions.js';
export const DirectoryButton = ({ parentPath, name, type, icon }) => {
const actionText = Widget.Revealer({
@@ -5,7 +5,7 @@ import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
import Applications from 'resource:///com/github/Aylur/ags/service/applications.js';
const { execAsync, exec } = Utils;
import { execAndClose, expandTilde, hasUnterminatedBackslash, startsWithNumber, launchCustomCommand, ls } from './miscfunctions.js';
import { execAndClose, expandTilde, hasUnterminatedBackslash, couldBeMath, launchCustomCommand, ls } from './miscfunctions.js';
import {
CalculationResultButton, CustomCommandButton, DirectoryButton,
DesktopEntryButton, ExecuteCommandButton, SearchButton
@@ -39,7 +39,7 @@ const OptionalOverview = async () => {
try {
return (await import('./overview_hyprland.js')).default();
} catch {
return null;
return Widget.Box({});
// return (await import('./overview_hyprland.js')).default();
}
};
@@ -104,7 +104,7 @@ export const SearchAndWindows = () => {
const isAction = text.startsWith('>');
const isDir = (['/', '~'].includes(entry.text[0]));
if (startsWithNumber(text)) { // Eval on typing is dangerous, this is a workaround
if (couldBeMath(text)) { // Eval on typing is dangerous, this is a workaround
try {
const fullResult = eval(text);
// copy
@@ -166,7 +166,7 @@ export const SearchAndWindows = () => {
_appSearchResults = Applications.query(text);
// Calculate
if (startsWithNumber(text)) { // Eval on typing is dangerous, this is a small workaround.
if (couldBeMath(text)) { // Eval on typing is dangerous; this is a small workaround.
try {
const fullResult = eval(text);
resultsBox.add(CalculationResultButton({ result: fullResult, text: text }));