Skip to content

Commit 0fa4d91

Browse files
authored
inntroduce better defaults for common cases (#71)
Co-authored-by: sandwich <dskvr@users.noreply.github.com>
1 parent 5d453f1 commit 0fa4d91

10 files changed

Lines changed: 29 additions & 19 deletions

File tree

docs/configuration/examples/basic.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
fps = 60 # Lower FPS for battery saving
66
debug = false
77
duration = 1.0 # 1 second workspace animation
8-
shift = 150 # Moderate parallax shift
8+
shift = 100 # Optimized parallax shift for 10 workspaces
99
vsync = true
1010
easing = "expo"
1111

@@ -20,11 +20,13 @@ easing = "expo"
2020
[[global.layers]]
2121
path = "~/Pictures/background.jpg"
2222
shift_multiplier = 0.5 # Moves at half speed
23+
scale = 1.2 # 20% larger to prevent edge smearing
2324
opacity = 1.0
2425
blur = 1.0 # Slight blur for depth
2526

2627
[[global.layers]]
2728
path = "~/Pictures/foreground.png"
28-
shift_multiplier = 1.0 # Normal parallax speed
29+
shift_multiplier = 0.75 # Reduced to stay within bounds
30+
scale = 1.2 # 20% larger to prevent edge smearing
2931
opacity = 0.95 # Slightly transparent
3032
blur = 0.0 # Sharp foreground

docs/configuration/examples/multi-layer.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
fps = 144
66
debug = false
77
duration = 1.2
8-
shift = 250
8+
shift = 100 # Optimized for 10 workspaces without smearing
99
vsync = true
1010
easing = "expo"
1111

@@ -61,7 +61,7 @@ scale = 1.1
6161
# Layer 5: Foreground elements
6262
[[global.layers]]
6363
path = "~/walls/layer5_foreground.png"
64-
shift_multiplier = 1.2 # Faster than normal
64+
shift_multiplier = 1.0 # Full speed (but within bounds)
6565
opacity = 1.0
6666
blur = 0.0 # Sharp foreground
6767
fit = "contain"
@@ -70,7 +70,7 @@ align = { x = 0.5, y = 1.0 } # Bottom-aligned
7070
# Layer 6: Overlay effects (optional)
7171
# [[global.layers]]
7272
# path = "~/walls/layer6_particles.png"
73-
# shift_multiplier = { x = 1.5, y = 0.5 } # Different X/Y speeds
73+
# shift_multiplier = { x = 1.0, y = 0.5 } # Different X/Y speeds
7474
# opacity = 0.3
7575
# blur = 0.0
7676
# fit = "cover"

examples/hyprlax.toml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
# Example hyprlax TOML configuration (scaffold)
2+
#
3+
# Default values optimized for 10 workspaces without edge smearing:
4+
# - shift = 100px per workspace (total 900px movement across 10 workspaces)
5+
# - layer scale = 1.2x (20% larger than viewport)
6+
# - For 1920px screen: 1.2x = 2304px, giving 192px margin each side
7+
# - This prevents edge artifacts while maintaining smooth parallax
28

39
[global]
410
fps = 144
511
duration = 1.0
6-
shift = 200
12+
shift = 100 # Reduced from 200 to prevent smearing with typical 10 workspaces
713
easing = "expo"
814
debug = false
915
vsync = false
@@ -12,12 +18,14 @@ idle_poll_rate = 2.0
1218
[[global.layers]]
1319
path = "images/bg.png"
1420
shift_multiplier = 0.25
21+
scale = 1.2 # 20% larger to accommodate parallax shift without edge artifacts
1522
opacity = 1.0
1623
blur = 0.0
1724

1825
[[global.layers]]
1926
path = "images/fg.png"
20-
shift_multiplier = 1.0
27+
shift_multiplier = 0.75 # Reduced from 1.0 to stay within scaled bounds
28+
scale = 1.2 # Match background scale for consistency
2129
opacity = 0.9
2230
blur = 0.0
2331

src/core/config.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ void config_set_defaults(config_t *cfg) {
2020

2121
cfg->target_fps = 60;
2222
cfg->max_fps = 144;
23-
cfg->shift_pixels = 150.0f;
24-
cfg->scale_factor = 1.5f;
23+
cfg->shift_pixels = 100.0f; /* Reduced from 150 to prevent smearing with 10 workspaces */
24+
cfg->scale_factor = 1.2f; /* Reduced from 1.5 to match new shift defaults */
2525
cfg->animation_duration = 1.0;
2626
cfg->default_easing = EASE_CUBIC_OUT;
2727
cfg->vsync = false; /* Default off to prevent GPU blocking when idle */

src/core/layer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ parallax_layer_t* layer_create(const char *image_path, float shift_multiplier, f
4848

4949
/* Content scaling defaults */
5050
layer->fit_mode = LAYER_FIT_STRETCH;
51-
layer->content_scale = 1.0f;
51+
layer->content_scale = 1.2f; /* 20% larger to prevent edge smearing with 10 workspaces */
5252
layer->align_x = 0.5f;
5353
layer->align_y = 0.5f;
5454
layer->base_uv_x = 0.0f;

src/core/monitor.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ void monitor_handle_workspace_context_change(hyprlax_context_t *ctx,
295295
/* Calculate 2D offset for 2D models */
296296
offset_2d = workspace_calculate_offset_2d(&monitor->current_context,
297297
new_context,
298-
monitor->config ? monitor->config->shift_pixels : 200.0f,
298+
monitor->config ? monitor->config->shift_pixels : 100.0f,
299299
NULL);
300300
if (ctx && ctx->config.debug) {
301301
fprintf(stderr, "[DEBUG] Using 2D offset calculation\n");
@@ -304,7 +304,7 @@ void monitor_handle_workspace_context_change(hyprlax_context_t *ctx,
304304
/* Calculate 1D offset for linear models */
305305
offset_1d = workspace_calculate_offset(&monitor->current_context,
306306
new_context,
307-
monitor->config ? monitor->config->shift_pixels : 200.0f,
307+
monitor->config ? monitor->config->shift_pixels : 100.0f,
308308
NULL);
309309
offset_2d.x = offset_1d;
310310
offset_2d.y = 0.0f;
@@ -349,7 +349,7 @@ void monitor_handle_workspace_context_change(hyprlax_context_t *ctx,
349349
int from_ws = old_context.data.workspace_id;
350350
int to_ws = new_context->data.workspace_id;
351351
int delta_ws = to_ws - from_ws;
352-
float step = (monitor->config ? monitor->config->shift_pixels : 200.0f);
352+
float step = (monitor->config ? monitor->config->shift_pixels : 100.0f);
353353
float base_x = monitor->animating ? monitor->animation_target_x : monitor->parallax_offset_x;
354354
absolute_target_x = base_x + delta_ws * step;
355355
absolute_target_y = 0.0f;

src/hyprlax.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ struct config {
8181
int max_workspaces; // Maximum number of workspaces (detected from Hyprland)
8282
char *config_file_path; // Path to the config file for resolving relative paths
8383
} config = {
84-
.shift_per_workspace = 200.0f, // More dramatic shift between workspaces
84+
.shift_per_workspace = 100.0f, // Optimized shift to prevent smearing with 10 workspaces
8585
.animation_duration = 1.0f, // Longer duration - user can "feel" it settling
8686
.animation_delay = 0.0f,
87-
.scale_factor = 1.5f, // Increased scale to accommodate larger shifts
87+
.scale_factor = 1.2f, // 20% larger to accommodate parallax without edge artifacts
8888
.easing = EASE_EXPO_OUT, // Exponential ease out - fast then very gentle settling
8989
.target_fps = 144,
9090
.vsync = 1,
@@ -1199,7 +1199,7 @@ void print_usage(const char *prog) {
11991199
printf(" or: %s [OPTIONS] --layer <image:shift:opacity> [...]\n", prog);
12001200
printf(" or: %s [OPTIONS] --config <config_file>\n\n", prog);
12011201
printf("Options:\n");
1202-
printf(" -s, --shift <pixels> Pixels to shift per workspace (default: 200)\n");
1202+
printf(" -s, --shift <pixels> Pixels to shift per workspace (default: 100)\n");
12031203
printf(" -d, --duration <seconds> Animation duration (default: 1.0)\n");
12041204
printf(" --delay <seconds> Delay before animation starts (default: 0)\n");
12051205
printf(" -e, --easing <type> Easing function (default: expo)\n");

src/hyprlax_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ static int parse_arguments(hyprlax_context_t *ctx, int argc, char **argv) {
419419
printf(" -h, --help Show this help message\n");
420420
printf(" -v, --version Show version information\n");
421421
printf(" -f, --fps <rate> Target FPS (default: 60)\n");
422-
printf(" -s, --shift <pixels> Shift amount per workspace (default: 150)\n");
422+
printf(" -s, --shift <pixels> Shift amount per workspace (default: 100)\n");
423423
printf(" -d, --duration <seconds> Animation duration (default: 1.0)\n");
424424
printf(" -e, --easing <type> Easing function (default: cubic)\n");
425425
printf(" -c, --config <file> Load configuration from file\n");

src/ipc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ int ipc_handle_request(ipc_context_t* ctx, const char* request, char* response,
13691369
hyprlax_context_t *app = (hyprlax_context_t*)ctx->app_context;
13701370
if (!app) {
13711371
if (strcmp(property, "fps") == 0) { snprintf(response, response_size, "60"); return 0; }
1372-
if (strcmp(property, "shift") == 0) { snprintf(response, response_size, "200"); return 0; }
1372+
if (strcmp(property, "shift") == 0) { snprintf(response, response_size, "100"); return 0; }
13731373
if (strcmp(property, "duration") == 0) { snprintf(response, response_size, "1.000"); return 0; }
13741374
if (strcmp(property, "easing") == 0) { snprintf(response, response_size, "cubic"); return 0; }
13751375
if (ipc_error_codes_enabled()) snprintf(response, response_size, "Error(1217): Unknown property '%s'", property); else snprintf(response, response_size, "Error: Unknown property '%s'", property); return -1;

src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int main(int argc, char **argv) {
8282
printf(" -h, --help Show this help message\n");
8383
printf(" -v, --version Show version information\n");
8484
printf(" -f, --fps <rate> Target FPS (default: 60)\n");
85-
printf(" -s, --shift <pixels> Shift amount per workspace (default: 150)\n");
85+
printf(" -s, --shift <pixels> Shift amount per workspace (default: 100)\n");
8686
printf(" -d, --duration <seconds> Animation duration (default: 1.0)\n");
8787
printf(" -e, --easing <type> Easing function (default: cubic)\n");
8888
printf(" -c, --config <file> Load configuration from file\n");

0 commit comments

Comments
 (0)