commit af208844b575edb6ce9205507289a00743a8bf4e parent 878d6a890bdc1a8381b0c44c80c36d829cc28fc1 Author: NunoSempere <nuno.semperelh@protonmail.com> Date: Thu, 14 Mar 2024 19:31:04 -0300 reorg makefile and make runtime locations less messy In particular, stop using the installation directory for anything and instead move to /opt/rosenrot The user specific cache remains at /home/user/.cache Diffstat:
20 files changed, 61 insertions(+), 48 deletions(-)
diff --git a/config.h b/config.h @@ -18,8 +18,9 @@ #define SEARCH "https://search.nunosempere.com/search?q=%s" // #define SEARCH "https://lite.duckduckgo.com/html/?q=%s" #define HOME "" +// ^ Could also be a website ("https://search.nunosempere.com"), or a file ("file:///opt/rose/homepage.png") // #define HOME "https://search.nunosempere.com/" -// #define HOME "file:///home/nuno/Documents/workspace/rosenrot/user-scripts/debian-12/rose-images/rose-homepage-2.png" +// #define HOME "file:///opt/rosenrot/rose.png" // Plugins #define LIBRE_REDIRECT_ENABLED true diff --git a/user-scripts/debian-12/rose-images/rose-homepage-2.png b/images/flower-imgs/rose-homepage-2.png Binary files differ. diff --git a/user-scripts/debian-12/rose-images/rose-2.png b/images/flower-imgs/rose-homepage.png Binary files differ. diff --git a/images/flower-imgs/rose-src.txt b/images/flower-imgs/rose-src.txt @@ -0,0 +1 @@ +https://www.onlygfx.com/red-rose-png-image-transparent/ diff --git a/user-scripts/debian-12/rose-images/rose-homepage.png b/images/flower-imgs/rose.png Binary files differ. diff --git a/images/flower-imgs/rose2.png b/images/flower-imgs/rose2.png Binary files differ. diff --git a/user-scripts/debian-12/rose-images/rose-desktop-icon.png b/images/flower-imgs/rosenrot-desktop-icon.png Binary files differ. diff --git a/makefile b/makefile @@ -1,10 +1,9 @@ # C compiler -CC=gcc # other options: tcc, clang, zig cc +CC=gcc # alternatives: tcc, clang, zig cc WARNINGS=-Wall -DEBUG=#'-g' +DEBUG= # -g OPTIMIZED_SOME=-O3 OPTIMIZED_MORE=-Ofast -march=native -funit-at-a-time -flto # binary will not be compatible with other computers, but may be much faster -# COMPILETIME_DEPRECATION_WARNINGS=#-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED # turns out that webkit2gtk-4.1 is using some deprecated stuff, lol # Dependencies DEPS='webkit2gtk-4.1' @@ -15,62 +14,50 @@ LIBS=`pkg-config --libs ${DEPS}` SRC=rosenrot.c CONFIG=config.h -## Plugins -LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.c ./plugins/libre_redirect/str_replace_start.c ./plugins/libre_redirect/str_init.c -CUSTOM_STYLES=./plugins/style/style.c -READABILITY=./plugins/readability/readability.c -SHORTCUTS=./plugins/shortcuts/shortcuts.c -STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing -PLUGINS=$(LIBRE_REDIRECT) $(READABILITY) $(CUSTOM_STYLES) $(SHORTCUTS) -ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' ## optional adblocking; depends on https://github.com/jun7/wyebadblock +# Plugins +# include plugins/plugins.mk +PLUGINS=./plugins/stand_in/stand_in.c ## Formatter STYLE_BLUEPRINT=webkit FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) -# Change hardcoded paths when building -## Data dirs -USER=`whoami` -DEFAULT_DATA_DIR=/home/nuno/.cache/rosenrot -USER_DATA_DIR=/home/$(USER)/.cache/rosenrot -## Startup image dir -DEFAULT_DIR=/home/nuno/Documents/workspace/rosenrot -CURRENT_DIR=`pwd` - -build: $(SRC) $(PLUGINS) $(CONFIG) - # Recompute constants +# Runtime files +MAINTAINER_CACHE_DIR=/home/nuno/.cache/rosenrot +USER_CACHE_DIR=/home/`whoami`/.cache/rosenrot +RUNTIME_FILES_DIR=/opt/rosenrot/ + +build: $(SRC) $(PLUGINS) $(CONFIG) constants user_cache + $(CC) $(WARNINGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS) $(PLUGINS) $(SRC) -o rosenrot $(LIBS) $(ADBLOCK) + +constants: cd plugins/readability/ && sh recompute_READABILITY_N.sh cd plugins/style && sh recompute_STYLE_N.sh - # Make cache - mkdir -p $(USER_DATA_DIR) - # Hardcode cache path - find $(CURRENT_DIR) -type f -not -path "*.git*" -not -path "*makefile*" -exec \ - sed -i "s|$(DEFAULT_DATA_DIR)|$(USER_DATA_DIR)|g" {} + - # Hardcode git repository path - find $(CURRENT_DIR) -type f -not -path "*.git*" -not -path "*makefile*" -exec \ - sed -i "s|$(DEFAULT_DIR)|$(CURRENT_DIR)|g" {} + - # Compile rosenrot - GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/ - $(CC) $(WARNINGS) $(OPTIMIZED_MORE) $(DEBUG) $(INCS) $(PLUGINS) $(SRC) -o rosenrot $(LIBS) $(ADBLOCK) -install: rosenrot - GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/ +user_cache: + @ # can't make this with sudo, because USER_CACHE_DIR could be /home/root/.cache + mkdir -p $(USER_CACHE_DIR) + find . -type f -not -path "*.git*" -not -path "*makefile*" -exec \ + sed -i "s|$(MAINTAINER_CACHE_DIR)|$(USER_CACHE_DIR)|g" {} + + +runtime_files: + sudo mkdir -p /opt/rosenrot/ + sudo cp style.css /opt/rosenrot/ + sudo cp -r images/flower-imgs /opt/rosenrot/ + +install: rosenrot runtime_files cp -f rosenrot /usr/bin - mkdir -p /usr/share/themes/rosenrot - cp style.css /usr/share/themes/rosenrot/ cp rosenrot-mklink /usr/bin - sudo mkdir -p /usr/bin/rosenrot-browser - sudo cp rosenrot /usr/bin/rosenrot-browser/twitter # custom twitter tweaks uninstall: - rm -r /usr/share/themes/rosenrot + rm -r /opt/rosenrot rm /usr/bin/rosenrot rm /usr/bin/rosenrot-mklink - rm $(DATA_DIR) + rm $(USER_CACHE_DIR) clean: rm rosenrot - rm $(DATA_DIR) + rm $(USER_CACHE_DIR) format: $(SRC) $(PLUGINS) $(FORMATTER) $(SRC) $(PLUGINS) $(rosenrot.h) @@ -98,3 +85,9 @@ diagnose_deprecations: view-gtk3-version: dpkg -l libgtk-3-0 + +twitter: + sudo mkdir -p /usr/bin/rosenrot-browser + sudo cp rosenrot /usr/bin/rosenrot-browser/twitter + +# COMPILETIME_DEPRECATION_WARNINGS=#-DGDK_DISABLE_DEPRECATED -DGTK_DISABLE_DEPRECATED # turns out that webkit2gtk-4.1 is using some deprecated stuff, lol diff --git a/plugins/plugins.mk b/plugins/plugins.mk @@ -0,0 +1,14 @@ +## Plugins +CUSTOM_STYLES=./plugins/style/style.c +SHORTCUTS=./plugins/shortcuts/shortcuts.c +READABILITY=./plugins/readability/readability.c +LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.c ./plugins/libre_redirect/str_replace_start.c ./plugins/libre_redirect/str_init.c + +ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' # optional adblocking; depends on https://github.com/jun7/wyebadblock + +STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing + +PLUGINS=$(CUSTOM_STYLES) $(SHORTCUTS) $(READABILITY) $(LIBRE_REDIRECT) +# PLUGINS=$(STAND_IN) + + diff --git a/plugins/stand_in/stand_in.c b/plugins/stand_in/stand_in.c @@ -25,3 +25,6 @@ void read_style_js(char* string){ } +int shortcut_expand(const char* uri, char* output){ + return 0; +} diff --git a/plugins/stand_in/stand_in.h b/plugins/stand_in/stand_in.h @@ -21,3 +21,4 @@ void read_readability_js(char* string); void read_style_js(char* string); +int shortcut_expand(const char* uri, char* output); diff --git a/rosenrot b/rosenrot Binary files differ. diff --git a/rosenrot.c b/rosenrot.c @@ -414,7 +414,7 @@ int main(int argc, char** argv) gtk_init(NULL, NULL); // <https://docs.gtk.org/gtk3/func.init.html> g_object_set(gtk_settings_get_default(), GTK_SETTINGS_CONFIG_H, NULL); // <https://docs.gtk.org/gobject/method.Object.set.html> GtkCssProvider* css = gtk_css_provider_new(); - gtk_css_provider_load_from_path(css, "/usr/share/themes/rosenrot/style.css", NULL); + gtk_css_provider_load_from_path(css, "/opt/rosenrot/style.css", NULL); gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), 800); /* Initialize GTK objects. These are declared as static globals at the top of this file */ diff --git a/style.css b/style.css @@ -1,7 +1,6 @@ * { font-size: 25px; - /*@Base; */ - /* border-bottom-color: @Base; */ + color: #333; } /* Make titlebar pretty gigantic. I'm pretty myopic. */ diff --git a/user-scripts/debian-12/install-with-dependencies.sh b/user-scripts/debian-12/install-with-dependencies.sh @@ -23,6 +23,8 @@ cd - # Debian desktop icon chmod +x rosenrot.desktop sudo cp rosenrot.desktop /usr/share/applications +mkdir -p /opt/rosenrot +sudo cp rosenrot-desktop-icon.png /opt/rosenrot/ # Optionally, set a shortcut (within GNOME) # https://askubuntu.com/questions/597395/how-to-set-custom-keyboard-shortcuts-from-terminal/1007035#1007035 diff --git a/user-scripts/debian-12/rose-images/rose-1.png b/user-scripts/debian-12/rose-images/rose-1.png Binary files differ. diff --git a/user-scripts/debian-12/rose-images/rose-homepage-1.6-zoom.png b/user-scripts/debian-12/rose-images/rose-homepage-1.6-zoom.png Binary files differ. diff --git a/user-scripts/debian-12/rose-images/rose-src.txt b/user-scripts/debian-12/rose-images/rose-src.txt @@ -1 +0,0 @@ -<https://www.onlygfx.com/red-rose-png-image-transparent/> diff --git a/user-scripts/debian-12/rose-images/rose-desktop-icon.png b/user-scripts/debian-12/rosenrot-desktop-icon.png Binary files differ. diff --git a/user-scripts/debian-12/rosenrot.desktop b/user-scripts/debian-12/rosenrot.desktop @@ -6,4 +6,4 @@ Terminal=false Exec=/bin/rose %u Name=Rose Comment=Minimalistic browser -Icon=/home/nuno/Documents/workspace/rosenrot/user-scripts/debian-12/rose-images/rose-desktop-icon.png +Icon=/opt/rosenrot/rosenrot-desktop-icon.png