feat: install process

This commit is contained in:
2025-09-06 16:28:38 +02:00
parent f37216f4c7
commit 748141d30c
3 changed files with 55 additions and 5 deletions

View File

@@ -5,3 +5,13 @@ wallpaper: src/wallpaper.c
distance_field_generator: src/distance_field_generator.c distance_field_generator: src/distance_field_generator.c
gcc -Werror -Wall -Wextra -fopenmp -I./vendor/raylib-5.5_linux_amd64/include/ -o distance_field_generator src/distance_field_generator.c -L./vendor/raylib-5.5_linux_amd64/lib -l:libraylib.a -lm gcc -Werror -Wall -Wextra -fopenmp -I./vendor/raylib-5.5_linux_amd64/include/ -o distance_field_generator src/distance_field_generator.c -L./vendor/raylib-5.5_linux_amd64/lib -l:libraylib.a -lm
install: wallpaper
sudo install -D -m 755 wallpaper /usr/bin/wallpaper
sudo mkdir -p /usr/share/wallpaper
sudo cp -r resources /usr/share/wallpaper/
clean:
rm -f wallpaper distance_field_generator
.PHONY: all install clean

View File

@@ -11,4 +11,7 @@ $ ./distance_field_generator ./resources/textures/background_mask.png ./resource
# run wallpaper, image paths are customizables # run wallpaper, image paths are customizables
$ ./wallpaper $ ./wallpaper
# install
$ make install
``` ```

View File

@@ -69,7 +69,21 @@ Vector2 hyprland_get_cursor_position()
Texture2D load_texture_from_file(const char *file_path) Texture2D load_texture_from_file(const char *file_path)
{ {
Texture2D texture = LoadTexture(file_path); Texture2D texture = {0};
if (FileExists(file_path))
{
texture = LoadTexture(file_path);
}
else
{
const char *system_path = TextFormat("/usr/share/wallpaper/%s", file_path);
if (FileExists(system_path))
{
texture = LoadTexture(system_path);
}
}
if (texture.id == 0) if (texture.id == 0)
{ {
TraceLog(LOG_ERROR, "Failed to load texture from file: %s", file_path); TraceLog(LOG_ERROR, "Failed to load texture from file: %s", file_path);
@@ -77,6 +91,31 @@ Texture2D load_texture_from_file(const char *file_path)
return texture; return texture;
} }
Shader load_shader_from_file(const char *vs_path, const char *fs_path)
{
Shader shader = {0};
if (FileExists(vs_path) && FileExists(fs_path))
{
shader = LoadShader(vs_path, fs_path);
}
else
{
const char *system_vs_path = TextFormat("/usr/share/wallpaper/%s", vs_path);
const char *system_fs_path = TextFormat("/usr/share/wallpaper/%s", fs_path);
if (FileExists(system_vs_path) && FileExists(system_fs_path))
{
shader = LoadShader(system_vs_path, system_fs_path);
}
}
if (shader.id == 0)
{
TraceLog(LOG_ERROR, "Failed to load shader from files: %s, %s", vs_path, fs_path);
}
return shader;
}
int main(void) int main(void)
{ {
InitWindow(WIDTH, HEIGHT, "pihkaal-wallpaper"); InitWindow(WIDTH, HEIGHT, "pihkaal-wallpaper");
@@ -92,7 +131,7 @@ int main(void)
RenderTexture2D target = LoadRenderTexture(WIDTH, HEIGHT); RenderTexture2D target = LoadRenderTexture(WIDTH, HEIGHT);
// initialize shader // initialize shader
Shader shader = LoadShader("resources/shaders/basic.vs", "resources/shaders/distance_field.fs"); Shader shader = load_shader_from_file("resources/shaders/basic.vs", "resources/shaders/distance_field.fs");
int resolutionLoc = GetShaderLocation(shader, "resolution"); int resolutionLoc = GetShaderLocation(shader, "resolution");
int mousePosLoc = GetShaderLocation(shader, "mousePos"); int mousePosLoc = GetShaderLocation(shader, "mousePos");
@@ -142,8 +181,6 @@ int main(void)
DrawTextureRec(backgroundTex, (Rectangle){0, 0, screenWidth, screenHeight}, (Vector2){0, 0}, WHITE); DrawTextureRec(backgroundTex, (Rectangle){0, 0, screenWidth, screenHeight}, (Vector2){0, 0}, WHITE);
DrawText(TextFormat("Distance Field | x: %.0f, y: %.0f | frame: %.2f ms", mousePos.x, mousePos.y, GetFrameTime() * 1000), 10, 10, 20, WHITE);
EndDrawing(); EndDrawing();
} }