From af208844b575edb6ce9205507289a00743a8bf4e Mon Sep 17 00:00:00 2001 From: NunoSempere Date: Thu, 14 Mar 2024 19:31:04 -0300 Subject: 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 --- config.h | 3 +- images/flower-imgs/rose-homepage-2.png | Bin 0 -> 145422 bytes images/flower-imgs/rose-homepage.png | Bin 0 -> 485022 bytes images/flower-imgs/rose-src.txt | 1 + images/flower-imgs/rose.png | Bin 0 -> 485022 bytes images/flower-imgs/rose2.png | Bin 0 -> 113204 bytes images/flower-imgs/rosenrot-desktop-icon.png | Bin 0 -> 756923 bytes makefile | 77 ++++++++++----------- plugins/plugins.mk | 14 ++++ plugins/stand_in/stand_in.c | 3 + plugins/stand_in/stand_in.h | 1 + rosenrot | Bin 40216 -> 35536 bytes rosenrot.c | 2 +- style.css | 3 +- .../debian-12/install-with-dependencies.sh | 2 + user-scripts/debian-12/rose-images/rose-1.png | Bin 640116 -> 0 bytes user-scripts/debian-12/rose-images/rose-2.png | Bin 485022 -> 0 bytes .../debian-12/rose-images/rose-desktop-icon.png | Bin 756923 -> 0 bytes .../rose-images/rose-homepage-1.6-zoom.png | Bin 104014 -> 0 bytes .../debian-12/rose-images/rose-homepage-2.png | Bin 145422 -> 0 bytes .../debian-12/rose-images/rose-homepage.png | Bin 485022 -> 0 bytes user-scripts/debian-12/rose-images/rose-src.txt | 1 - user-scripts/debian-12/rosenrot-desktop-icon.png | Bin 0 -> 756923 bytes user-scripts/debian-12/rosenrot.desktop | 2 +- 24 files changed, 61 insertions(+), 48 deletions(-) create mode 100644 images/flower-imgs/rose-homepage-2.png create mode 100644 images/flower-imgs/rose-homepage.png create mode 100644 images/flower-imgs/rose-src.txt create mode 100644 images/flower-imgs/rose.png create mode 100644 images/flower-imgs/rose2.png create mode 100644 images/flower-imgs/rosenrot-desktop-icon.png create mode 100644 plugins/plugins.mk delete mode 100644 user-scripts/debian-12/rose-images/rose-1.png delete mode 100644 user-scripts/debian-12/rose-images/rose-2.png delete mode 100644 user-scripts/debian-12/rose-images/rose-desktop-icon.png delete mode 100644 user-scripts/debian-12/rose-images/rose-homepage-1.6-zoom.png delete mode 100644 user-scripts/debian-12/rose-images/rose-homepage-2.png delete mode 100644 user-scripts/debian-12/rose-images/rose-homepage.png delete mode 100644 user-scripts/debian-12/rose-images/rose-src.txt create mode 100644 user-scripts/debian-12/rosenrot-desktop-icon.png diff --git a/config.h b/config.h index ec6cc9e..729f926 100644 --- 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/images/flower-imgs/rose-homepage-2.png b/images/flower-imgs/rose-homepage-2.png new file mode 100644 index 0000000..2770c78 Binary files /dev/null and b/images/flower-imgs/rose-homepage-2.png differ diff --git a/images/flower-imgs/rose-homepage.png b/images/flower-imgs/rose-homepage.png new file mode 100644 index 0000000..9944beb Binary files /dev/null and b/images/flower-imgs/rose-homepage.png differ diff --git a/images/flower-imgs/rose-src.txt b/images/flower-imgs/rose-src.txt new file mode 100644 index 0000000..b41762d --- /dev/null +++ b/images/flower-imgs/rose-src.txt @@ -0,0 +1 @@ +https://www.onlygfx.com/red-rose-png-image-transparent/ diff --git a/images/flower-imgs/rose.png b/images/flower-imgs/rose.png new file mode 100644 index 0000000..9944beb Binary files /dev/null and b/images/flower-imgs/rose.png differ diff --git a/images/flower-imgs/rose2.png b/images/flower-imgs/rose2.png new file mode 100644 index 0000000..6ab0658 Binary files /dev/null and b/images/flower-imgs/rose2.png differ diff --git a/images/flower-imgs/rosenrot-desktop-icon.png b/images/flower-imgs/rosenrot-desktop-icon.png new file mode 100644 index 0000000..163494f Binary files /dev/null and b/images/flower-imgs/rosenrot-desktop-icon.png differ diff --git a/makefile b/makefile index a6d3a93..2703e83 100644 --- 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 new file mode 100644 index 0000000..f95cac7 --- /dev/null +++ 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 index dbcc7e8..cb8c487 100644 --- 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 index 062acf7..10f4283 100644 --- 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 index 2e62adb..830bad2 100755 Binary files a/rosenrot and b/rosenrot differ diff --git a/rosenrot.c b/rosenrot.c index 680ae41..1706a3c 100644 --- a/rosenrot.c +++ b/rosenrot.c @@ -414,7 +414,7 @@ int main(int argc, char** argv) gtk_init(NULL, NULL); // g_object_set(gtk_settings_get_default(), GTK_SETTINGS_CONFIG_H, NULL); // 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 index b0dee59..2b2eb6a 100644 --- 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 index e1aa254..687c376 100644 --- 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 deleted file mode 100644 index f2c546a..0000000 Binary files a/user-scripts/debian-12/rose-images/rose-1.png and /dev/null differ diff --git a/user-scripts/debian-12/rose-images/rose-2.png b/user-scripts/debian-12/rose-images/rose-2.png deleted file mode 100644 index 9944beb..0000000 Binary files a/user-scripts/debian-12/rose-images/rose-2.png and /dev/null differ diff --git a/user-scripts/debian-12/rose-images/rose-desktop-icon.png b/user-scripts/debian-12/rose-images/rose-desktop-icon.png deleted file mode 100644 index 163494f..0000000 Binary files a/user-scripts/debian-12/rose-images/rose-desktop-icon.png and /dev/null 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 deleted file mode 100644 index 97183ac..0000000 Binary files a/user-scripts/debian-12/rose-images/rose-homepage-1.6-zoom.png and /dev/null differ diff --git a/user-scripts/debian-12/rose-images/rose-homepage-2.png b/user-scripts/debian-12/rose-images/rose-homepage-2.png deleted file mode 100644 index 2770c78..0000000 Binary files a/user-scripts/debian-12/rose-images/rose-homepage-2.png and /dev/null differ diff --git a/user-scripts/debian-12/rose-images/rose-homepage.png b/user-scripts/debian-12/rose-images/rose-homepage.png deleted file mode 100644 index 9944beb..0000000 Binary files a/user-scripts/debian-12/rose-images/rose-homepage.png and /dev/null differ diff --git a/user-scripts/debian-12/rose-images/rose-src.txt b/user-scripts/debian-12/rose-images/rose-src.txt deleted file mode 100644 index 30650de..0000000 --- a/user-scripts/debian-12/rose-images/rose-src.txt +++ /dev/null @@ -1 +0,0 @@ - diff --git a/user-scripts/debian-12/rosenrot-desktop-icon.png b/user-scripts/debian-12/rosenrot-desktop-icon.png new file mode 100644 index 0000000..163494f Binary files /dev/null and b/user-scripts/debian-12/rosenrot-desktop-icon.png differ diff --git a/user-scripts/debian-12/rosenrot.desktop b/user-scripts/debian-12/rosenrot.desktop index c970b7a..dc30dc7 100755 --- 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 -- cgit v1.2.3