From 1922146fc566d99de5f74b627b42676a29bb5a4d Mon Sep 17 00:00:00 2001 From: Uyanide Date: Sat, 20 Sep 2025 20:40:19 +0200 Subject: [PATCH] mainly ghostty --- .../KroneCorylus/ghostty-shader-playground | 21 +++ ghostty/config | 7 +- ghostty/cursor-shaders/cursor-smear.glsl | 120 ++++++++++++++++++ hypr/hyprland/keybinds.conf | 3 +- waybar/style.css | 2 +- waybar/style.css.template | 2 +- 6 files changed, 148 insertions(+), 7 deletions(-) create mode 100644 .licenses/KroneCorylus/ghostty-shader-playground create mode 100644 ghostty/cursor-shaders/cursor-smear.glsl diff --git a/.licenses/KroneCorylus/ghostty-shader-playground b/.licenses/KroneCorylus/ghostty-shader-playground new file mode 100644 index 0000000..33bf1cb --- /dev/null +++ b/.licenses/KroneCorylus/ghostty-shader-playground @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Krone Corylus + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/ghostty/config b/ghostty/config index 637f5b5..c3941d1 100644 --- a/ghostty/config +++ b/ghostty/config @@ -1,4 +1,4 @@ -theme = catppuccin-mocha +theme = Catppuccin Mocha background-opacity = 0.75 background-blur = true @@ -16,7 +16,6 @@ font-family = Maple Mono NF CN font-size = 12 cursor-style = bar +adjust-cursor-thickness = 3 -# just for fun -# see https://github.com/hackr-sh/ghostty-shaders -# custom-shader = ~/.config/ghostty/shaders/glitchy.glsl +custom-shader = cursor-shaders/cursor-smear.glsl diff --git a/ghostty/cursor-shaders/cursor-smear.glsl b/ghostty/cursor-shaders/cursor-smear.glsl new file mode 100644 index 0000000..ca748e0 --- /dev/null +++ b/ghostty/cursor-shaders/cursor-smear.glsl @@ -0,0 +1,120 @@ +// https://github.com/KroneCorylus/ghostty-shader-playground/blob/main/shaders/cursor_smear.glsl + +float getSdfRectangle(in vec2 p, in vec2 xy, in vec2 b) +{ + vec2 d = abs(p - xy) - b; + return length(max(d, 0.0)) + min(max(d.x, d.y), 0.0); +} + +// Based on Inigo Quilez's 2D distance functions article: https://iquilezles.org/articles/distfunctions2d/ +// Potencially optimized by eliminating conditionals and loops to enhance performance and reduce branching + +float seg(in vec2 p, in vec2 a, in vec2 b, inout float s, float d) { + vec2 e = b - a; + vec2 w = p - a; + vec2 proj = a + e * clamp(dot(w, e) / dot(e, e), 0.0, 1.0); + float segd = dot(p - proj, p - proj); + d = min(d, segd); + + float c0 = step(0.0, p.y - a.y); + float c1 = 1.0 - step(0.0, p.y - b.y); + float c2 = 1.0 - step(0.0, e.x * w.y - e.y * w.x); + float allCond = c0 * c1 * c2; + float noneCond = (1.0 - c0) * (1.0 - c1) * (1.0 - c2); + float flip = mix(1.0, -1.0, step(0.5, allCond + noneCond)); + s *= flip; + return d; +} + +float getSdfParallelogram(in vec2 p, in vec2 v0, in vec2 v1, in vec2 v2, in vec2 v3) { + float s = 1.0; + float d = dot(p - v0, p - v0); + + d = seg(p, v0, v3, s, d); + d = seg(p, v1, v0, s, d); + d = seg(p, v2, v1, s, d); + d = seg(p, v3, v2, s, d); + + return s * sqrt(d); +} + +vec2 normalize(vec2 value, float isPosition) { + return (value * 2.0 - (iResolution.xy * isPosition)) / iResolution.y; +} + +float antialising(float distance) { + return 1. - smoothstep(0., normalize(vec2(2., 2.), 0.).x, distance); +} + +float determineStartVertexFactor(vec2 a, vec2 b) { + // Conditions using step + float condition1 = step(b.x, a.x) * step(a.y, b.y); // a.x < b.x && a.y > b.y + float condition2 = step(a.x, b.x) * step(b.y, a.y); // a.x > b.x && a.y < b.y + + // If neither condition is met, return 1 (else case) + return 1.0 - max(condition1, condition2); +} + +vec2 getRectangleCenter(vec4 rectangle) { + return vec2(rectangle.x + (rectangle.z / 2.), rectangle.y - (rectangle.w / 2.)); +} +float ease(float x) { + return pow(1.0 - x, 3.0); +} +vec4 saturate(vec4 color, float factor) { + float gray = dot(color, vec4(0.299, 0.587, 0.114, 0.)); // luminance + return mix(vec4(gray), color, factor); +} + +vec4 TRAIL_COLOR = iCurrentCursorColor; +const float OPACITY = 0.6; +const float DURATION = 0.3; //IN SECONDS + +void mainImage(out vec4 fragColor, in vec2 fragCoord) +{ + + #if !defined(WEB) + fragColor = texture(iChannel0, fragCoord.xy / iResolution.xy); + #endif + // Normalization for fragCoord to a space of -1 to 1; + vec2 vu = normalize(fragCoord, 1.); + vec2 offsetFactor = vec2(-.5, 0.5); + + // Normalization for cursor position and size; + // cursor xy has the postion in a space of -1 to 1; + // zw has the width and height + vec4 currentCursor = vec4(normalize(iCurrentCursor.xy, 1.), normalize(iCurrentCursor.zw, 0.)); + vec4 previousCursor = vec4(normalize(iPreviousCursor.xy, 1.), normalize(iPreviousCursor.zw, 0.)); + + // When drawing a parellelogram between cursors for the trail i need to determine where to start at the top-left or top-right vertex of the cursor + float vertexFactor = determineStartVertexFactor(currentCursor.xy, previousCursor.xy); + float invertedVertexFactor = 1.0 - vertexFactor; + + // Set every vertex of my parellogram + vec2 v0 = vec2(currentCursor.x + currentCursor.z * vertexFactor, currentCursor.y - currentCursor.w); + vec2 v1 = vec2(currentCursor.x + currentCursor.z * invertedVertexFactor, currentCursor.y); + vec2 v2 = vec2(previousCursor.x + currentCursor.z * invertedVertexFactor, previousCursor.y); + vec2 v3 = vec2(previousCursor.x + currentCursor.z * vertexFactor, previousCursor.y - previousCursor.w); + + float sdfCurrentCursor = getSdfRectangle(vu, currentCursor.xy - (currentCursor.zw * offsetFactor), currentCursor.zw * 0.5); + float sdfTrail = getSdfParallelogram(vu, v0, v1, v2, v3); + + float progress = clamp((iTime - iTimeCursorChange) / DURATION, 0.0, 1.0); + float easedProgress = ease(progress); + // Distance between cursors determine the total length of the parallelogram; + vec2 centerCC = getRectangleCenter(currentCursor); + vec2 centerCP = getRectangleCenter(previousCursor); + float lineLength = distance(centerCC, centerCP); + + vec4 newColor = vec4(fragColor); + + vec4 trail = TRAIL_COLOR; + trail = saturate(trail, 2.5); + // Draw trail + newColor = mix(newColor, trail, antialising(sdfTrail)); + // Draw current cursor + newColor = mix(newColor, trail, antialising(sdfCurrentCursor)); + newColor = mix(newColor, fragColor, step(sdfCurrentCursor, 0.)); + // newColor = mix(fragColor, newColor, OPACITY); + fragColor = mix(fragColor, newColor, step(sdfCurrentCursor, easedProgress * lineLength)); +} \ No newline at end of file diff --git a/hypr/hyprland/keybinds.conf b/hypr/hyprland/keybinds.conf index 27a179b..5712244 100755 --- a/hypr/hyprland/keybinds.conf +++ b/hypr/hyprland/keybinds.conf @@ -92,7 +92,7 @@ bind = Super+Shift, Left, movewindow, l # [hidden] bind = Super+Shift, Right, movewindow, r # [hidden] bind = Super+Shift, Up, movewindow, u # [hidden] bind = Super+Shift, Down, movewindow, d # [hidden] -# Window split ratio< +# Window split ratio #/# binde = Super, +/-,, # Window: split ratio +/- 0.1 binde = Super, udiaeresis, splitratio, -0.1 # [hidden] binde = Super, plus, splitratio, +0.1 # [hidden] @@ -104,6 +104,7 @@ bind = Super, F, fullscreen, 0 bind = Super, D, fullscreen, 1 bind = Super, J, togglesplit bind = Super, O, plugin:uyani:organize # https://github.com/Uyanide/hyprplug +bind = Super, H, layoutmsg, orientationcycle left right #! ##! Workspace navigation diff --git a/waybar/style.css b/waybar/style.css index ac8ddfe..7d2e6f4 100644 --- a/waybar/style.css +++ b/waybar/style.css @@ -24,7 +24,7 @@ /* The whole bar */ #waybar { - background: linear-gradient(to bottom, alpha(@base, 0.8), alpha(@base, 0.6), alpha(@base, 0.4), alpha(@base, 0)); + background: linear-gradient(to bottom, alpha(@base, 0.8), alpha(@base, 0)); /* background: transparent; */ color: @text; border-radius: 0px; diff --git a/waybar/style.css.template b/waybar/style.css.template index b97115d..aa91f8d 100644 --- a/waybar/style.css.template +++ b/waybar/style.css.template @@ -24,7 +24,7 @@ /* The whole bar */ #waybar { - background: linear-gradient(to bottom, alpha(@base, 0.8), alpha(@base, 0.6), alpha(@base, 0.4), alpha(@base, 0)); + background: linear-gradient(to bottom, alpha(@base, 0.8), alpha(@base, 0)); /* background: transparent; */ color: @text; border-radius: 0px;