mirror of
https://github.com/danbulant/dots-hyprland
synced 2026-05-24 12:22:09 +00:00
fix wallpaper for multimonitor (#200); recommend image size
This commit is contained in:
parent
15c426df9e
commit
34622f29cf
2 changed files with 15 additions and 9 deletions
|
|
@ -1,4 +1,4 @@
|
|||
const { Gio, GLib } = imports.gi;
|
||||
const { Gdk, Gio, GLib } = imports.gi;
|
||||
import Service from 'resource:///com/github/Aylur/ags/service.js';
|
||||
import * as Utils from 'resource:///com/github/Aylur/ags/utils.js';
|
||||
const { exec, execAsync } = Utils;
|
||||
|
|
@ -19,6 +19,7 @@ class WallpaperService extends Service {
|
|||
|
||||
_wallPath = '';
|
||||
_wallJson = [];
|
||||
_monitorCount = 1;
|
||||
|
||||
_save() {
|
||||
Utils.writeFile(JSON.stringify(this._wallJson), this._wallPath)
|
||||
|
|
@ -32,7 +33,8 @@ class WallpaperService extends Service {
|
|||
}
|
||||
|
||||
set(path, monitor = -1) {
|
||||
if(this._wallJson.length == 0) this._wallJson.push("");
|
||||
this._monitorCount = Gdk.Display.get_default()?.get_n_monitors() || 1;
|
||||
if (this._wallJson.length < this._monitorCount) this._wallJson[this._monitorCount - 1] = "";
|
||||
if (monitor == -1)
|
||||
this._wallJson.fill(path);
|
||||
else
|
||||
|
|
@ -48,18 +50,21 @@ class WallpaperService extends Service {
|
|||
|
||||
constructor() {
|
||||
super();
|
||||
// How many screens?
|
||||
this._monitorCount = Gdk.Display.get_default()?.get_n_monitors() || 1;
|
||||
// Read config
|
||||
this._wallPath = `${GLib.get_user_cache_dir()}/ags/user/wallpaper.json`;
|
||||
if (!fileExists(this._wallPath)) { // No? create file with empty array
|
||||
try {
|
||||
const fileContents = Utils.readFile(this._wallPath);
|
||||
this._wallJson = JSON.parse(fileContents);
|
||||
}
|
||||
catch {
|
||||
Utils.exec(`bash -c 'mkdir -p ${GLib.get_user_cache_dir()}/ags/user'`);
|
||||
Utils.exec(`touch ${this._wallPath}`);
|
||||
Utils.writeFile('[]', this._wallPath).then(() => {
|
||||
this._wallJson = JSON.parse(Utils.readFile(this._wallPath))
|
||||
}).catch(print);
|
||||
}
|
||||
else {
|
||||
const fileContents = Utils.readFile(this._wallPath);
|
||||
this._wallJson = JSON.parse(fileContents);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ 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 WALLPAPER_ZOOM_SCALE = 1.2; // For scrolling when we switch workspace
|
||||
const MAX_WORKSPACES = 10;
|
||||
|
||||
const WALLPAPER_OFFSCREEN_X = (WALLPAPER_ZOOM_SCALE - 1) * SCREEN_WIDTH;
|
||||
|
|
@ -69,8 +69,9 @@ export default (monitor = 0) => {
|
|||
children: [
|
||||
Label({
|
||||
hpack: 'center',
|
||||
justification: 'center',
|
||||
className: 'txt-large',
|
||||
label: `No wallpaper loaded`,
|
||||
label: `No wallpaper loaded.\nAn image ≥ ${SCREEN_WIDTH * WALLPAPER_ZOOM_SCALE} × ${SCREEN_HEIGHT * WALLPAPER_ZOOM_SCALE} is recommended.`,
|
||||
}),
|
||||
Button({
|
||||
hpack: 'center',
|
||||
|
|
|
|||
Loading…
Reference in a new issue