mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
parallax wallpaper
This commit is contained in:
parent
3a4a5226b8
commit
a7d70b7cb0
5 changed files with 44 additions and 34 deletions
|
|
@ -12,7 +12,8 @@ else
|
|||
exit 0
|
||||
fi
|
||||
|
||||
ags run-js "wallpaper.set('${imgpath}')"
|
||||
ags run-js "wallpaper.set('')"
|
||||
sleep 0.1 && ags run-js "wallpaper.set('${imgpath}')" &
|
||||
fi
|
||||
|
||||
# Generate colors for ags n stuff
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ function trimTrackTitle(title) {
|
|||
/【[^】]*】/, // Touhou n weeb stuff
|
||||
/\[FREE DOWNLOAD\]/, // F-777
|
||||
];
|
||||
cleanRegexes.forEach((expr) => cleanedTitle.replace(expr, ''));
|
||||
cleanRegexes.forEach((expr) => title.replace(expr, ''));
|
||||
return title;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ export default (monitor) => Widget.Window({
|
|||
layer: 'background',
|
||||
exclusivity: 'ignore',
|
||||
visible: true,
|
||||
// child: Wallpaper(monitor),
|
||||
// child: WallpaperImage(monitor),
|
||||
child: Widget.Overlay({
|
||||
child: WallpaperImage(monitor),
|
||||
overlays: [
|
||||
|
|
@ -21,4 +21,4 @@ export default (monitor) => Widget.Window({
|
|||
self.set_overlay_pass_through(self.get_children()[1], true);
|
||||
},
|
||||
}),
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,47 +4,56 @@ import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
|||
import { SCREEN_HEIGHT, SCREEN_WIDTH } from '../../imports.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 '../../lib/cursorhover.js';
|
||||
|
||||
const SWITCHWALL_SCRIPT_PATH = `${App.configDir}/scripts/color_generation/switchwall.sh`;
|
||||
const WALLPAPER_ZOOM_SCALE = 1.1; // 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) => {
|
||||
let pixbuf = undefined;
|
||||
const wallpaperImage = Widget.DrawingArea({
|
||||
css: `transition: 1000ms cubic-bezier(0.1, 1, 0, 1);`,
|
||||
setup: (self) => {
|
||||
attribute: {
|
||||
pixbuf: undefined,
|
||||
},
|
||||
css: `transition: 2000ms cubic-bezier(0.05, 0.7, 0.1, 1); font-size: 1px;`,
|
||||
setup: (self) => {
|
||||
self.set_size_request(SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
self.on('draw', (widget, cr) => {
|
||||
if (!pixbuf) return;
|
||||
Gdk.cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
|
||||
cr.paint();
|
||||
});
|
||||
self.hook(Wallpaper, (self) => {
|
||||
const wallPath = Wallpaper.get(monitor);
|
||||
if (!wallPath || wallPath === "") return;
|
||||
pixbuf = GdkPixbuf.Pixbuf.new_from_file(wallPath);
|
||||
|
||||
const scale_x = SCREEN_WIDTH * WALLPAPER_ZOOM_SCALE / pixbuf.get_width();
|
||||
const scale_y = SCREEN_HEIGHT * WALLPAPER_ZOOM_SCALE / pixbuf.get_height();
|
||||
const scale_factor = Math.max(scale_x, scale_y);
|
||||
self
|
||||
.hook(Hyprland.active.workspace, (self) =>
|
||||
self.setCss(`font-size: ${Hyprland.active.workspace.id}px;`)
|
||||
)
|
||||
.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);
|
||||
Gdk.cairo_set_source_pixbuf(cr, self.attribute.pixbuf,
|
||||
-(WALLPAPER_OFFSCREEN_X / (MAX_WORKSPACES - 1) * (workspace - 1)),
|
||||
-WALLPAPER_OFFSCREEN_Y / 2);
|
||||
cr.paint();
|
||||
})
|
||||
.hook(Wallpaper, (self) => {
|
||||
const wallPath = Wallpaper.get(monitor);
|
||||
if (!wallPath || wallPath === "") return;
|
||||
self.attribute.pixbuf = GdkPixbuf.Pixbuf.new_from_file(wallPath);
|
||||
|
||||
pixbuf = pixbuf.scale_simple(
|
||||
Math.round(pixbuf.get_width() * scale_factor),
|
||||
Math.round(pixbuf.get_height() * scale_factor),
|
||||
GdkPixbuf.InterpType.BILINEAR
|
||||
);
|
||||
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);
|
||||
|
||||
// pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(wallPath, SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
// console.log(pixbuf.get_width(), pixbuf.get_height())
|
||||
|
||||
// pixbuf = GdkPixbuf.Pixbuf.new_from_file(wallPath);
|
||||
// console.log(pixbuf.get_width(), pixbuf.get_height())
|
||||
|
||||
self.queue_draw();
|
||||
}, 'updated');
|
||||
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');
|
||||
;
|
||||
}
|
||||
,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ function trimTrackTitle(title) {
|
|||
/【[^】]*】/, // Touhou n weeb stuff
|
||||
/\[FREE DOWNLOAD\]/, // F-777
|
||||
];
|
||||
cleanRegexes.forEach((expr) => cleanedTitle.replace(expr, ''));
|
||||
cleanRegexes.forEach((expr) => title.replace(expr, ''));
|
||||
return title;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue