diff --git a/linux-hidpi/conkyrc b/linux-hidpi/conkyrc new file mode 100644 index 0000000..d85400d --- /dev/null +++ b/linux-hidpi/conkyrc @@ -0,0 +1,164 @@ +conky.config = { + +------------------------------------- +-- Generic Settings +------------------------------------- +background=true, +update_interval=1, +double_buffer=true, +no_buffers=true, + +draw_shades=false, +draw_outline=false, +draw_borders=false, + + +------------------------------------- +-- Window Specifications +------------------------------------- +gap_x=800, +gap_y=550, + +minimum_height=250, +minimum_width=360, + +own_window=true, +own_window_type="normal", +own_window_transparent=true, +own_window_hints="undecorated,below,sticky,skip_taskbar,skip_pager", + +own_window_argb_visual=true, +own_window_argb_value=0, + + +------------------------------------- +-- Text Settings +------------------------------------- +use_xft=true, +xftalpha=1, +font="Droid Sans:size=10", +text_buffer_size=256, +override_utf8_locale=true, + + +------------------------------------- +-- Color Scheme +------------------------------------- +default_color="FFFFFF", + +color0="FFFFFF", -- hours +color1="FFFFFF", -- clock dots +color2="FFFFFF", -- minutes +color3="FFFFFF", -- week day +color4="FFFFFF", -- month day +color5="FFFFFF", -- month +color6="FFFFFF", -- current temp +color7="FFFFFF", -- min temp +color8="FFFFFF", -- max temp +color9="FFFFFF", -- current conditions + + +------------------------------------- +-- Icon Sources +------------------------------------- +template0="~/.jelly-conky/#fff__64", + + +------------------------------------- +-- API Key +------------------------------------- +template6="$OWM_KEY", + + +------------------------------------- +-- City ID +------------------------------------- +template7="1846918", + + +------------------------------------- +-- Temp Unit (default, metric, imperial) +------------------------------------- +template8="metric", + + +------------------------------------- +-- Locale (e.g. "es_ES.UTF-8") +-- Leave empty for default +------------------------------------- +template9="$LANG" + +} + + +------------------------------------- +------------------------------------- + + +conky.text = [[ +\ +\ +${execi 300 ~/.jelly-conky/get_weather ${template6} ${template7} ${template8} ${template9}}\ +\ +\ +\ +\ +${font Roboto:size=64}${color0}\ +${alignc}${time %H}\ +\ +\ +\ +\ +${font Roboto:thin:size=64}${color1}:\ +\ +\ +\ +\ +${font Roboto:thin:size=64}${color2}\ +${time %M}${font}${color} +\ +\ +\ +\ +${font Noto Sans CJK JP:light:size=16}${color3}\ +${voffset 12}${alignc}${execi 300 LANG=${template9} LC_TIME=${template9} date +"%A"}${color}, \ +\ +\ +\ +\ +${font Noto Sans CJK JP:light:size=16}${color5}\ +${alignc}${execi 300 LANG=${template9} LC_TIME=${template9} date +"%B"}${color} \ +\ +\ +\ +\ +${font Noto Sans CJK JP:size=16}${color4}\ +${alignc}${execi 300 LANG=${template9} LC_TIME=${template9} date +"%d"}${color}日 +\ +\ +\ +\ +${font Roboto:light:size=24}${color6}\ +${goto 70}${voffset 18}\ +${execi 300 jq ".main.temp" ~/.cache/jelly-conky/weather.json | awk '{print int($1+0.5)}' # round num}°${font}${color} +\ +\ +\ +\ +${font Roboto:light:size=12}\ +${goto 70}${voffset 5}\ +${color7}${execi 300 ~/.jelly-conky/parse_weather 'avg' '.main.temp_min' '0'}° ${color}| \ +${color8}${execi 300 ~/.jelly-conky/parse_weather 'avg' '.main.temp_max' '0'}°${font}${color} +\ +\ +\ +\ +${font Noto Sans CJK JP:light:size=12}${color9}\ +${goto 70}${voffset 5}\ +${execi 300 jq -r ".weather[0].description" ~/.cache/jelly-conky/weather.json}${font}${color} +\ +\ +\ +\ +${execi 300 cp -f ${template0}/$(jq .weather[0].id ~/.cache/jelly-conky/weather.json).png ~/.cache/jelly-conky/current.png}${image ~/.cache/jelly-conky/current.png -p 236,270 -s 128x128}\ +]] diff --git a/linux-hidpi/dconf/user b/linux-hidpi/dconf/user index ecead0e..0e06331 100644 Binary files a/linux-hidpi/dconf/user and b/linux-hidpi/dconf/user differ diff --git a/linux-hidpi/glava/bars.glsl b/linux-hidpi/glava/bars.glsl new file mode 100755 index 0000000..6e6a7b0 --- /dev/null +++ b/linux-hidpi/glava/bars.glsl @@ -0,0 +1,33 @@ + +/* Center line thickness (pixels) */ +#define C_LINE 1 +/* Width (in pixels) of each bar */ +#define BAR_WIDTH 4 +/* Width (in pixels) of each bar gap */ +#define BAR_GAP 2 +/* Outline color */ +#define BAR_OUTLINE #262626 +/* Outline width (in pixels, set to 0 to disable outline drawing) */ +#define BAR_OUTLINE_WIDTH 0 +/* Amplify magnitude of the results each bar displays */ +#define AMPLIFY 300 +/* Whether the current settings use the alpha channel; + enabling this is required for alpha to function + correctly on X11 with `"native"` transparency. */ +#define USE_ALPHA 0 +/* How strong the gradient changes */ +#define GRADIENT_POWER 60 +/* Bar color changes with height */ +#define GRADIENT (d / GRADIENT_POWER + 1) +/* Bar color */ +#define COLOR (#3366b2 * GRADIENT) +/* Direction that the bars are facing, 0 for inward, 1 for outward */ +#define DIRECTION 0 +/* Whether to switch left/right audio buffers */ +#define INVERT 0 +/* Whether to flip the output vertically */ +#define FLIP 0 +/* Whether to mirror output along `Y = X`, causing output to render on the left side of the window */ +/* Use with `FLIP 1` to render on the right side */ +#define MIRROR_YX 0 + diff --git a/linux-hidpi/glava/bars/1.frag b/linux-hidpi/glava/bars/1.frag new file mode 100644 index 0000000..97d719b --- /dev/null +++ b/linux-hidpi/glava/bars/1.frag @@ -0,0 +1,114 @@ +in vec4 gl_FragCoord; + +#request uniform "screen" screen +uniform ivec2 screen; + +#request uniform "audio_sz" audio_sz +uniform int audio_sz; + +#include "@bars.glsl" +#include ":bars.glsl" + +#request uniform "audio_l" audio_l +#request transform audio_l "window" +#request transform audio_l "fft" +#request transform audio_l "gravity" +#request transform audio_l "avg" +uniform sampler1D audio_l; + +#request uniform "audio_r" audio_r +#request transform audio_r "window" +#request transform audio_r "fft" +#request transform audio_r "gravity" +#request transform audio_r "avg" +uniform sampler1D audio_r; + +out vec4 fragment; +#include ":util/smooth.glsl" + +#define TWOPI 6.28318530718 +#define PI 3.14159265359 + +void main() { + + #if MIRROR_YX == 0 + #define AREA_WIDTH screen.x + #define AREA_HEIGHT screen.y + #define AREA_X gl_FragCoord.x + #define AREA_Y gl_FragCoord.y + #else + #define AREA_WIDTH screen.y + #define AREA_HEIGHT screen.x + #define AREA_X gl_FragCoord.y + #define AREA_Y gl_FragCoord.x + #endif + + float dx = (AREA_X - (AREA_WIDTH / 2)); + #if FLIP == 0 + float d = AREA_Y; + #else + float d = AREA_HEIGHT - AREA_Y; + #endif + float section = BAR_WIDTH + BAR_GAP; /* size of section for each bar (including gap) */ + float center = section / 2.0F; /* half section, distance to center */ + float m = abs(mod(dx, section)); /* position in section */ + float md = m - center; /* position in section from center line */ + float nbars = floor((AREA_WIDTH * 0.5F) / section) * 2; + float p, s; + if (md < ceil(float(BAR_WIDTH) / 2) && md >= -floor(float(BAR_WIDTH) / 2)) { /* if not in gap */ + s = dx / section; + p = (sign(s) == 1.0 ? ceil(s) : floor(s)) / float(nbars / 2); /* position, (-1.0F, 1.0F)) */ + p += sign(p) * ((0.5F + center) / AREA_WIDTH); /* index center of bar position */ + /* Apply smooth function and index texture */ + #define smooth_f(tex, p) smooth_audio(tex, audio_sz, p) + float v; + /* ignore out of bounds values */ + if (p > 1.0F || p < -1.0F) { + fragment = vec4(0, 0, 0, 0); + return; + } + /* handle user options and store result of indexing in 'v' */ + if (p > 0.0F) { + #if DIRECTION == 1 + p = 1.0F - p; + #endif + #if INVERT > 0 + v = smooth_f(audio_l, p); + #else + v = smooth_f(audio_r, p); + #endif + } else { + p = abs(p); + #if DIRECTION == 1 + p = 1.0F - p; + #endif + #if INVERT > 0 + v = smooth_f(audio_r, p); + #else + v = smooth_f(audio_l, p); + #endif + } + #undef smooth_f + + v *= AMPLIFY; /* amplify result */ + if (d < v - BAR_OUTLINE_WIDTH) { /* if within range of the reported frequency, draw */ + #if BAR_OUTLINE_WIDTH > 0 + if (md < (BAR_WIDTH / 2) - BAR_OUTLINE_WIDTH) + fragment = COLOR; + else + fragment = BAR_OUTLINE; + #else + fragment = COLOR; + #endif + return; + } + + #if BAR_OUTLINE_WIDTH > 0 + if (d <= v) { + fragment = BAR_OUTLINE; + return; + } + #endif + } + fragment = vec4(0, 0, 0, 0); /* default frag color */ +} diff --git a/linux-hidpi/glava/circle.glsl b/linux-hidpi/glava/circle.glsl new file mode 100755 index 0000000..83b8ad3 --- /dev/null +++ b/linux-hidpi/glava/circle.glsl @@ -0,0 +1,24 @@ +/* center radius (pixels) */ +#define C_RADIUS 128 +/* center line thickness (pixels) */ +#define C_LINE 1.5 +/* outline color */ +#define OUTLINE #333333 +/* Amplify magnitude of the results each bar displays */ +#define AMPLIFY 150 +/* Angle (in radians) for how much to rotate the visualizer */ +#define ROTATE (PI / 2) +/* Whether to switch left/right audio buffers */ +#define INVERT 0 +/* Whether to fill in the space between the line and inner circle */ +#define C_FILL 0 +/* Whether to apply a post-processing image smoothing effect + 1 to enable, 0 to disable. Only works with `xroot` transparency, + and improves performance if disabled. */ +#define C_SMOOTH 1 + +/* Gravity step, overrude frin `smooth_parameters.glsl` */ +#request setgravitystep 6.0 + +/* Smoothing factor, override from `smooth_parameters.glsl` */ +#request setsmoothfactor 0.01 diff --git a/linux-hidpi/glava/circle/1.frag b/linux-hidpi/glava/circle/1.frag new file mode 100644 index 0000000..6caccd1 --- /dev/null +++ b/linux-hidpi/glava/circle/1.frag @@ -0,0 +1,84 @@ +layout(pixel_center_integer) in vec4 gl_FragCoord; + +#request uniform "screen" screen +uniform ivec2 screen; + +#request uniform "audio_sz" audio_sz +uniform int audio_sz; + +#include ":util/smooth.glsl" +#include "@circle.glsl" +#include ":circle.glsl" + +#request uniform "audio_l" audio_l +#request transform audio_l "window" +#request transform audio_l "fft" +#request transform audio_l "gravity" +#request transform audio_l "avg" +uniform sampler1D audio_l; + +#request uniform "audio_r" audio_r +#request transform audio_r "window" +#request transform audio_r "fft" +#request transform audio_r "gravity" +#request transform audio_r "avg" +uniform sampler1D audio_r; + +out vec4 fragment; + +#define TWOPI 6.28318530718 +#define PI 3.14159265359 + +/* This shader is based on radial.glsl, refer to it for more commentary */ + +float apply_smooth(float theta) { + float idx = theta + ROTATE; + float dir = mod(abs(idx), TWOPI); + if (dir > PI) + idx = -sign(idx) * (TWOPI - dir); + if (INVERT > 0) + idx = -idx; + + float pos = abs(idx) / (PI + 0.001F); + #define smooth_f(tex) smooth_audio(tex, audio_sz, pos) + float v; + if (idx > 0) v = smooth_f(audio_l); + else v = smooth_f(audio_r); + v *= AMPLIFY; + #undef smooth_f + return v; +} + +void main() { + fragment = vec4(0, 0, 0, 0); + float + dx = gl_FragCoord.x - (screen.x / 2), + dy = gl_FragCoord.y - (screen.y / 2); + float theta = atan(dy, dx); + float d = sqrt((dx * dx) + (dy * dy)); + float adv = (1.0F / d) * (C_LINE * 0.5); + float + adj0 = theta + adv, + adj1 = theta - adv; + d -= C_RADIUS; + if (d >= -(float(C_LINE) / 2.0F)) { + float v = apply_smooth(theta); + + adj0 = apply_smooth(adj0) - v; + adj1 = apply_smooth(adj1) - v; + + float + dmax = max(adj0, adj1), + dmin = min(adj0, adj1); + + d -= v; + #if C_FILL > 0 + #define BOUNDS (d < (float(C_LINE) / 2.0F)) + #else + #define BOUNDS (d > -(float(C_LINE) / 2.0F) && d < (float(C_LINE) / 2.0F)) || (d <= dmax && d >= dmin) + #endif + if (BOUNDS) { + fragment = OUTLINE; + } + } +} diff --git a/linux-hidpi/glava/circle/2.frag b/linux-hidpi/glava/circle/2.frag new file mode 100644 index 0000000..d38f6ad --- /dev/null +++ b/linux-hidpi/glava/circle/2.frag @@ -0,0 +1,33 @@ + +in vec4 gl_FragCoord; + +#request uniform "prev" tex +uniform sampler2D tex; /* screen texture */ + +out vec4 fragment; /* output */ + +#include "@circle.glsl" +#include ":circle.glsl" + +void main() { + fragment = texelFetch(tex, ivec2(gl_FragCoord.x, gl_FragCoord.y), 0); + #if C_SMOOTH > 0 + #if USE_ALPHA + vec4 + a0 = texelFetch(tex, ivec2((gl_FragCoord.x + 1), (gl_FragCoord.y + 0)), 0), + a1 = texelFetch(tex, ivec2((gl_FragCoord.x + 1), (gl_FragCoord.y + 1)), 0), + a2 = texelFetch(tex, ivec2((gl_FragCoord.x + 0), (gl_FragCoord.y + 1)), 0), + a3 = texelFetch(tex, ivec2((gl_FragCoord.x + 1), (gl_FragCoord.y + 0)), 0), + + a4 = texelFetch(tex, ivec2((gl_FragCoord.x - 1), (gl_FragCoord.y - 0)), 0), + a5 = texelFetch(tex, ivec2((gl_FragCoord.x - 1), (gl_FragCoord.y - 1)), 0), + a6 = texelFetch(tex, ivec2((gl_FragCoord.x - 0), (gl_FragCoord.y - 1)), 0), + a7 = texelFetch(tex, ivec2((gl_FragCoord.x - 1), (gl_FragCoord.y - 0)), 0); + + vec4 avg = (a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7) / 8.0; + if (fragment.a == 0) { + fragment = avg; + } + #endif + #endif +} diff --git a/linux-hidpi/glava/circle/3.frag b/linux-hidpi/glava/circle/3.frag new file mode 100644 index 0000000..66f7cd9 --- /dev/null +++ b/linux-hidpi/glava/circle/3.frag @@ -0,0 +1 @@ +#include ":util/premultiply.frag" diff --git a/linux-hidpi/glava/env_KWin.glsl b/linux-hidpi/glava/env_KWin.glsl new file mode 100755 index 0000000..aa168ba --- /dev/null +++ b/linux-hidpi/glava/env_KWin.glsl @@ -0,0 +1,8 @@ +#request setdecorated false +#request setxwintype "normal" +#request addxwinstate "below" +#request addxwinstate "skip_taskbar" +#request addxwinstate "skip_pager" +#request addxwinstate "pinned" +#request setclickthrough true + diff --git a/linux-hidpi/glava/env_Openbox.glsl b/linux-hidpi/glava/env_Openbox.glsl new file mode 100755 index 0000000..c95c616 --- /dev/null +++ b/linux-hidpi/glava/env_Openbox.glsl @@ -0,0 +1,2 @@ +#request setxwintype "desktop" +#request addxwinstate "pinned" diff --git a/linux-hidpi/glava/env_Xfwm4.glsl b/linux-hidpi/glava/env_Xfwm4.glsl new file mode 100755 index 0000000..1c20359 --- /dev/null +++ b/linux-hidpi/glava/env_Xfwm4.glsl @@ -0,0 +1,3 @@ +#request setxwintype "desktop" +#request addxwinstate "pinned" +#request addxwinstate "below" diff --git a/linux-hidpi/glava/env_awesome.glsl b/linux-hidpi/glava/env_awesome.glsl new file mode 100755 index 0000000..7f2bba3 --- /dev/null +++ b/linux-hidpi/glava/env_awesome.glsl @@ -0,0 +1 @@ +#request setxwintype "!-" diff --git a/linux-hidpi/glava/env_default.glsl b/linux-hidpi/glava/env_default.glsl new file mode 100755 index 0000000..90336cc --- /dev/null +++ b/linux-hidpi/glava/env_default.glsl @@ -0,0 +1 @@ +#request setxwintype "desktop" diff --git a/linux-hidpi/glava/env_i3.glsl b/linux-hidpi/glava/env_i3.glsl new file mode 100755 index 0000000..7f2bba3 --- /dev/null +++ b/linux-hidpi/glava/env_i3.glsl @@ -0,0 +1 @@ +#request setxwintype "!-" diff --git a/linux-hidpi/glava/graph.glsl b/linux-hidpi/glava/graph.glsl new file mode 100755 index 0000000..546d8d4 --- /dev/null +++ b/linux-hidpi/glava/graph.glsl @@ -0,0 +1,31 @@ + +/* Vertical scale, larger values will amplify output */ +#define VSCALE 300 +/* Rendering direction, either -1 (outwards) or 1 (inwards). */ +#define DIRECTION 1 + +/* Color gradient scale, (optionally) used in `COLOR` macro */ +#define GRADIENT_SCALE 75 +/* Color definition. By default this is a gradient formed by mixing two colors. + `pos` represents the pixel position relative to the visualizer baseline. */ +#define COLOR mix(#802A2A, #4F4F92, clamp(pos / GRADIENT_SCALE, 0, 1)) +/* 1 to draw outline, 0 to disable */ +#define DRAW_OUTLINE 0 +/* 1 to draw edge highlight, 0 to disable */ +#define DRAW_HIGHLIGHT 1 +/* Whether to anti-alias the border of the graph, creating a smoother curve. + This may have a small impact on performance. + Note: requires `xroot` or `none` opacity to be set */ +#define ANTI_ALIAS 0 +/* outline color */ +#define OUTLINE #262626 +/* 1 to join the two channels together in the middle, 0 to clamp both down to zero */ +#define JOIN_CHANNELS 0 +/* 1 to invert (vertically), 0 otherwise */ +#define INVERT 0 + +/* Gravity step, overrude from `smooth_parameters.glsl` */ +#request setgravitystep 2.4 + +/* Smoothing factor, override from `smooth_parameters.glsl` */ +#request setsmoothfactor 0.015 diff --git a/linux-hidpi/glava/graph/1.frag b/linux-hidpi/glava/graph/1.frag new file mode 100644 index 0000000..9b82d05 --- /dev/null +++ b/linux-hidpi/glava/graph/1.frag @@ -0,0 +1,132 @@ + +layout(pixel_center_integer) in vec4 gl_FragCoord; + +#request uniform "screen" screen +uniform ivec2 screen; /* screen dimensions */ + +#request uniform "audio_sz" audio_sz +uniform int audio_sz; + +/* When we transform our audio, we need to go through the following steps: + + transform -> "window" + First, apply a window function to taper off the ends of the spectrum, helping + avoid artifacts in the FFT output. + + transform -> "fft" + Apply the Fast Fourier Transform algorithm to separate raw audio data (waves) + into their respective spectrums. + + transform -> "fft" + As part of the FFT process, we return spectrum magnitude on a log(n) scale, + as this is how the (decibel) dB scale functions. + + transform -> "gravity" + To help make our data more pleasing to look at, we apply our data received over + time to a buffer, taking the max of either the existing value in the buffer or + the data from the input. We then reduce the data by the 'gravity step', and + return the storage buffer. + + This makes frequent and abrupt changes in frequency less distracting, and keeps + short frequency responses on the screen longer. + + transform -> "avg" + As a final step, we take the average of several data frames (specified by + 'setavgframes') and return the result to further help smooth the resulting + animation. In order to mitigate abrupt changes to the average, the values + at each end of the average buffer can be weighted less with a window function + (the same window function used at the start of this step!). It can be disabled + with 'setavgwindow'. +*/ + +#include ":util/smooth.glsl" +#include "@graph.glsl" +#include ":graph.glsl" + +#request uniform "audio_l" audio_l +#request transform audio_l "window" +#request transform audio_l "fft" +#request transform audio_l "gravity" +#request transform audio_l "avg" +uniform sampler1D audio_l; + +#request uniform "audio_r" audio_r +#request transform audio_r "window" +#request transform audio_r "fft" +#request transform audio_r "gravity" +#request transform audio_r "avg" +uniform sampler1D audio_r; + +out vec4 fragment; + +/* distance from center */ +#define CDIST (abs((screen.x / 2) - gl_FragCoord.x) / screen.x) +/* distance from sides (far) */ +#define FDIST (min(gl_FragCoord.x, screen.x - gl_FragCoord.x) / screen.x) + +#if DIRECTION < 0 +#define LEFT_IDX (gl_FragCoord.x) +#define RIGHT_IDX (-gl_FragCoord.x + screen.x) +/* distance from base frequencies */ +#define BDIST FDIST +/* distance from high frequencies */ +#define HDIST CDIST +#else +#define LEFT_IDX (half_w - gl_FragCoord.x) +#define RIGHT_IDX (gl_FragCoord.x - half_w) +#define BDIST CDIST +#define HDIST FDIST +#endif + +#define TWOPI 6.28318530718 + +float half_w; +float middle; +highp float pixel = 1.0F / float(screen.x); + +float get_line_height(in sampler1D tex, float idx) { + float s = smooth_audio_adj(tex, audio_sz, idx / half_w, pixel); + /* scale the data upwards so we can see it */ + s *= VSCALE; + /* clamp far ends of the screen down to make the ends of the graph smoother */ + + float fact = clamp((abs((screen.x / 2) - gl_FragCoord.x) / screen.x) * 48, 0.0F, 1.0F); + #if JOIN_CHANNELS > 0 + fact = -2 * pow(fact, 3) + 3 * pow(fact, 2); /* To avoid spikes */ + s = fact * s + (1 - fact) * middle; + #else + s *= fact; + #endif + + s *= clamp((min(gl_FragCoord.x, screen.x - gl_FragCoord.x) / screen.x) * 48, 0.0F, 1.0F); + + return s; +} + +void render_side(in sampler1D tex, float idx) { + float s = get_line_height(tex, idx); + + /* and finally set fragment color if we are in range */ + #if INVERT > 0 + float pos = float(screen.y) - gl_FragCoord.y; + #else + float pos = gl_FragCoord.y; + #endif + if (pos + 1.5 <= s) { + fragment = COLOR; + } else { + fragment = vec4(0, 0, 0, 0); + } +} + +void main() { + half_w = (screen.x / 2); + + middle = VSCALE * (smooth_audio_adj(audio_l, audio_sz, 1, pixel) + smooth_audio_adj(audio_r, audio_sz, 0, pixel)) / 2; + + if (gl_FragCoord.x < half_w) { + render_side(audio_l, LEFT_IDX); + } else { + render_side(audio_r, RIGHT_IDX); + } +} diff --git a/linux-hidpi/glava/graph/2.frag b/linux-hidpi/glava/graph/2.frag new file mode 100644 index 0000000..ff18445 --- /dev/null +++ b/linux-hidpi/glava/graph/2.frag @@ -0,0 +1,44 @@ + +in vec4 gl_FragCoord; + +#request uniform "prev" tex +uniform sampler2D tex; /* screen texture */ + +out vec4 fragment; /* output */ + +#include "@graph.glsl" +#include ":graph.glsl" + +#if DRAW_OUTLINE == 0 && DRAW_HIGHLIGHT == 0 +#error __disablestage +#endif + +void main() { + fragment = texelFetch(tex, ivec2(gl_FragCoord.x, gl_FragCoord.y), 0); + + vec4 + a0 = texelFetch(tex, ivec2((gl_FragCoord.x + 1), (gl_FragCoord.y + 0)), 0), + a1 = texelFetch(tex, ivec2((gl_FragCoord.x + 1), (gl_FragCoord.y + 1)), 0), + a2 = texelFetch(tex, ivec2((gl_FragCoord.x + 0), (gl_FragCoord.y + 1)), 0), + a3 = texelFetch(tex, ivec2((gl_FragCoord.x + 1), (gl_FragCoord.y + 0)), 0), + + a4 = texelFetch(tex, ivec2((gl_FragCoord.x - 1), (gl_FragCoord.y - 0)), 0), + a5 = texelFetch(tex, ivec2((gl_FragCoord.x - 1), (gl_FragCoord.y - 1)), 0), + a6 = texelFetch(tex, ivec2((gl_FragCoord.x - 0), (gl_FragCoord.y - 1)), 0), + a7 = texelFetch(tex, ivec2((gl_FragCoord.x - 1), (gl_FragCoord.y - 0)), 0); + + vec4 avg = (a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7) / 8.0; + if (avg.a > 0){ + if (fragment.a <= 0) { + /* outline */ + #if DRAW_OUTLINE > 0 + fragment = OUTLINE; + #endif + } else if (avg.a < 1) { + /* creates a highlight along the edge of the spectrum */ + #if DRAW_HIGHLIGHT > 0 + fragment.rgb *= avg.a * 2; + #endif + } + } +} diff --git a/linux-hidpi/glava/graph/3.frag b/linux-hidpi/glava/graph/3.frag new file mode 100644 index 0000000..2263139 --- /dev/null +++ b/linux-hidpi/glava/graph/3.frag @@ -0,0 +1,104 @@ + +in vec4 gl_FragCoord; + +#request uniform "screen" screen +uniform ivec2 screen; /* screen dimensions */ + +#request uniform "prev" tex +uniform sampler2D tex; /* screen texture */ + +out vec4 fragment; /* output */ + +#include "@graph.glsl" +#include ":graph.glsl" + +#if ANTI_ALIAS == 0 +#error __disablestage +#endif + +/* Moves toward the border of the graph, gives the + y coordinate of the last colored pixel */ +float get_col_height_up(float x, float oy) { + float y = oy; + #if INVERT > 0 + while (y >= 0) { + #else + while (y < screen.y) { + #endif + vec4 f = texelFetch(tex, ivec2(x, y), 0); + if (f.a <= 0) { + #if INVERT > 0 + y += 1; + #else + y -= 1; + #endif + break; + } + #if INVERT > 0 + y -= 1; + #else + y += 1; + #endif + } + + return y; +} + +/* Moves toward the base of the graph, gives the + y coordinate of the first colored pixel */ +float get_col_height_down(float x, float oy) { + float y = oy; + #if INVERT > 0 + while (y < screen.y) { + #else + while (y >= 0) { + #endif + vec4 f = texelFetch(tex, ivec2(x, y), 0); + if (f.a > 0) { + break; + } + #if INVERT > 0 + y += 1; + #else + y -= 1; + #endif + } + + return y; +} + +void main() { + fragment = texelFetch(tex, ivec2(gl_FragCoord.x, gl_FragCoord.y), 0); + + #if ANTI_ALIAS > 0 + + if (fragment.a <= 0) { + bool left_done = false; + float h2; + float a_fact = 0; + + if (texelFetch(tex, ivec2(gl_FragCoord.x - 1, gl_FragCoord.y), 0).a > 0) { + float h1 = get_col_height_up(gl_FragCoord.x - 1, gl_FragCoord.y); + h2 = get_col_height_down(gl_FragCoord.x, gl_FragCoord.y); + fragment = texelFetch(tex, ivec2(gl_FragCoord.x, h2), 0); + + a_fact = clamp(abs((h1 - gl_FragCoord.y) / (h2 - h1)), 0.0, 1.0); + + left_done = true; + } + if (texelFetch(tex, ivec2(gl_FragCoord.x + 1, gl_FragCoord.y), 0).a > 0) { + if (!left_done) { + h2 = get_col_height_down(gl_FragCoord.x, gl_FragCoord.y); + fragment = texelFetch(tex, ivec2(gl_FragCoord.x, h2), 0); + } + float h3 = get_col_height_up(gl_FragCoord.x + 1, gl_FragCoord.y); + + a_fact = max(a_fact, clamp(abs((h3 - gl_FragCoord.y) / (h2 - h3)), 0.0, 1.0)); + } + + fragment.a *= a_fact; + + } + + #endif +} diff --git a/linux-hidpi/glava/radial.glsl b/linux-hidpi/glava/radial.glsl new file mode 100755 index 0000000..37f2635 --- /dev/null +++ b/linux-hidpi/glava/radial.glsl @@ -0,0 +1,39 @@ + +/* center radius (pixels) */ +#define C_RADIUS 720 +/* center line thickness (pixels) */ +#define C_LINE 0 +/* outline color */ +#define OUTLINE #ffffff +/* number of bars (use even values for best results) */ +#define NBARS 360 +/* width (in pixels) of each bar*/ +#define BAR_WIDTH 8 +/* outline color */ +#define BAR_OUTLINE OUTLINE +/* outline width (in pixels, set to 0 to disable outline drawing) */ +#define BAR_OUTLINE_WIDTH 0 +/* Amplify magnitude of the results each bar displays */ +#define AMPLIFY 200 +/* Bar color */ +#define COLOR #ffffff +/* Angle (in radians) for how much to rotate the visualizer */ +#define ROTATE (PI / 2) +/* Whether to switch left/right audio buffers */ +#define INVERT 0 +/* Aliasing factors. Higher values mean more defined and jagged lines. + Note: aliasing does not have a notable impact on performance, but requires + `xroot` transparency to be enabled since it relies on alpha blending with + the background. */ +#define BAR_ALIAS_FACTOR 1.2 +#define C_ALIAS_FACTOR 1.8 +/* Offset (Y) of the visualization */ +#define CENTER_OFFSET_Y 0 +/* Offset (X) of the visualization */ +#define CENTER_OFFSET_X 0 + +/* Gravity step, override from `smooth_parameters.glsl` */ +#request setgravitystep 5.0 + +/* Smoothing factor, override from `smooth_parameters.glsl` */ +#request setsmoothfactor 0.02 diff --git a/linux-hidpi/glava/radial/1.frag b/linux-hidpi/glava/radial/1.frag new file mode 100644 index 0000000..3951a37 --- /dev/null +++ b/linux-hidpi/glava/radial/1.frag @@ -0,0 +1,115 @@ +in vec4 gl_FragCoord; + +#request uniform "screen" screen +uniform ivec2 screen; + +#request uniform "audio_sz" audio_sz +uniform int audio_sz; + +#include ":util/smooth.glsl" +#include "@radial.glsl" +#include ":radial.glsl" + +#request uniform "audio_l" audio_l +#request transform audio_l "window" +#request transform audio_l "fft" +#request transform audio_l "gravity" +#request transform audio_l "avg" +uniform sampler1D audio_l; + +#request uniform "audio_r" audio_r +#request transform audio_r "window" +#request transform audio_r "fft" +#request transform audio_r "gravity" +#request transform audio_r "avg" +uniform sampler1D audio_r; + +out vec4 fragment; + +#define TWOPI 6.28318530718 +#define PI 3.14159265359 + +void main() { + + #if USE_ALPHA > 0 + #define APPLY_FRAG(f, c) f = vec4(f.rgb * f.a + c.rgb * (1 - clamp(f.a, 0, 1)), max(c.a, f.a)) + fragment = #00000000; + #else + #define APPLY_FRAG(f, c) f = c + #endif + + /* To handle jagged edges, we alias in the shader by using alpha layer blending. + Alpha layer blending is only applied when `xroot` transparency is enabled. */ + + float /* translate (x, y) to use (0, 0) as the center of the screen */ + dx = gl_FragCoord.x - (screen.x / 2) + CENTER_OFFSET_X, + dy = gl_FragCoord.y - (screen.y / 2) + CENTER_OFFSET_Y; + float theta = atan(dy, dx); /* fragment angle with the center of the screen as the origin */ + float d = sqrt((dx * dx) + (dy * dy)); /* distance */ + if (d > C_RADIUS - (float(C_LINE) / 2.0F) && d < C_RADIUS + (float(C_LINE) / 2.0F)) { + APPLY_FRAG(fragment, OUTLINE); + #if USE_ALPHA > 0 + fragment.a *= clamp(((C_LINE / 2) - abs(C_RADIUS - d)) * C_ALIAS_FACTOR, 0, 1); + #else + return; /* return immediately if there is no alpha blending available */ + #endif + } + if (d > C_RADIUS) { + const float section = (TWOPI / NBARS); /* range (radians) for each bar */ + const float center = ((TWOPI / NBARS) / 2.0F); /* center line angle */ + float m = mod(theta, section); /* position in section (radians) */ + float ym = d * sin(center - m); /* distance from center line (cartesian coords) */ + if (abs(ym) < BAR_WIDTH / 2) { /* if within width, draw audio */ + float idx = theta + ROTATE; /* position (radians) in texture */ + float dir = mod(abs(idx), TWOPI); /* absolute position, [0, 2pi) */ + if (dir > PI) + idx = -sign(idx) * (TWOPI - dir); /* Re-correct position values to [-pi, pi) */ + if (INVERT > 0) + idx = -idx; /* Invert if needed */ + float pos = int(abs(idx) / section) / float(NBARS / 2); /* bar position, [0, 1) */ + #define smooth_f(tex) smooth_audio(tex, audio_sz, pos) /* smooth function format */ + float v; + if (idx > 0) v = smooth_f(audio_l); /* left buffer */ + else v = smooth_f(audio_r); /* right buffer */ + v *= AMPLIFY; /* amplify */ + #undef smooth_f + /* offset to fragment distance from inner circle */ + #if USE_ALPHA > 0 + #define ALIAS_FACTOR (((BAR_WIDTH / 2) - abs(ym)) * BAR_ALIAS_FACTOR) + d -= C_RADIUS; /* start bar overlapping the inner circle for blending */ + #else + #define ALIAS_FACTOR 1 + d -= C_RADIUS + (float(C_LINE) / 2.0F); /* start bar after circle */ + #endif + if (d <= v - BAR_OUTLINE_WIDTH) { + vec4 r; + #if BAR_OUTLINE_WIDTH > 0 + if (abs(ym) < (BAR_WIDTH / 2) - BAR_OUTLINE_WIDTH) + r = COLOR; + else + r = BAR_OUTLINE; + #else + r = COLOR; + #endif + #if USE_ALPHA > 0 + r.a *= ALIAS_FACTOR; + #endif + APPLY_FRAG(fragment, r); + return; + } + #if BAR_OUTLINE_WIDTH > 0 + if (d <= v) { + #if USE_ALPHA > 0 + vec4 r = BAR_OUTLINE; + r.a *= ALIAS_FACTOR; + APPLY_FRAG(fragment, r); + #else + APPLY_FRAG(fragment, BAR_OUTLINE); + #endif + return; + } + #endif + } + } + fragment = APPLY_FRAG(fragment, vec4(0, 0, 0, 0)); /* default frag color */ +} diff --git a/linux-hidpi/glava/radial/2.frag b/linux-hidpi/glava/radial/2.frag new file mode 100644 index 0000000..66f7cd9 --- /dev/null +++ b/linux-hidpi/glava/radial/2.frag @@ -0,0 +1 @@ +#include ":util/premultiply.frag" diff --git a/linux-hidpi/glava/rc.glsl b/linux-hidpi/glava/rc.glsl new file mode 100755 index 0000000..1135d94 --- /dev/null +++ b/linux-hidpi/glava/rc.glsl @@ -0,0 +1,227 @@ + +/* The module to use. A module is a set of shaders used to produce + the visualizer. The structure for a module is the following: + + module_name [directory] + 1.frag [file: fragment shader], + 2.frag [file: fragment shader], + ... + + Shaders are loaded in numerical order, starting at '1.frag', + continuing indefinitely. The results of each shader (except + for the final pass) is given to the next shader in the list + as a 2D sampler. + + See documentation for more details. */ +#request mod radial + +/* Window hints */ +#request setfloating false +#request setdecorated true +#request setfocused false +#request setmaximized false + +/* Set window background opacity mode. Possible values are: + + "native" - True transparency provided by the compositor. Can + reduce performance on some systems, depending on + the compositor used. + + "xroot" - Maintain a copy of the root window's pixmap + (usually the desktop background) to provide a + pseudo-transparent effect. Useful when no compositor + is available or native transparency isn't nessecary. + Has very little performance impact. + + "none" - Disable window opacity completely. */ +#request setopacity "native" + +/* Whether to mirror left and right audio input channels from PulseAudio.*/ +#request setmirror false + +/* OpenGL context and GLSL shader versions, do not change unless + you *absolutely* know what you are doing. */ +#request setversion 3 3 +#request setshaderversion 330 + +/* Window title */ +#request settitle "GLava" + +/* Window geometry (x, y, width, height) */ +#request setgeometry 0 0 2880 1800 + +/* Window background color (RGB format). + Does not work with `setopacity "xroot"` */ +#request setbg 00000000 + +/* (X11 only) EWMH Window type. Possible values are: + + "desktop", "dock", "toolbar", "menu", + "utility", "splash", "dialog", "normal" + + This will set _NET_WM_WINDOW_TYPE to _NET_WM_WINDOW_TYPE_(TYPE), + where (TYPE) is the one of the window types listed (after being + converted to uppercase). + + Alternatively, you can set this value to "!", which will cause + the window to be unmanaged. If this is set, then `addxwinstate` + will do nothing, but you can use "!+" and "!-" to stack on top + or below other windows. +*/ +#request setxwintype "normal" + +/* (X11 only) EWMH Window state atoms (multiple can be specified). + Possible values are: + + "modal", "sticky", "maximized_vert", "maximized_horz", + "shaded", "skip_taskbar", "skip_pager", "hidden", "fullscreen", + "above", "below", "demands_attention", "focused", "pinned" + + This will add _NET_WM_STATE_(TYPE) atoms to _NET_WM_STATE, + where (TYPE) is one of the window states listed (after being + converted to uppercase). + + The lines below (commented out by default) are of relevance + if you are trying to get GLava to behave as a desktop widget + and your WM is not correctly responding to the "desktop" value + for `setxwintype`. +*/ +// #request addxwinstate "sticky" +// #request addxwinstate "skip_taskbar" +// #request addxwinstate "skip_pager" +// #request addxwinstate "above" +// #request addxwinstate "pinned" + +/* (X11 only) Use the XShape extension to support clicking through + the GLava window. Useful when you want to interact with other + desktop windows (icons, menus, desktop shells). Enabled by + default when GLava itself is a desktop window. */ +#request setclickthrough false + +/* Audio source + + When the "pulseaudio" backend is set, this can be a number or + a name of an audio sink or device to record from. Set to "auto" + to use the default output device. + + When the "fifo" backend is set, "auto" is interpreted as + "/tmp/mpd.fifo". Otherwise, a valid path should be provided. */ +#request setsource "auto" + +/* Buffer swap interval (vsync), set to '0' to prevent + waiting for refresh, '1' (or more) to wait for the specified + amount of frames. */ +#request setswap 1 + +/* Linear interpolation for audio data frames. Drastically + improves smoothness with configurations that yield low UPS + (`setsamplerate` and `setsamplesize`), or monitors that have + high refresh rates. + + This feature itself, however, will effect performance as it + will have to interpolate data every frame on the CPU. It will + automatically (and temporarily) disable itself if the update + rate is close to, or higher than the framerate: + + if (update_rate / frame_rate > 0.9) disable_interpolation; + + This will delay data output by one update frame, so it can + desync audio with visual effects on low UPS configs. */ +#request setinterpolate true + +/* Frame limiter, set to the frames per second (FPS) desired or + simply set to zero (or lower) to disable the frame limiter. */ +#request setframerate 0 + +/* Suspends rendering if a fullscreen window is focused while + GLava is still visible (ie. on another monitor). This prevents + rendering from interfering with other graphically intensive + tasks. + + If GLava is minimized or completely obscured, it will not + render regardless of this option. */ +#request setfullscreencheck false + +/* Enable/disable printing framerate every second. 'FPS' stands + for 'Frames Per Second', and 'UPS' stands for 'Updates Per + Second'. Updates are performed when new data is submitted + by pulseaudio, and require transformations to be re-applied + (thus being a good measure of how much work your CPU has to + perform over time) */ +#request setprintframes true + +/* PulseAudio sample buffer size. Lower values result in more + frequent audio updates (also depends on sampling rate), but + will also require all transformations to be applied much + more frequently (CPU intensive). + + High (>2048, with 22050 Hz) values will decrease accuracy + (as some signals can be missed by transformations like FFT) + + The following settings (@22050 Hz) produce the listed rates: + + Sample UPS Description + - 2048 -> 43.0 (low accuracy, cheap), use with < 60 FPS + - 1024 -> 86.1 (high accuracy, expensive), use with >= 60 FPS + - 512 -> 172.3 (extreme accuracy, very expensive), use only + for graphing accurate spectrum data with + custom modules. + + If the framerate drops below the update rate, the update rate + will be locked to the framerate (to prevent wasting CPU time). + This behaviour means you can use a 1024 sample size on a 60Hz + monitor with vsync enabled to get 60FPS and 60UPS. + + For high refresh rate monitors (120+ Hz), it's recommended to + also stick with the 1024 sample size and use interpolation to + smooth the data, as accuracy beyond this setting is mostly + meaningless for visual purposes. +*/ +#request setsamplesize 1024 + +/* Audio buffer size to be used for processing and shaders. + Increasing this value can have the effect of adding 'gravity' + to FFT output, as the audio signal will remain in the buffer + longer. + + This value has a _massive_ effect on FFT performance and + quality for some modules. */ +#request setbufsize 4096 + +/* PulseAudio sample rate. Lower values can add 'gravity' to + FFT output, but can also reduce accuracy. Most hardware + samples at 44100Hz. + + Lower sample rates also can make output more choppy, when + not using interpolation. It's generally OK to leave this + value unless you have a strange PulseAudio configuration. + + This option does nothing when using the "fifo" audio + backend. Instead, an ideal rate should be be configured + in the application generating the output. */ +#request setsamplerate 22050 + +/* ** DEPRECATED ** + Force window geometry (locking the window in place), useful + for some pesky WMs that try to reposition the window when + embedding in the desktop. + + This routinely sends X11 events and should be avoided. */ +#request setforcegeometry false + +/* ** DEPRECATED ** + Force window to be raised (focused in some WMs), useful for + WMs that have their own stacking order for desktop windows. + + This routinely sends X11 events and should be avoided. */ +#request setforceraised false + +/* ** DEPRECATED ** + Scale down the audio buffer before any operations are + performed on the data. Higher values are faster. + + This value can affect the output of various transformations, + since it applies (crude) averaging to the data when shrinking + the buffer. It is reccommended to use `setsamplerate` and + `setsamplesize` to improve performance or accuracy instead. */ +#request setbufscale 1 diff --git a/linux-hidpi/glava/smooth_parameters.glsl b/linux-hidpi/glava/smooth_parameters.glsl new file mode 100755 index 0000000..bfea307 --- /dev/null +++ b/linux-hidpi/glava/smooth_parameters.glsl @@ -0,0 +1,78 @@ + +/* Settings for smoothing functions and transformations commonly + used to display FFT output. + + IMPORTANT: THESE VALUES CAN BE OVERRIDDEN IN MODULE CONFIG + FILES, IF CHANGING VALUES HERE DOES NOT WORK, CHECK + TO MAKE SURE THEY ARE NOT BEING SET ELSEWHERE. +*/ + +/* The type of formula to use for weighting values when smoothing. + Possible values: + + - circular heavily rounded points + - sinusoidal rounded at both low and high weighted values + like a sine wave + - linear not rounded at all; linear distance + */ +#define ROUND_FORMULA sinusoidal + +/* The sampling mode for processing raw FFT input: + + - average averages all the inputs in the sample range for + a given point. Produces smooth output, but peaks + are not well represented + - maximum obtains the best value from the closest peak in + the sample range. Very accurate peaks, but + output is jagged and sporadic. + - hybrid uses the results from both `average` and `maximum` + with the weight provided in `SAMPLE_HYBRID_WEIGHT` */ +#define SAMPLE_MODE average +/* Weight should be provided in the range (0, 1). Higher values favour + averaged results. `hybrid` mode only. */ +#define SAMPLE_HYBRID_WEIGHT 0.65 + +/* Factor used to scale frequencies. Lower values allows lower + frequencies to occupy more space. */ +#define SAMPLE_SCALE 8 + +/* The frequency range to sample. 1.0 would be the entire FFT output, + and lower values reduce the displayed frequencies in a log-like + scale. */ +#define SAMPLE_RANGE 0.9 + +/* Factor for how to scale higher frequencies. Used in a linear equation + which is multiplied by the result of the fft transformation. */ +#request setfftscale 10.2 + +/* Cutoff for the bass end of the audio data when scaling frequencies. + Higher values cause more of the bass frequencies to be skipped when + scaling. */ +#request setfftcutoff 0.3 + +/* How many frames to queue and run through the average function. + Increasing this value will create latency between the audio and the + animation, but will make for much smoother results. */ +#request setavgframes 6 + +/* Whether to window frames ran through the average function (new & old + frames are weighted less). This massively helps smoothing out + spontaneous values in the animation. */ +#request setavgwindow true + +/* Gravity step, higher values means faster drops. The step is applied + in a rate independant method like so: + + val -= (gravitystep) * (seconds per update) */ +#request setgravitystep 4.2 + +/* Smoothing factor. Larger values mean more smoothing in the output, + however high values can be expensive to compute. Values are in + normalized width: [0.0, 1.0) */ +#request setsmoothfactor 0.025 + +/* Whether to use a separate pass for audio data while smoothing. On + most hardware, this will improve performance, but involves doing a + separate render step for each audio texture and will add some driver + (CPU) overhead. */ +#request setsmoothpass true diff --git a/linux-hidpi/glava/util/premultiply.frag b/linux-hidpi/glava/util/premultiply.frag new file mode 100644 index 0000000..4be8846 --- /dev/null +++ b/linux-hidpi/glava/util/premultiply.frag @@ -0,0 +1,17 @@ + +#if PREMULTIPLY_ALPHA == 0 +#error __disablestage +#endif + +#request uniform "prev" tex +uniform sampler2D tex; + +out vec4 fragment; +in vec4 gl_FragCoord; + +void main() { + fragment = texelFetch(tex, ivec2(gl_FragCoord.x, gl_FragCoord.y), 0); + #if PREMULTIPLY_ALPHA > 0 + fragment.rgb *= fragment.a; + #endif +} diff --git a/linux-hidpi/glava/util/smooth.glsl b/linux-hidpi/glava/util/smooth.glsl new file mode 100644 index 0000000..5b8a3b4 --- /dev/null +++ b/linux-hidpi/glava/util/smooth.glsl @@ -0,0 +1,97 @@ + +#ifndef _SMOOTH_GLSL /* include gaurd */ +#define _SMOOTH_GLSL + +#ifndef TWOPI +#define TWOPI 6.28318530718 +#endif + +#ifndef PI +#define PI 3.14159265359 +#endif + +#include "@smooth_parameters.glsl" +#include ":smooth_parameters.glsl" + +/* window value t that resides in range [0, sz)*/ +#define window(t, sz) (0.53836 - (0.46164 * cos(TWOPI * t / (sz - 1)))) +/* this does nothing, but we keep it as an option for config */ +#define linear(x) (x) +/* take value x that scales linearly between [0, 1) and return its sinusoidal curve */ +#define sinusoidal(x) ((0.5 * sin((PI * (x)) - (PI / 2))) + 0.5) +/* take value x that scales linearly between [0, 1) and return its circlar curve */ +#define circular(x) sqrt(1 - (((x) - 1) * ((x) - 1))) + +#define average 0 +#define maximum 1 +#define hybrid 2 + +float scale_audio(float idx) { + return -log((-(SAMPLE_RANGE) * idx) + 1) / (SAMPLE_SCALE); +} + +float iscale_audio(float idx) { + return -log((SAMPLE_RANGE) * idx) / (SAMPLE_SCALE); +} + +/* Note: the SMOOTH_FACTOR macro is defined by GLava itself, from `#request setsmoothfactor`*/ + +float smooth_audio(in sampler1D tex, int tex_sz, highp float idx) { + + #if PRE_SMOOTHED_AUDIO < 1 + float + smin = scale_audio(clamp(idx - SMOOTH_FACTOR, 0, 1)) * tex_sz, + smax = scale_audio(clamp(idx + SMOOTH_FACTOR, 0, 1)) * tex_sz; + float m = ((smax - smin) / 2.0F), s, w; + float rm = smin + m; /* middle */ + + #if SAMPLE_MODE == average + float avg = 0, weight = 0; + for (s = smin; s <= smax; s += 1.0F) { + w = ROUND_FORMULA(clamp((m - abs(rm - s)) / m, 0, 1)); + weight += w; + avg += texelFetch(tex, int(round(s)), 0).r * w; + } + avg /= weight; + return avg; + #elif SAMPLE_MODE == hybrid + float vmax = 0, avg = 0, weight = 0, v; + for (s = smin; s < smax; s += 1.0F) { + w = ROUND_FORMULA(clamp((m - abs(rm - s)) / m, 0, 1)); + weight += w; + v = texelFetch(tex, int(round(s)), 0).r * w; + avg += v; + if (vmax < v) + vmax = v; + } + return (vmax * (1 - SAMPLE_HYBRID_WEIGHT)) + ((avg / weight) * SAMPLE_HYBRID_WEIGHT); + #elif SAMPLE_MODE == maximum + float vmax = 0, v; + for (s = smin; s < smax; s += 1.0F) { + w = texelFetch(tex, int(round(s)), 0).r * ROUND_FORMULA(clamp((m - abs(rm - s)) / m, 0, 1)); + if (vmax < w) + vmax = w; + } + return vmax; + #endif + #else + return texelFetch(tex, int(round(idx * tex_sz)), 0).r; + #endif +} + +/* Applies the audio smooth sampling function three times to the adjacent values */ +float smooth_audio_adj(in sampler1D tex, int tex_sz, highp float idx, highp float pixel) { + float + al = smooth_audio(tex, tex_sz, max(idx - pixel, 0.0F)), + am = smooth_audio(tex, tex_sz, idx), + ar = smooth_audio(tex, tex_sz, min(idx + pixel, 1.0F)); + return (al + am + ar) / 3.0F; +} + +#ifdef TWOPI +#undef TWOPI +#endif +#ifdef PI +#undef PI +#endif +#endif /* _SMOOTH_GLSL */ diff --git a/linux-hidpi/glava/util/smooth_pass.frag b/linux-hidpi/glava/util/smooth_pass.frag new file mode 100644 index 0000000..b55d0f6 --- /dev/null +++ b/linux-hidpi/glava/util/smooth_pass.frag @@ -0,0 +1,16 @@ + +uniform sampler1D tex; +uniform int sz; +uniform int w; + +out vec4 fragment; +in vec4 gl_FragCoord; + +#undef PRE_SMOOTHED_AUDIO +#define PRE_SMOOTHED_AUDIO 0 + +#include ":util/smooth.glsl" + +void main() { + fragment = vec4(smooth_audio(tex, sz, gl_FragCoord.x / w), 0, 0, 0); +} diff --git a/linux-hidpi/glava/wave.glsl b/linux-hidpi/glava/wave.glsl new file mode 100755 index 0000000..6a59fbe --- /dev/null +++ b/linux-hidpi/glava/wave.glsl @@ -0,0 +1,14 @@ +/* min (vertical) line thickness */ +#define MIN_THICKNESS 1 + +/* max (vertical) line thickness */ +#define MAX_THICKNESS 6 + +/* base color to use, distance from center will multiply the RGB components */ +#define BASE_COLOR vec4(0.7, 0.2, 0.45, 1) + +/* amplitude */ +#define AMPLIFY 500 + +/* outline color */ +#define OUTLINE vec4(0.15, 0.15, 0.15, 1) diff --git a/linux-hidpi/glava/wave/1.frag b/linux-hidpi/glava/wave/1.frag new file mode 100644 index 0000000..1352204 --- /dev/null +++ b/linux-hidpi/glava/wave/1.frag @@ -0,0 +1,39 @@ + +layout(pixel_center_integer) in vec4 gl_FragCoord; + +#request uniform "screen" screen +uniform ivec2 screen; /* screen dimensions */ + +#request uniform "audio_l" audio_l +#request transform audio_l "window" +#request transform audio_l "wrange" +uniform sampler1D audio_l; + +out vec4 fragment; + +#include "@wave.glsl" +#include ":wave.glsl" + +#define index(offset) ((texture(audio_l, (gl_FragCoord.x + offset) / screen.x).r - 0.5) * AMPLIFY) + 0.5F + +void main() { + float + os = index(0), + adj0 = index(-1), + adj1 = index(1); + float + s0 = adj0 - os, + s1 = adj1 - os; + float + dmax = max(s0, s1), + dmin = min(s0, s1); + + float s = (os + (screen.y * 0.5F) - 0.5F); /* center to screen coords */ + float diff = gl_FragCoord.y - s; + if (abs(diff) < clamp(abs(s - (screen.y * 0.5)) * 6, MIN_THICKNESS, MAX_THICKNESS) + || (diff <= dmax && diff >= dmin)) { + fragment = BASE_COLOR + (abs((screen.y * 0.5F) - s) * 0.02); + } else { + fragment = vec4(0, 0, 0, 0); + } +} diff --git a/linux-hidpi/glava/wave/2.frag b/linux-hidpi/glava/wave/2.frag new file mode 100644 index 0000000..5ff0706 --- /dev/null +++ b/linux-hidpi/glava/wave/2.frag @@ -0,0 +1,33 @@ + +layout(pixel_center_integer) in vec4 gl_FragCoord; + +#request uniform "prev" tex +uniform sampler2D tex; /* screen texture */ +#request uniform "screen" screen +uniform ivec2 screen; /* screen dimensions */ + +out vec4 fragment; /* output */ + +#include "@wave.glsl" +#include ":wave.glsl" + +void main() { + fragment = texelFetch(tex, ivec2(gl_FragCoord.x, gl_FragCoord.y), 0); + + vec4 + a0 = texelFetch(tex, ivec2((gl_FragCoord.x + 1), (gl_FragCoord.y + 0)), 0), + a1 = texelFetch(tex, ivec2((gl_FragCoord.x + 1), (gl_FragCoord.y + 1)), 0), + a2 = texelFetch(tex, ivec2((gl_FragCoord.x + 0), (gl_FragCoord.y + 1)), 0), + a3 = texelFetch(tex, ivec2((gl_FragCoord.x + 1), (gl_FragCoord.y + 0)), 0), + + a4 = texelFetch(tex, ivec2((gl_FragCoord.x - 1), (gl_FragCoord.y - 0)), 0), + a5 = texelFetch(tex, ivec2((gl_FragCoord.x - 1), (gl_FragCoord.y - 1)), 0), + a6 = texelFetch(tex, ivec2((gl_FragCoord.x - 0), (gl_FragCoord.y - 1)), 0), + a7 = texelFetch(tex, ivec2((gl_FragCoord.x - 1), (gl_FragCoord.y - 0)), 0); + + vec4 avg = (a0 + a1 + a2 + a3 + a4 + a5 + a6 + a7) / 8.0; + if (avg.a > 0){ + if (fragment.a <= 0 || gl_FragCoord.x == 0 || gl_FragCoord.x == screen.x - 1) + fragment = OUTLINE; + } +} diff --git a/linux-hidpi/pam_environment b/linux-hidpi/pam_environment index d28c754..e1ef1ec 100644 --- a/linux-hidpi/pam_environment +++ b/linux-hidpi/pam_environment @@ -3,7 +3,7 @@ QT_IM_MODULE DEFAULT=fcitx XMODIFIERS DEFAULT=\@im=fcitx GTK_THEME DEFAULT=Lumiere -GTK2_RC_FILES DEFAULT=/usr/share/themes/Lumiere/gtk-2.0/gtkrc +GTK2_RC_FILES DEFAULT=/home/vbalien/.themes/Lumiere/gtk-2.0/gtkrc BROWSER DEFAULT=google-chrome-stable BACKLIGHT DEFAULT=gmux_backlight diff --git a/linux-hidpi/picom/picom.conf b/linux-hidpi/picom/picom.conf index 70ec8e6..b64fd2a 100644 --- a/linux-hidpi/picom/picom.conf +++ b/linux-hidpi/picom/picom.conf @@ -36,8 +36,9 @@ shadow-exclude = [ "class_g = 'Cairo-clock'", "class_g = 'slop'", "class_g = 'Polybar'", - "_GTK_FRAME_EXTENTS@:c", - "_PICOM_ROUNDED@:32c = 0" + "class_g = 'conky'", + "class_g = 'GLava'", + "_GTK_FRAME_EXTENTS@:c" ]; # Avoid drawing shadow on all shaped windows (see also: --detect-rounded-corners) @@ -124,6 +125,8 @@ focus-exclude = [ # opacity-rule = [] opacity-rule = [ "100:class_g = 'Polybar'", + "100:class_g = 'conky'", + "100:class_g = 'GLava'", "100:class_g = 'Rofi'", "100:name = 'Picture in picture'", "100:class_g = 'baka-mplayer'", @@ -186,6 +189,8 @@ blur-background-exclude = [ # prevents picom from blurring the background # when taking selection screenshot with `main` # https://github.com/naelstrof/maim/issues/130 + "class_g = 'conky'", + "class_g = 'GLava'", "class_g = 'slop'", "_GTK_FRAME_EXTENTS@:c", ]; diff --git a/mapping.ts b/mapping.ts index 0597285..6975a81 100644 --- a/mapping.ts +++ b/mapping.ts @@ -37,7 +37,7 @@ const linux: DotOption = { kcm-fcitx5 numix-gtk-theme-git numix-circle-icon-theme-git telegram-desktop nautilus eog smplayer smplayer-skins transgui-qt qt5-styleplugins xdg-user-dirs slim network-manager-applet bc - glava conky` + glava conky jq xdo ttf-roboto` ], link: { ...common.link, @@ -74,7 +74,9 @@ const linuxHiDPI: DotOption = { ".config/dunst": "linux-hidpi/dunst", ".config/picom": "linux-hidpi/picom", ".pam_environment": "linux-hidpi/pam_environment", - ".Xresources": "linux-hidpi/Xresources" + ".Xresources": "linux-hidpi/Xresources", + ".config/glava": "linux-hidpi/glava", + ".conkyrc": "linux-hidpi/conkyrc" } };