forked from Shinonome/dots-hyprland
user-friendly wallpaper; some fixes
This commit is contained in:
@@ -34,7 +34,7 @@ function applyStyle() {
|
||||
applyStyle();
|
||||
|
||||
const Windows = () => [
|
||||
DesktopBackground(),
|
||||
forMonitors(DesktopBackground),
|
||||
// Dock(),
|
||||
Overview(),
|
||||
forMonitors(Indicator),
|
||||
|
||||
@@ -34,7 +34,7 @@ elif len(sys.argv) > 1 and sys.argv[1] == '--color':
|
||||
newtheme = themeFromSourceColor(argbFromHex(colorstr))
|
||||
else:
|
||||
# try:
|
||||
imagePath = subprocess.check_output("swww query | awk -F 'image: ' '{print $2}'", shell=True)
|
||||
imagePath = subprocess.check_output("ags run-js 'wallpaper.get(0)'", shell=True)
|
||||
imagePath = imagePath[:-1].decode("utf-8")
|
||||
img = Image.open(imagePath)
|
||||
basewidth = 64
|
||||
|
||||
@@ -1,28 +1,18 @@
|
||||
#!/usr/bin/bash
|
||||
# Switches swww wallpaper
|
||||
# Requires: coreutils, xrandr, hyprland
|
||||
|
||||
if [ "$1" == "--noswitch" ]; then
|
||||
imgpath=$(swww query | awk -F 'image: ' '{print $2}')
|
||||
imgpath=$(ags run-js 'wallpaper.get(0)')
|
||||
else
|
||||
# Select and set image (hyprland)
|
||||
cd "$HOME/Pictures"
|
||||
imgpath=$(yad --width 1200 --height 800 --file --title='Choose wallpaper')
|
||||
screensizey=$(xrandr --current | grep '*' | uniq | awk '{print $1}' | cut -d 'x' -f2 | head -1)
|
||||
cursorposx=$(hyprctl cursorpos -j | gojq '.x')
|
||||
cursorposy=$(hyprctl cursorpos -j | gojq '.y')
|
||||
cursorposy_inverted=$(( screensizey - cursorposy ))
|
||||
|
||||
if [ "$imgpath" == '' ]; then
|
||||
echo 'Aborted'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo Sending "$imgpath" to swww. Cursor pos: ["$cursorposx, $cursorposy_inverted"]
|
||||
# Change swww wallpaper
|
||||
swww img "$imgpath" --transition-step 100 --transition-fps 60 \
|
||||
--transition-type grow --transition-angle 30 --transition-duration 1 \
|
||||
--transition-pos "$cursorposx, $cursorposy_inverted"
|
||||
ags run-js "wallpaper.set('${imgpath}')"
|
||||
fi
|
||||
|
||||
# Generate colors for ags n stuff
|
||||
|
||||
@@ -139,6 +139,13 @@
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
@include full-rounding;
|
||||
background-color: $primary;
|
||||
color: $onPrimary;
|
||||
padding: 0.682rem 1.023rem;
|
||||
}
|
||||
|
||||
.titlefont {
|
||||
@include titlefont;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
.overview-tasks-window {
|
||||
@include normal-rounding;
|
||||
@include menu_decel;
|
||||
background-color: $l_t_secondaryContainer;
|
||||
background-color: $t_surfaceVariant;
|
||||
color: $onSecondaryContainer;
|
||||
border: 0.068rem solid $t_t_t_onSecondaryContainer;
|
||||
}
|
||||
|
||||
@@ -32,24 +32,26 @@ class TodoService extends Service {
|
||||
return this._todoJson;
|
||||
}
|
||||
|
||||
add(content) {
|
||||
this._todoJson.push({ content, done: false });
|
||||
_save() {
|
||||
Utils.writeFile(JSON.stringify(this._todoJson), this._todoPath)
|
||||
.catch(print);
|
||||
}
|
||||
|
||||
add(content) {
|
||||
this._todoJson.push({ content, done: false });
|
||||
this._save();
|
||||
this.emit('updated');
|
||||
}
|
||||
|
||||
check(index) {
|
||||
this._todoJson[index].done = true;
|
||||
Utils.writeFile(JSON.stringify(this._todoJson), this._todoPath)
|
||||
.catch(print);
|
||||
this._save();
|
||||
this.emit('updated');
|
||||
}
|
||||
|
||||
uncheck(index) {
|
||||
this._todoJson[index].done = false;
|
||||
Utils.writeFile(JSON.stringify(this._todoJson), this._todoPath)
|
||||
.catch(print);
|
||||
this._save();
|
||||
this.emit('updated');
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
const { 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;
|
||||
|
||||
const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
|
||||
function fileExists(filePath) {
|
||||
let file = Gio.File.new_for_path(filePath);
|
||||
return file.query_exists(null);
|
||||
}
|
||||
|
||||
class WallpaperService extends Service {
|
||||
static {
|
||||
Service.register(
|
||||
this,
|
||||
{ 'updated': [], },
|
||||
);
|
||||
}
|
||||
|
||||
_wallPath = '';
|
||||
_wallJson = [];
|
||||
|
||||
_save() {
|
||||
Utils.writeFile(JSON.stringify(this._wallJson), this._wallPath)
|
||||
.catch(print);
|
||||
}
|
||||
|
||||
add(path) {
|
||||
this._wallJson.push(path);
|
||||
this._save();
|
||||
this.emit('updated');
|
||||
}
|
||||
|
||||
set(path, monitor = -1) {
|
||||
if(this._wallJson.length == 0) this._wallJson.push("");
|
||||
if (monitor == -1)
|
||||
this._wallJson.fill(path);
|
||||
else
|
||||
this._wallJson[monitor] = path;
|
||||
|
||||
this._save();
|
||||
this.emit('updated');
|
||||
}
|
||||
|
||||
get(monitor = 0) {
|
||||
return this._wallJson[monitor];
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
this._wallPath = `${GLib.get_user_cache_dir()}/ags/user/wallpaper.json`;
|
||||
if (!fileExists(this._wallPath)) { // No? create file with empty array
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// instance
|
||||
const service = new WallpaperService();
|
||||
// make it global for easy use with cli
|
||||
globalThis['wallpaper'] = service;
|
||||
export default service;
|
||||
+351
-344
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@ import { AnimatedCircProg } from "../../lib/animatedcircularprogress.js";
|
||||
import { showMusicControls } from '../../variables.js';
|
||||
|
||||
function trimTrackTitle(title) {
|
||||
cleanRegexes = [
|
||||
const cleanRegexes = [
|
||||
/【[^】]*】/, // Touhou n weeb stuff
|
||||
/\[FREE DOWNLOAD\]/, // F-777
|
||||
];
|
||||
|
||||
@@ -1,23 +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 () => Widget.Window({
|
||||
export default (monitor) => Widget.Window({
|
||||
name: 'desktopbackground',
|
||||
anchor: ['top', 'bottom', 'left', 'right'],
|
||||
layer: 'bottom',
|
||||
exclusivity: 'normal',
|
||||
// anchor: ['top', 'bottom', 'left', 'right'],
|
||||
layer: 'background',
|
||||
exclusivity: 'ignore',
|
||||
visible: true,
|
||||
// child: Wallpaper(monitor),
|
||||
child: Widget.Overlay({
|
||||
child: Widget.Box({
|
||||
hexpand: true,
|
||||
vexpand: true,
|
||||
}),
|
||||
child: WallpaperImage(monitor),
|
||||
overlays: [
|
||||
TimeAndLaunchesWidget(),
|
||||
SystemWidget(),
|
||||
],
|
||||
setup: (self) => self.set_overlay_pass_through(self.get_children()[1], true),
|
||||
setup: (self) => {
|
||||
self.set_overlay_pass_through(self.get_children()[1], true);
|
||||
},
|
||||
}),
|
||||
});
|
||||
@@ -0,0 +1,87 @@
|
||||
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 '../../imports.js';
|
||||
const { exec, execAsync } = Utils;
|
||||
const { Box, Button, Label, Stack } = Widget;
|
||||
|
||||
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
|
||||
|
||||
export default (monitor = 0) => {
|
||||
let pixbuf = undefined;
|
||||
const wallpaperImage = Widget.DrawingArea({
|
||||
css: `transition: 1000ms cubic-bezier(0.1, 1, 0, 1);`,
|
||||
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);
|
||||
|
||||
pixbuf = pixbuf.scale_simple(
|
||||
Math.round(pixbuf.get_width() * scale_factor),
|
||||
Math.round(pixbuf.get_height() * scale_factor),
|
||||
GdkPixbuf.InterpType.BILINEAR
|
||||
);
|
||||
|
||||
// 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');
|
||||
}
|
||||
,
|
||||
});
|
||||
const wallpaperPrompt = Box({
|
||||
hpack: 'center',
|
||||
vpack: 'center',
|
||||
vertical: true,
|
||||
className: 'spacing-v-10',
|
||||
children: [
|
||||
Label({
|
||||
hpack: 'center',
|
||||
className: 'txt-large',
|
||||
label: `No wallpaper loaded`,
|
||||
}),
|
||||
Button({
|
||||
hpack: 'center',
|
||||
className: 'btn-primary',
|
||||
label: `Select one`,
|
||||
setup: setupCursorHover,
|
||||
onClicked: (self) => Utils.execAsync([SWITCHWALL_SCRIPT_PATH]),
|
||||
}),
|
||||
]
|
||||
});
|
||||
const stack = Stack({
|
||||
transition: 'crossfade',
|
||||
transitionDuration: 180,
|
||||
items: [
|
||||
['image', wallpaperImage],
|
||||
['prompt', wallpaperPrompt],
|
||||
],
|
||||
setup: (self) => self
|
||||
.hook(Wallpaper, (self) => {
|
||||
const wallPath = Wallpaper.get(monitor);
|
||||
self.shown = ((wallPath && wallPath != "") ? 'image' : 'prompt');
|
||||
}, 'updated')
|
||||
,
|
||||
})
|
||||
return stack;
|
||||
// return wallpaperImage;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import Widget from 'resource:///com/github/Aylur/ags/widget.js';
|
||||
import Indicator from '../../services/indicator.js';
|
||||
import IndicatorValues from './indicatorvalues.js';
|
||||
import MusicControls from './musiccontrols.js';
|
||||
// import MusicControls from './musiccontrols.js';
|
||||
import ColorScheme from './colorscheme.js';
|
||||
import NotificationPopups from './notificationpopups.js';
|
||||
|
||||
@@ -23,7 +23,7 @@ export default (monitor = 0) => Widget.Window({
|
||||
css: 'min-height: 2px;',
|
||||
children: [
|
||||
IndicatorValues(),
|
||||
MusicControls(),
|
||||
// MusicControls(),
|
||||
NotificationPopups(),
|
||||
ColorScheme(),
|
||||
]
|
||||
|
||||
@@ -69,7 +69,7 @@ function getTrackfont(player) {
|
||||
return DEFAULT_MUSIC_FONT;
|
||||
}
|
||||
function trimTrackTitle(title) {
|
||||
cleanRegexes = [
|
||||
const cleanRegexes = [
|
||||
/【[^】]*】/, // Touhou n weeb stuff
|
||||
/\[FREE DOWNLOAD\]/, // F-777
|
||||
];
|
||||
|
||||
@@ -10,7 +10,7 @@ export default Scrollable({
|
||||
child: Box({
|
||||
vertical: true,
|
||||
children: [
|
||||
QuickScripts(),
|
||||
// QuickScripts(),
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
@@ -4,7 +4,8 @@ env = QT_IM_MODULE, fcitx
|
||||
env = XMODIFIERS, @im=fcitx
|
||||
|
||||
############# Themes #############
|
||||
# env = QT_QPA_PLATFORMTHEME, qt5ct
|
||||
env = QT_QPA_PLATFORM, wayland
|
||||
env = QT_QPA_PLATFORMTHEME, qt5ct
|
||||
# env = QT_STYLE_OVERRIDE,kvantum
|
||||
env = WLR_NO_HARDWARE_CURSORS, 1
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
# Wallpaper
|
||||
#exec-once = swaybg -i ~/.config/eww/images/wallpaper/wallpaper
|
||||
exec-once = swww init; swww kill; swww init # idk why tbh
|
||||
|
||||
# Status bar
|
||||
#exec-once = eww daemon && eww open bar && eww open bgdecor
|
||||
exec-once = ags &
|
||||
|
||||
@@ -30,7 +30,7 @@ input {
|
||||
scroll_factor = 0.5
|
||||
}
|
||||
|
||||
special_fallthrough = true
|
||||
# special_fallthrough = true
|
||||
}
|
||||
|
||||
binds {
|
||||
|
||||
@@ -21,6 +21,7 @@ layerrule = xray 1, .*
|
||||
#layerrule = noanim, .*
|
||||
layerrule = noanim, selection
|
||||
layerrule = noanim, overview
|
||||
layerrule = noanim, anyrun
|
||||
layerrule = blur, swaylock
|
||||
|
||||
layerrule = blur, eww
|
||||
|
||||
Reference in New Issue
Block a user