update ags

This commit is contained in:
sankalp committed 2024-06-26 00:10:21 +05:45
1 parent 88822cb8e8
commit a9c19bd2e1
134 files changed
+4732 -5813

No files matched your search

+114
View File
@@ -0,0 +1,114 @@
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
const prefix = "100" // Identifier for minimized workspace
function getMinimizedWS(maximizedWS){
return parseInt(prefix + maximizedWS)
}
function getMaximizedWS(minimizedWS){
return parseInt(minimizedWS.toString().substring(prefix.length))
}
function isMinimized(ws){
ws = ws.toString()
if (ws.length > 3 || ws.slice(0, prefix.length) == prefix){
return true
}
else{
return false
}
}
const focusClient = (client) => {
// If minimized
if (isMinimized(client.workspace.id)){
var maximizedWS = getMaximizedWS(client.workspace.id)
Hyprland.messageAsync(`dispatch movetoworkspacesilent ${maximizedWS},address:${client.address}`)
// Focus window
//Hyprland.messageAsync(`dispatch focuswindow address:${client.address}`)
Hyprland.messageAsync(`dispatch alterzorder top,address:${client.address}`)
}
// If maximized
else{
var minimizedWS = getMinimizedWS(client.workspace.id)
Hyprland.messageAsync(`dispatch movetoworkspacesilent ${minimizedWS},address:${client.address}`)
}
}
const Client = (client = null) => Widget.Box({
// Attributes
attribute: {
returnWS: client.workspace,
},
})
const appButton = (client = null) => Widget.Button({
class_name: "dock-button",
tooltip_text: client.title,
on_primary_click: () => focusClient(client),
child: Widget.Box({
vertical: true,
children: [
Widget.Box({
children: [
Widget.Box({
class_name: "dock-app-indicator",
vpack: "center",
setup: (self) => {
self.hook(Hyprland, () => {
//self.toggleClassName("dock-button-current", Hyprland.active.client.address === client.address)
self.toggleClassName("dock-app-indicator-active", Hyprland.active.client.address === client.address)
}, 'event')
}
}),
/*
Widget.Icon({
class_name: 'client-icon',
css: 'font-size: 3rem;',
icon: client.class,
}),
*/
],
}),
Widget.Label({
label: client.class,
truncate: 'end',
maxWidthChars: 8,
})
],
}),
});
const clientList = Widget.Scrollable({
hscroll: "never",
child: Widget.Box({
class_name: "dock-container",
css: "min-height: 6rem;",
css: "min-width: 6rem;",
vertical: true,
}).hook(Hyprland, self => {
//check if ws is empty
self.children = Hyprland.clients.filter(client => client.class != "" && (client.workspace.id === Hyprland.active.workspace.id || client.workspace.id === getMinimizedWS(Hyprland.active.workspace.id))).map(client => {
return appButton(client)
})
})
})
export const Dock = (monitor = 0) => Widget.Window({
name: `Dock`, // name has to be unique
monitor,
visible: false,
//margins: [4,64,4,64],
//margins: [8,8,8,8],
anchor: ['bottom', 'left', 'top'],
exclusivity: 'exclusive',
child: clientList,
});
@@ -0,0 +1,51 @@
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
const { Gtk } = imports.gi;
const Lang = imports.lang;
export const RoundedCorner = (place, props) => Widget.DrawingArea({
...props,
hpack: place.includes('left') ? 'start' : 'end',
vpack: place.includes('top') ? 'start' : 'end',
setup: (widget) => Utils.timeout(1, () => {
const c = widget.get_style_context().get_property('background-color', Gtk.StateFlags.NORMAL);
const r = widget.get_style_context().get_property('border-radius', Gtk.StateFlags.NORMAL);
widget.set_size_request(r, r);
// @ts-ignore
widget.connect('draw', Lang.bind(widget, (widget, cr) => {
const c = widget.get_style_context().get_property('background-color', Gtk.StateFlags.NORMAL);
const r = widget.get_style_context().get_property('border-radius', Gtk.StateFlags.NORMAL);
// const borderColor = widget.get_style_context().get_property('color', Gtk.StateFlags.NORMAL);
// const borderWidth = widget.get_style_context().get_border(Gtk.StateFlags.NORMAL).left; // ur going to write border-width: something anyway
widget.set_size_request(r, r);
switch (place) {
case 'top_left':
cr.arc(r, r, r, Math.PI, 3 * Math.PI / 2);
cr.lineTo(0, 0);
break;
case 'top_right':
cr.arc(0, r, r, 3 * Math.PI / 2, 2 * Math.PI);
cr.lineTo(r, 0);
break;
case 'bottom_left':
cr.arc(r, 0, r, Math.PI / 2, Math.PI);
cr.lineTo(0, r);
break;
case 'bottom_right':
cr.arc(0, 0, r, 0, Math.PI / 2);
cr.lineTo(r, r);
break;
}
cr.closePath();
cr.setSourceRGBA(c.red, c.green, c.blue, c.alpha);
cr.fill();
// cr.setLineWidth(borderWidth);
// cr.setSourceRGBA(borderColor.red, borderColor.green, borderColor.blue, borderColor.alpha);
// cr.stroke();
}));
}),
});
+4
View File
@@ -0,0 +1,4 @@
import Cairo from 'gi://cairo?version=1.0';
export const dummyRegion = new Cairo.Region();
export const enableClickThrough = (self) => self.input_shape_combine_region(dummyRegion);
+44
View File
@@ -0,0 +1,44 @@
import App from 'resource:///com/github/Aylur/ags/app.js';
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
import { WindowProps, Window } from 'types/widgets/window';
const { Gtk, GLib } = imports.gi;
type _WindowProps = WindowProps<any, unknown, Window<any, unknown>> | undefined[];
type Type = {
name: string,
child: any,
showClassName?: string,
hideClassName?: string,
}
export default <T extends Type>({
name,
child,
showClassName = "",
hideClassName = "",
...props
}: T & Omit<_WindowProps, keyof Type>) => {
return Widget.Window({
name,
visible: false,
type: Gtk.WindowType.POPUP,
layer: 'overlay',
resizable: true,
...props,
setup: (self) => {
self.keybind("Escape", () => App.closeWindow(name));
if (showClassName != "" && hideClassName !== "") {
self.hook(App, (self, currentName, visible) => {
if (currentName === name) {
self.toggleClassName(hideClassName, !visible);
}
});
if (showClassName !== "" && hideClassName !== "")
self.class_name = `${showClassName} ${hideClassName}`;
}
},
child: child,
});
}