While customizing my desktop with fun little overlays using Hyprwinwrap, I thought it would be really cool to display shaders on top of my wallpaper. After trying and failing to find an existing program that would suit my needs, a new project idea was born.
Awesome, but maybe you want something more “interesting”. Here’s a ShaderToy converted shader called Eon:
I realized early in the project most of the fun ShaderToy projects use layering with iChannels and more than one shader. This program uses a similar structure so it’s possible to achieve advanced effects.
Cellular automata simulation
For instance, put a file named “shader0.frag/shader0.vert” next to wayshader for a basic one shader setup. If you need multipass rendering on that one shader, simply insert uniform sampler2D u_sampler0 as a variable. u_sampler0 will then contain a reference to last frame’s buffer so you can make trails, transformations, etc.
Want another layer? Easy. Add “shader1.frag/shader1.vert” next to the program. This shader will be rendered as its own pass on top of the previous shader.
The u_sampler variables are mapped to each shader’s index; u_sampler0 is always a reference to shader0‘s buffer. shader1 has access to u_sampler1, which is a reference to its own buffer. shader2 will have access to u_sampler0, u_sampler1, and u_sampler2 (its own buffer). Supports up to 32 “channels” with the same pattern.
It also provides basic inputs in the form of u_resolution, u_time, and u_frame.
Linux is a real joy compared to Windows. Finally, my computer is my own again. No more nagging ads, settings changing automatically, or random telemetry taking up valuable CPU time. Using Linux is like getting rid of that old 1961 American Rambler and finally joining modern society with an electric car.
Using Hyprland is like ditching your car for a spaceship. Not very practical for commuting, but really fun nonetheless. And, everyone stares at you whenever you land it in the grocery store parking lot, so it’s all worth it, right?
Since Hyprland is a relatively new Wayland compositor, there are a few things that bothered me when attempting to implement the experience I wanted.
Hyprland has a built in setting (input:touchpad:disable_while_typing) to hopefully prevent palms from messing with the cursor. If you’re lucky, Hyprland thinks your touchpad is a mouse, so this setting doesn’t work at all.
hyprctl devices
We can re-implement our desired behavior:
Read input from our main keyboard
Disable the touchpad device on input
Re-enable the touchpad device after X ms have elapsed
First we’ll figure out our devices.
ls /dev/input/by-id/
There may be a few that match what we’re looking for. usb-Razer_Razer_Blade-if01-event-kbd was the one that worked in my case.
And then from the previous screenshot where we ran hyprctl devices, we’ve already discovered the touchpad is elan0406:00-04f3:31a6-touchpad.
We could choose any language to write a daemon, but I’ll pick C. It’s fast, performant, and has a tiny memory footprint. This will allow the daemon/program to sit at 0% CPU usage when idle and take up mere megabytes of our RAM.
Unfortunately, when you fullscreen an application the gaps you chose will stay the same. This means no matter your gap preference, unless it’s 0, you can see behind the window.
You also have to disable rounded corners, otherwise there will be tiny gaps in all four quadrants.
Additionally, by default there’s no visual variation between a window that exists by itself on a workspace, and a fullscreen window. This can lead to confusion unless you explicitly style fullscreen windows borders differently.
We can add some configurations to our hyprland.conf to differentiate it a bit.
windowrule = bordercolor rgb(ffc1e4), fullscreen:1
windowrule = rounding 0, fullscreen:1
windowrule = bordersize 2, fullscreen:1 # or 0 for none
As stated above, if we’ve set any gap size at all, there will still be space between the fullscreen window and the screen edge. This is not ideal.
Let’s fix it. You’d think we can just do something similar to the above, right?
Wrong! These are not valid properties. You must set them in the general or workspace namespace.
Okay, so we want an application that can do the following:
Keep track of the fullscreen state
Change the configuration when fullscreen
Leave all other windows alone
We could bind a fullscreen shortcut to run a script that would both update the gap settings and toggle fullscreen for the active window. This seems fine and recommended. Unfortunately this is a bad solution, because there are way too many edge cases to handle.
Double clicking a titlebar to maximize would not trigger our solution
Maximizing, then closing the application window would not update our tracked boolean, making the next maximize do nothing until pressed twice
Maximizing, then tabbing to another workspace would mean our settings changes remain, making all normal windows have no gap
We could try to track window closes and any potential edge case, but it becomes messy and complex quickly, without solving the problem cleanly.
The solution is yet another lightweight daemon. We can track fullscreen changes directly from the compositor socket itself, ensuring we catch everything. Once we know the fullscreen state and which window specifically, it’s trivial to hand that information off to a script that handles setting changes for us.
But wait, how does this solve the problem of settings applying to all our other windows which aren’t fullscreen? The hint was mentioned above.
Hyprland has individual workspace separated settings, so you can do something like this:
workspace = 1, gapsin:3, gapsout:2
workspace = 2, gapsin:10, gapsout:10 # example
workspace = 3, gapsin:5, gapsout:12 # example
workspace = 4, gapsin:20, gapsout:9 # example
This is important because logically, if a window were fullscreened on a certain workspace, no other windows are visible. That means an individual workspace config essentially becomes that window’s config.
The last piece we need is to find out where we can get window information from. The hyprctl activewindow -j command is perfectly suitable for this.
I’m going to write the daemon in C again for the same reasons mentioned above.
#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
#define BUF_SIZE 4096
static void tag_window(const char *addr, int add) {
if (!addr || !addr[0])
return;
char cmd[512];
int ret =
snprintf(cmd, sizeof(cmd),
"hyprctl dispatch tagwindow %s%sfullscreen_mode address:%s > /dev/null 2>&1",
add ? "+" : "-- -", add ? "" : "", addr);
if (ret < 0 || ret >= sizeof(cmd))
return;
system(cmd);
}
static void run_fullscreen_handler(const char *addr, int fs, int workspace) {
if (!addr || !addr[0])
return;
char cmd[512];
int ret = snprintf(
cmd, sizeof(cmd),
"/home/user/.config/hypr/UserScripts/FullscreenHandler.sh %s %d %d > /dev/null 2>&1",
addr, fs, workspace);
if (ret < 0 || ret >= sizeof(cmd))
return;
system(cmd);
}
static void query_active_window(void) {
FILE *fp = popen("hyprctl activewindow -j", "r");
if (!fp) {
fprintf(stderr, "Failed to query active window\n");
return;
}
char buf[BUF_SIZE];
char address[128] = {0};
int fullscreen = -1;
int workspace = -1;
int in_workspace = 0;
while (fgets(buf, sizeof(buf), fp)) {
if (strstr(buf, "\"address\"")) {
sscanf(buf, " \"address\": \"%[^\"]\"", address);
}
if (strstr(buf, "\"fullscreen\"")) {
sscanf(buf, " \"fullscreen\": %d", &fullscreen);
}
// Handle json workspace object
if (strstr(buf, "\"workspace\"")) {
in_workspace = 1;
}
if (in_workspace && strstr(buf, "\"id\"")) {
sscanf(buf, " \"id\": %d", &workspace);
in_workspace = 0;
}
}
pclose(fp);
if (fullscreen == -1 || !address[0] || workspace == -1)
return;
//printf("fullscreen=%d window=%s workspace=%d\n", fullscreen, address, workspace);
//fflush(stdout);
if (fullscreen == 1) {
tag_window(address, 1);
} else if (fullscreen == 0) {
tag_window(address, 0);
}
run_fullscreen_handler(address, fullscreen, workspace);
}
int main(void) {
const char *runtime = getenv("XDG_RUNTIME_DIR");
const char *sig = getenv("HYPRLAND_INSTANCE_SIGNATURE");
if (!runtime || !sig) {
fprintf(stderr, "Hyprland environment not detected\n");
return 1;
}
char sockpath[512];
int ret = snprintf(sockpath, sizeof(sockpath), "%s/hypr/%s/.socket2.sock",
runtime, sig);
if (ret < 0 || ret >= sizeof(sockpath)) {
fprintf(stderr, "Socket path too long\n");
return 1;
}
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) {
perror("socket");
return 1;
}
struct sockaddr_un addr = {0};
addr.sun_family = AF_UNIX;
strncpy(addr.sun_path, sockpath, sizeof(addr.sun_path) - 1);
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
perror("connect");
close(fd);
return 1;
}
// Normalize workspaces
char cmd[512];
int resetRet = snprintf(
cmd, sizeof(cmd),
"/home/user/.config/hypr/UserScripts/FullscreenHandler.sh %s %d %d > /dev/null 2>&1",
"discard", -1, -1);
if (resetRet < 0 || resetRet >= sizeof(cmd))
return 1;
system(cmd);
// Watch for changes
char buf[BUF_SIZE];
while (1) {
ssize_t n = read(fd, buf, sizeof(buf) - 1);
if (n < 0) {
if (errno == EINTR)
continue;
perror("read");
break;
}
if (n == 0)
break;
buf[n] = '\0';
if (strstr(buf, "fullscreen>>")) {
query_active_window();
}
}
close(fd);
return 0;
}
This program will be updated with each fullscreen change from Hyprland itself. It then passes the actual action off to FullscreenHandler.sh with the window address, fullscreen status, and workspace. It also tags the window in case we want to do any future actions, but you may omit this part without any loss of functionality.
The handler script is quite basic, and will update the actual settings.
#!/bin/bash
ADDR="$1"
FS="$2" # 0, 1, or 2
WS="$3" # 1-10, or -1 to reset all
# Config file to edit
HYPR_CONF="$HOME/.config/hypr/UserConfigs/UserDecorations.conf" # adjust if needed
# Normal vs Fullscreen configuration
NO_BORDER_GAP="gapsin:0, gapsout:0"
NORMAL_BORDER_GAP="gapsin:3, gapsout:2"
if [ "$WS" -eq -1 ]; then
for i in {1..10}; do
LINE_TO_INSERT="workspace = ${i}, $NORMAL_BORDER_GAP"
sed -i "/^#${i}:DYNAMIC WORKSPACE PLACEHOLDER \[ns\]/{n;s/.*/$LINE_TO_INSERT/;}" "$HYPR_CONF"
done
#echo "Reset all workspaces to normal padding"
exit 0
fi
# 0 = not fs, 1 = fs, 2 = exclusive fs
if [ "$FS" -eq 1 ]; then
LINE_TO_INSERT="workspace = ${WS}, $NO_BORDER_GAP"
else
LINE_TO_INSERT="workspace = ${WS}, $NORMAL_BORDER_GAP"
fi
# Use sed to replace the line after the workspace comment, in-place
sed -i "/^#${WS}:DYNAMIC WORKSPACE PLACEHOLDER \[ns\]/{n;s/.*/$LINE_TO_INSERT/;}" "$HYPR_CONF"
#echo "Updated workspace $WS with $( [ $FS -eq 1 ] && echo 'no-border padding' || echo 'normal padding')"
There’s probably a better way than using sed. Regardless, if you structure a section in your UserDecorations.conf as the script expects, it will work perfectly.
## EXAMPLE ##
# You CAN use a tag but it has a few ms delay and we can handle everything needed with fullscreen:1 match right now
#windowrule = bordercolor rgb(00ff00), tag:fullscreen_mode
windowrule = bordercolor rgb(ffc1e4), fullscreen:1
windowrule = rounding 0, fullscreen:1
# Can do bordersize 10 for a fun indicator around or something
windowrule = bordersize 0, fullscreen:1
# This section is replaced by SED from $UserScripts/FullscreenHandler.sh
#1:DYNAMIC WORKSPACE PLACEHOLDER [ns]
workspace = 1, gapsin:3, gapsout:2
#2:DYNAMIC WORKSPACE PLACEHOLDER [ns]
workspace = 2, gapsin:3, gapsout:2
#3:DYNAMIC WORKSPACE PLACEHOLDER [ns]
workspace = 3, gapsin:3, gapsout:2
#4:DYNAMIC WORKSPACE PLACEHOLDER [ns]
workspace = 4, gapsin:3, gapsout:2
#5:DYNAMIC WORKSPACE PLACEHOLDER [ns]
workspace = 5, gapsin:3, gapsout:2
#6:DYNAMIC WORKSPACE PLACEHOLDER [ns]
workspace = 6, gapsin:3, gapsout:2
#7:DYNAMIC WORKSPACE PLACEHOLDER [ns]
workspace = 7, gapsin:3, gapsout:2
#8:DYNAMIC WORKSPACE PLACEHOLDER [ns]
workspace = 8, gapsin:3, gapsout:2
#9:DYNAMIC WORKSPACE PLACEHOLDER [ns]
workspace = 9, gapsin:3, gapsout:2
#10:DYNAMIC WORKSPACE PLACEHOLDER [ns]
workspace = 10, gapsin:3, gapsout:2
Add a line in our Startup_Apps.conf: exec-once = /usr/local/bin/fullscreen-window-watcher, and voilà.
Regardless of bindings or how we achieved fullscreen, our app now has no gap or border. Additionally, tabbing to other workspaces works perfectly, and exiting the app in any way properly resets the settings. Sleek.