aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetri Hienonen <petri.hienonen@gmail.com>2025-10-18 15:08:35 +0300
committerPetri Hienonen <petri.hienonen@gmail.com>2025-10-18 15:08:35 +0300
commitc105a7520ae1d0d9f59e3a6325c0b73f36ed85ed (patch)
treef0ce2bf77bd272b73a762bd0a868e0d0e7b842a3
parent1dd8bd776c516d122cb849c1c681a6bdbff30b06 (diff)
downloadwallpaper-c105a7520ae1d0d9f59e3a6325c0b73f36ed85ed.tar.zst
Debug
-rw-r--r--flake.nix2
-rw-r--r--shaders/red.wgsl13
-rw-r--r--src/main.rs34
-rw-r--r--src/wayland.rs9
4 files changed, 36 insertions, 22 deletions
diff --git a/flake.nix b/flake.nix
index caa775f..fcc6750 100644
--- a/flake.nix
+++ b/flake.nix
@@ -100,7 +100,7 @@
}/bin/hyprland-live-wallpaper --shader ${cfg.shader}";
Restart = "on-failure";
Environment = [
- "RUST_LOG=info"
+ "RUST_LOG=wgpu=info"
];
};
};
diff --git a/shaders/red.wgsl b/shaders/red.wgsl
new file mode 100644
index 0000000..47f837b
--- /dev/null
+++ b/shaders/red.wgsl
@@ -0,0 +1,13 @@
+@vertex
+fn vs_main(@builtin(vertex_index) vertex_index: u32) -> @builtin(position) vec4<f32> {
+ let pos = vec2<f32>(
+ f32(vertex_index == 0u) * 4.0 - 1.0,
+ f32(vertex_index == 1u) * 4.0 - 1.0
+ );
+ return vec4<f32>(pos, 0.0, 1.0);
+}
+
+@fragment
+fn fs_main() -> @location(0) vec4<f32> {
+ return vec4<f32>(1.0, 0.0, 0.0, 1.0);
+}
diff --git a/src/main.rs b/src/main.rs
index 2081584..64dfdba 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -199,14 +199,15 @@ impl WallpaperApp {
Ok(())
}
fn resize(&mut self, new_size: winit::dpi::PhysicalSize<u32>) {
- if new_size.width > 0 && new_size.height > 0
+ if new_size.width > 0
+ && new_size.height > 0
&& let (Some(surface), Some(device), Some(config)) =
(&self.surface, &self.device, &mut self.config)
- {
- config.width = new_size.width;
- config.height = new_size.height;
- surface.configure(device, config);
- }
+ {
+ config.width = new_size.width;
+ config.height = new_size.height;
+ surface.configure(device, config);
+ }
}
fn render(&mut self) -> Result<()> {
let surface = self
@@ -323,16 +324,16 @@ impl ApplicationHandler for WallpaperApp {
WindowEvent::RedrawRequested => {
// Apply Hyprland rules on first redraw (after window is mapped)
if !self.wayland_configured
- && let Some(window) = &self.window {
- // Convert window ID to u64 for hyprctl
- let window_id: u64 = window.id().into();
- if let Err(e) =
- wayland::apply_hyprland_rules(window_id, &self.hyprland_config)
- {
- warn!("Failed to apply Hyprland rules: {}", e);
- }
- self.wayland_configured = true;
+ && let Some(window) = &self.window
+ {
+ // Convert window ID to u64 for hyprctl
+ let window_id: u64 = window.id().into();
+ if let Err(e) = wayland::apply_hyprland_rules(window_id, &self.hyprland_config)
+ {
+ warn!("Failed to apply Hyprland rules: {}", e);
}
+ self.wayland_configured = true;
+ }
if let Err(e) = self.render() {
error!("Render error: {}", e);
event_loop.exit();
@@ -364,7 +365,7 @@ fn main() -> Result<()> {
let shader_path = matches
.get_one::<String>("shader")
.map(|s| s.as_str())
- .unwrap_or("shaders/default.wgsl")
+ .unwrap_or("shaders/red.wgsl")
.to_string();
run_wallpaper(shader_path)?;
Ok(())
@@ -375,4 +376,3 @@ fn run_wallpaper(shader_path: String) -> Result<()> {
event_loop.run_app(&mut app)?;
Ok(())
}
-
diff --git a/src/wayland.rs b/src/wayland.rs
index f9c396d..54699ec 100644
--- a/src/wayland.rs
+++ b/src/wayland.rs
@@ -30,10 +30,11 @@ pub fn configure_hyprland_window(
// For Hyprland, we can use hyprctl to configure the window
// This requires the window to be created first, so we'll do this after creation
if let Ok(output) = Command::new("which").arg("hyprctl").output()
- && output.status.success() {
- info!("Hyprland detected, will configure window properties");
- // We'll configure the window after it's mapped in the event loop
- }
+ && output.status.success()
+ {
+ info!("Hyprland detected, will configure window properties");
+ // We'll configure the window after it's mapped in the event loop
+ }
Ok(())
}