mirror of
https://github.com/xsghetti/HyprCrux.git
synced 2025-07-03 13:50:38 -04:00
updates
This commit is contained in:
parent
1f8cb3c145
commit
610604e80f
253 changed files with 27055 additions and 44 deletions
14
.config/ags/modules/desktopbackground/data_quicklaunches.js
Normal file
14
.config/ags/modules/desktopbackground/data_quicklaunches.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
export const quickLaunchItems = [
|
||||
{
|
||||
"name": "GitHub + Files×2",
|
||||
"command": "github-desktop & nautilus --new-window & nautilus --new-window &"
|
||||
},
|
||||
{
|
||||
"name": "Terminal×2",
|
||||
"command": "foot & foot &"
|
||||
},
|
||||
{
|
||||
"name": "Discord + Youtube + Github",
|
||||
"command": "xdg-open 'https://discord.com/app' && xdg-open 'https://youtube.com/' && xdg-open 'https://github.com/' &"
|
||||
},
|
||||
]
|
24
.config/ags/modules/desktopbackground/main.js
Normal file
24
.config/ags/modules/desktopbackground/main.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
|
||||
import WallpaperImage from './wallpaper.js';
|
||||
import TimeAndLaunchesWidget from './timeandlaunches.js'
|
||||
import SystemWidget from './system.js'
|
||||
|
||||
export default (monitor) => Widget.Window({
|
||||
name: `desktopbackground${monitor}`,
|
||||
// anchor: ['top', 'bottom', 'left', 'right'],
|
||||
layer: 'background',
|
||||
exclusivity: 'ignore',
|
||||
visible: true,
|
||||
child: Widget.Overlay({
|
||||
child: WallpaperImage(monitor),
|
||||
// child: Widget.Box({}),
|
||||
overlays: [
|
||||
TimeAndLaunchesWidget(),
|
||||
SystemWidget(),
|
||||
],
|
||||
setup: (self) => {
|
||||
self.set_overlay_pass_through(self.get_children()[1], true);
|
||||
},
|
||||
}),
|
||||
});
|
161
.config/ags/modules/desktopbackground/system.js
Normal file
161
.config/ags/modules/desktopbackground/system.js
Normal file
|
@ -0,0 +1,161 @@
|
|||
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;
|
||||
const { Box, EventBox, Label, Revealer, Overlay } = Widget;
|
||||
import { AnimatedCircProg } from "../.commonwidgets/cairo_circularprogress.js";
|
||||
import { MaterialIcon } from '../.commonwidgets/materialicon.js';
|
||||
|
||||
const ResourceValue = (name, icon, interval, valueUpdateCmd, displayFunc, props = {}) => Box({
|
||||
...props,
|
||||
className: 'bg-system-bg txt',
|
||||
children: [
|
||||
Revealer({
|
||||
transition: 'slide_left',
|
||||
transitionDuration: userOptions.animations.durationLarge,
|
||||
child: Box({
|
||||
vpack: 'center',
|
||||
vertical: true,
|
||||
className: 'margin-right-15',
|
||||
children: [
|
||||
Label({
|
||||
xalign: 1,
|
||||
className: 'txt-small txt',
|
||||
label: `${name}`,
|
||||
}),
|
||||
Label({
|
||||
xalign: 1,
|
||||
className: 'titlefont txt-norm txt-onSecondaryContainer',
|
||||
setup: (self) => self
|
||||
.poll(interval, (label) => displayFunc(label))
|
||||
,
|
||||
})
|
||||
]
|
||||
})
|
||||
}),
|
||||
Overlay({
|
||||
child: AnimatedCircProg({
|
||||
className: 'bg-system-circprog',
|
||||
extraSetup: (self) => self
|
||||
.poll(interval, (self) => {
|
||||
execAsync(['bash', '-c', `${valueUpdateCmd}`]).then((newValue) => {
|
||||
self.css = `font-size: ${Math.round(newValue)}px;`
|
||||
}).catch(print);
|
||||
})
|
||||
,
|
||||
}),
|
||||
overlays: [
|
||||
MaterialIcon(`${icon}`, 'hugeass'),
|
||||
],
|
||||
setup: self => self.set_overlay_pass_through(self.get_children()[1], true),
|
||||
}),
|
||||
]
|
||||
})
|
||||
|
||||
const resources = Box({
|
||||
vpack: 'fill',
|
||||
vertical: true,
|
||||
className: 'spacing-v-15',
|
||||
children: [
|
||||
ResourceValue('Memory', 'memory', 10000, `free | awk '/^Mem/ {printf("%.2f\\n", ($3/$2) * 100)}'`,
|
||||
(label) => {
|
||||
execAsync(['bash', '-c', `free -h | awk '/^Mem/ {print $3 " / " $2}' | sed 's/Gi/Gib/g'`])
|
||||
.then((output) => {
|
||||
label.label = `${output}`
|
||||
}).catch(print);
|
||||
}, { hpack: 'end' }),
|
||||
ResourceValue('Swap', 'swap_horiz', 10000, `free | awk '/^Swap/ {if ($2 > 0) printf("%.2f\\n", ($3/$2) * 100); else print "0";}'`,
|
||||
(label) => {
|
||||
execAsync(['bash', '-c', `free -h | awk '/^Swap/ {if ($2 != "0") print $3 " / " $2; else print "No swap"}' | sed 's/Gi/Gib/g'`])
|
||||
.then((output) => {
|
||||
label.label = `${output}`
|
||||
}).catch(print);
|
||||
}, { hpack: 'end' }),
|
||||
ResourceValue('Disk space', 'hard_drive_2', 3600000, `echo $(df --output=pcent / | tr -dc '0-9')`,
|
||||
(label) => {
|
||||
execAsync(['bash', '-c', `df -h --output=avail / | awk 'NR==2{print $1}'`])
|
||||
.then((output) => {
|
||||
label.label = `${output} available`
|
||||
}).catch(print);
|
||||
}, { hpack: 'end' }),
|
||||
]
|
||||
});
|
||||
|
||||
const distroAndVersion = Box({
|
||||
vertical: true,
|
||||
children: [
|
||||
Box({
|
||||
hpack: 'end',
|
||||
children: [
|
||||
Label({
|
||||
className: 'bg-distro-txt',
|
||||
xalign: 0,
|
||||
label: 'Hyping on ',
|
||||
}),
|
||||
Label({
|
||||
className: 'bg-distro-name',
|
||||
xalign: 0,
|
||||
label: '<distro>',
|
||||
setup: (label) => {
|
||||
execAsync([`grep`, `-oP`, `PRETTY_NAME="\\K[^"]+`, `/etc/os-release`]).then(distro => {
|
||||
label.label = distro;
|
||||
}).catch(print);
|
||||
},
|
||||
}),
|
||||
]
|
||||
}),
|
||||
Box({
|
||||
hpack: 'end',
|
||||
children: [
|
||||
Label({
|
||||
className: 'bg-distro-txt',
|
||||
xalign: 0,
|
||||
label: 'with ',
|
||||
}),
|
||||
Label({
|
||||
className: 'bg-distro-name',
|
||||
xalign: 0,
|
||||
label: 'An environment idk',
|
||||
setup: (label) => {
|
||||
// hyprctl will return unsuccessfully if Hyprland isn't running
|
||||
execAsync([`bash`, `-c`, `hyprctl version | grep -oP "Tag: v\\K\\d+\\.\\d+\\.\\d+"`]).then(version => {
|
||||
label.label = `Hyprland ${version}`;
|
||||
}).catch(() => execAsync([`bash`, `-c`, `sway -v | cut -d'-' -f1 | sed 's/sway version /v/'`]).then(version => {
|
||||
label.label = `Sway ${version}`;
|
||||
}).catch(print));
|
||||
},
|
||||
}),
|
||||
]
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
export default () => Box({
|
||||
hpack: 'end',
|
||||
vpack: 'end',
|
||||
children: [
|
||||
EventBox({
|
||||
child: Box({
|
||||
hpack: 'end',
|
||||
vpack: 'end',
|
||||
className: 'bg-distro-box spacing-v-20',
|
||||
vertical: true,
|
||||
children: [
|
||||
resources,
|
||||
distroAndVersion,
|
||||
]
|
||||
}),
|
||||
onPrimaryClickRelease: () => {
|
||||
const kids = resources.get_children();
|
||||
for (let i = 0; i < kids.length; i++) {
|
||||
const child = kids[i];
|
||||
const firstChild = child.get_children()[0];
|
||||
firstChild.revealChild = !firstChild.revealChild;
|
||||
}
|
||||
|
||||
},
|
||||
})
|
||||
],
|
||||
})
|
||||
|
||||
|
||||
|
74
.config/ags/modules/desktopbackground/timeandlaunches.js
Normal file
74
.config/ags/modules/desktopbackground/timeandlaunches.js
Normal file
|
@ -0,0 +1,74 @@
|
|||
const { GLib } = imports.gi;
|
||||
import App from 'resource:///com/github/Aylur/ags/app.js';
|
||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
|
||||
import Variable from 'resource:///com/github/Aylur/ags/variable.js';
|
||||
const { execAsync, exec } = Utils;
|
||||
const { Box, Label, Button, Revealer, EventBox } = Widget;
|
||||
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
|
||||
import { quickLaunchItems } from './data_quicklaunches.js'
|
||||
|
||||
const TimeAndDate = () => Box({
|
||||
vertical: true,
|
||||
className: 'spacing-v--5',
|
||||
children: [
|
||||
Label({
|
||||
className: 'bg-time-clock',
|
||||
xalign: 0,
|
||||
label: GLib.DateTime.new_now_local().format(userOptions.time.format),
|
||||
setup: (self) => self.poll(userOptions.time.interval, label => {
|
||||
label.label = GLib.DateTime.new_now_local().format(userOptions.time.format);
|
||||
}),
|
||||
}),
|
||||
Label({
|
||||
className: 'bg-time-date',
|
||||
xalign: 0,
|
||||
label: GLib.DateTime.new_now_local().format(userOptions.time.dateFormatLong),
|
||||
setup: (self) => self.poll(userOptions.time.dateInterval, (label) => {
|
||||
label.label = GLib.DateTime.new_now_local().format(userOptions.time.dateFormatLong);
|
||||
}),
|
||||
}),
|
||||
]
|
||||
})
|
||||
|
||||
const QuickLaunches = () => Box({
|
||||
vertical: true,
|
||||
className: 'spacing-v-10',
|
||||
children: [
|
||||
Label({
|
||||
xalign: 0,
|
||||
className: 'bg-quicklaunch-title',
|
||||
label: 'Quick Launches',
|
||||
}),
|
||||
Box({
|
||||
hpack: 'start',
|
||||
className: 'spacing-h-5',
|
||||
children: quickLaunchItems.map((item, i) => Button({
|
||||
onClicked: () => {
|
||||
execAsync(['bash', '-c', `${item["command"]}`]).catch(print);
|
||||
},
|
||||
className: 'bg-quicklaunch-btn',
|
||||
child: Label({
|
||||
label: `${item["name"]}`,
|
||||
}),
|
||||
setup: (self) => {
|
||||
setupCursorHover(self);
|
||||
}
|
||||
})),
|
||||
})
|
||||
]
|
||||
})
|
||||
|
||||
export default () => Box({
|
||||
hpack: 'start',
|
||||
vpack: 'end',
|
||||
vertical: true,
|
||||
className: 'bg-time-box spacing-h--10',
|
||||
children: [
|
||||
TimeAndDate(),
|
||||
// QuickLaunches(),
|
||||
],
|
||||
})
|
||||
|
121
.config/ags/modules/desktopbackground/wallpaper.js
Normal file
121
.config/ags/modules/desktopbackground/wallpaper.js
Normal file
|
@ -0,0 +1,121 @@
|
|||
const { Gdk, GdkPixbuf, Gio, GLib, Gtk } = imports.gi;
|
||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
import { SCREEN_HEIGHT, SCREEN_WIDTH } from '../../variables.js';
|
||||
const { exec, execAsync } = Utils;
|
||||
const { Box, Button, Label, Stack } = Widget;
|
||||
import Hyprland from 'resource:///com/github/Aylur/ags/service/hyprland.js';
|
||||
|
||||
import Wallpaper from '../../services/wallpaper.js';
|
||||
import { setupCursorHover } from '../.widgetutils/cursorhover.js';
|
||||
import { clamp } from '../.miscutils/mathfuncs.js';
|
||||
|
||||
const DISABLE_AGS_WALLPAPER = true;
|
||||
|
||||
const SWITCHWALL_SCRIPT_PATH = `${App.configDir}/scripts/color_generation/switchwall.sh`;
|
||||
const WALLPAPER_ZOOM_SCALE = 1.25; // For scrolling when we switch workspace
|
||||
const MAX_WORKSPACES = 10;
|
||||
|
||||
const WALLPAPER_OFFSCREEN_X = (WALLPAPER_ZOOM_SCALE - 1) * SCREEN_WIDTH;
|
||||
const WALLPAPER_OFFSCREEN_Y = (WALLPAPER_ZOOM_SCALE - 1) * SCREEN_HEIGHT;
|
||||
|
||||
|
||||
export default (monitor = 0) => {
|
||||
const wallpaperImage = Widget.DrawingArea({
|
||||
attribute: {
|
||||
pixbuf: undefined,
|
||||
workspace: 1,
|
||||
sideleft: 0,
|
||||
sideright: 0,
|
||||
updatePos: (self) => {
|
||||
self.setCss(`font-size: ${self.attribute.workspace - self.attribute.sideleft + self.attribute.sideright}px;`)
|
||||
},
|
||||
},
|
||||
className: 'bg-wallpaper-transition',
|
||||
setup: (self) => {
|
||||
self.set_size_request(SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
self
|
||||
// TODO: reduced updates using timeouts to reduce lag
|
||||
// .hook(Hyprland.active.workspace, (self) => {
|
||||
// self.attribute.workspace = Hyprland.active.workspace.id
|
||||
// self.attribute.updatePos(self);
|
||||
// })
|
||||
// .hook(App, (box, name, visible) => { // Update on open
|
||||
// if (self.attribute[name] === undefined) return;
|
||||
// self.attribute[name] = (visible ? 1 : 0);
|
||||
// self.attribute.updatePos(self);
|
||||
// })
|
||||
.on('draw', (self, cr) => {
|
||||
if (!self.attribute.pixbuf) return;
|
||||
const styleContext = self.get_style_context();
|
||||
const workspace = styleContext.get_property('font-size', Gtk.StateFlags.NORMAL);
|
||||
// Draw
|
||||
Gdk.cairo_set_source_pixbuf(cr, self.attribute.pixbuf,
|
||||
-(WALLPAPER_OFFSCREEN_X / (MAX_WORKSPACES + 1) * (clamp(workspace, 0, MAX_WORKSPACES + 1))),
|
||||
-WALLPAPER_OFFSCREEN_Y / 2);
|
||||
cr.paint();
|
||||
})
|
||||
.hook(Wallpaper, (self) => {
|
||||
if (DISABLE_AGS_WALLPAPER) return;
|
||||
const wallPath = Wallpaper.get(monitor);
|
||||
if (!wallPath || wallPath === "") return;
|
||||
self.attribute.pixbuf = GdkPixbuf.Pixbuf.new_from_file(wallPath);
|
||||
|
||||
const scale_x = SCREEN_WIDTH * WALLPAPER_ZOOM_SCALE / self.attribute.pixbuf.get_width();
|
||||
const scale_y = SCREEN_HEIGHT * WALLPAPER_ZOOM_SCALE / self.attribute.pixbuf.get_height();
|
||||
const scale_factor = Math.max(scale_x, scale_y);
|
||||
|
||||
self.attribute.pixbuf = self.attribute.pixbuf.scale_simple(
|
||||
Math.round(self.attribute.pixbuf.get_width() * scale_factor),
|
||||
Math.round(self.attribute.pixbuf.get_height() * scale_factor),
|
||||
GdkPixbuf.InterpType.BILINEAR
|
||||
);
|
||||
self.queue_draw();
|
||||
}, 'updated');
|
||||
;
|
||||
}
|
||||
,
|
||||
});
|
||||
const wallpaperPrompt = Box({
|
||||
hpack: 'center',
|
||||
vpack: 'center',
|
||||
vertical: true,
|
||||
className: 'spacing-v-10',
|
||||
children: [
|
||||
Label({
|
||||
hpack: 'center',
|
||||
justification: 'center',
|
||||
className: 'txt-large',
|
||||
label: `No wallpaper loaded.\nAn image ≥ ${SCREEN_WIDTH * WALLPAPER_ZOOM_SCALE} × ${SCREEN_HEIGHT * WALLPAPER_ZOOM_SCALE} is recommended.`,
|
||||
}),
|
||||
Button({
|
||||
hpack: 'center',
|
||||
className: 'btn-primary',
|
||||
label: `Select one`,
|
||||
setup: setupCursorHover,
|
||||
onClicked: (self) => Utils.execAsync([SWITCHWALL_SCRIPT_PATH]).catch(print),
|
||||
}),
|
||||
]
|
||||
});
|
||||
const stack = Stack({
|
||||
transition: 'crossfade',
|
||||
transitionDuration: userOptions.animations.durationLarge,
|
||||
children: {
|
||||
'disabled': Box({}),
|
||||
'image': wallpaperImage,
|
||||
'prompt': wallpaperPrompt,
|
||||
},
|
||||
setup: (self) => self
|
||||
.hook(Wallpaper, (self) => {
|
||||
if(DISABLE_AGS_WALLPAPER) {
|
||||
self.shown = 'disabled';
|
||||
return;
|
||||
}
|
||||
const wallPath = Wallpaper.get(monitor);
|
||||
self.shown = ((wallPath && wallPath != "") ? 'image' : 'prompt');
|
||||
}, 'updated')
|
||||
,
|
||||
})
|
||||
return stack;
|
||||
// return wallpaperImage;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue