tweak README to add architecture, tweak makefile to make fast.

This commit is contained in:
NunoSempere 2024-02-11 22:13:53 +01:00
parent d2e210c56a
commit e52293d78a
3 changed files with 39 additions and 41 deletions

View File

@ -6,8 +6,6 @@ Rosenrot is a small browser forked from an earlier version of [rose](https://git
![](https://raw.githubusercontent.com/NunoSempere/rosenrot-browser/master/images/6-hello-world.png) ![](https://raw.githubusercontent.com/NunoSempere/rosenrot-browser/master/images/6-hello-world.png)
![](https://raw.githubusercontent.com/NunoSempere/rosenrot-browser/master/images/0-architecture.png)
### Installation ### Installation
You can see detailed instructions [here](./user-scripts/ubuntu-20.04/install-with-dependencies.sh), for Ubuntu 20.04 in particular—though they should generalize easily to other distributions. Or a video installing rosenrot in a fresh Ubuntu 20.04 virtual machine [here](https://video.nunosempere.com/w/t3oAvJLPHTSAMViQ6zbwTV). You can see detailed instructions [here](./user-scripts/ubuntu-20.04/install-with-dependencies.sh), for Ubuntu 20.04 in particular—though they should generalize easily to other distributions. Or a video installing rosenrot in a fresh Ubuntu 20.04 virtual machine [here](https://video.nunosempere.com/w/t3oAvJLPHTSAMViQ6zbwTV).
@ -52,12 +50,27 @@ You can also create a rose.desktop file so that it will show up in your desktop
You can see some screenshots in the [images](./images) folder. You can see some screenshots in the [images](./images) folder.
## Architecture
![](https://raw.githubusercontent.com/NunoSempere/rosenrot-browser/master/images/0-architecture.png)
## Relationship with [rose](https://github.com/mini-rose/rose) ## Relationship with [rose](https://github.com/mini-rose/rose)
- Rose is a minimal browser based on webkit2gtk. Previously, it described itself as aiming to be a "basement for creating your own browser using [the] gtk and webkit libraries". - Rose is a minimal browser based on webkit2gtk. Previously, it described itself as aiming to be a "basement for creating your own browser using [the] gtk and webkit libraries".
- Rosenrot is my (@NunoSempere's) fork from rose. It has accumulated quality of life features/cruft that I like, like a "readability" plugin that simplifies annoying websites like [Matt Levine's Money Stuff newsletter](https://www.bloomberg.com/opinion/articles/2022-10-18/matt-levine-s-money-stuff-credit-suisse-was-a-reverse-meme-stock). It also incorporates ad-blocking. - Rosenrot is my (@NunoSempere's) fork from rose. It has accumulated quality of life features/cruft that I like, like a "readability" plugin that simplifies annoying websites like [Matt Levine's Money Stuff newsletter](https://www.bloomberg.com/opinion/articles/2022-10-18/matt-levine-s-money-stuff-credit-suisse-was-a-reverse-meme-stock). It also incorporates ad-blocking.
- Rosenrot is also a song by the German hardcore rock band [Rammstein](https://www.youtube.com/watch?v=af59U2BRRAU). - Rosenrot is also a song by the German hardcore rock band [Rammstein](https://www.youtube.com/watch?v=af59U2BRRAU).
## Comparison with [surf](https://git.suckless.org/surf/file/surf.c.html)
- Surf is another browser based on GTK/Webkit, from the suckless community.
- It is more complex: surf.c has [2170](https://git.suckless.org/surf/file/surf.c.html) lines, vs rose.c's [454](https://git.nunosempere.com/open.source/rosenrot/src/branch/master/rose.c)
- I find its code messier and harder to understand
- Conversely, surf has significantly more configuration options, and digs deeper into webkit internals.
- Anecdotically, surf feels slower, though I haven't tested this rigorously.
- surf has a larger community, with patches and modifications
- surf is more opinionated, but also less amateurish. For instance, rosenrot
- My recommendation would be to use rose, and if you find some feature missing, either look how surf does it and import it to rose, or move to surf.
### Contribute ### Contribute
- Contribute upstream to [github.com/mini-rose/rose](https://github.com/mini-rose/) for core functionality changes. - Contribute upstream to [github.com/mini-rose/rose](https://github.com/mini-rose/) for core functionality changes.
@ -84,16 +97,14 @@ About my own system:
#### Quality of life: #### Quality of life:
- [ ] Add css for js alerts
- [x] Add custom alert whose css can be customized
- [ ] Debug problems, e.g., this version is non-blocking.
- [ ] Figure out better way to have plugins
- [ ] Double check newtab/next-tab behavior
- [ ] Document creating new applications, e.g., as in [Asana for Linux](https://git.nunosempere.com/NunoSempere/asana-for-linux) - [ ] Document creating new applications, e.g., as in [Asana for Linux](https://git.nunosempere.com/NunoSempere/asana-for-linux)
- [ ] Add list of similar projects: <https://github.com/qutebrowser/qutebrowser#similar-projects> - [ ] Add list of similar projects: <https://github.com/qutebrowser/qutebrowser#similar-projects>
#### Maintenance #### Maintenance
- [x] Add css for js alerts
- [x] Add custom alert whose css can be customized
- [ ] ~~Debug problems, e.g., this version is non-blocking.~~ => will leave as is
- [ ] Set [`webkit_web_context_set_sandbox_enabled`](<https://webkitgtk.org/reference/webkit2gtk/2.36.8/WebKitWebContext.html#webkit-web-context-set-sandbox-enabled>), as recommended [here](<https://blogs.gnome.org/mcatanzaro/2022/11/04/stop-using-qtwebkit/>) - [ ] Set [`webkit_web_context_set_sandbox_enabled`](<https://webkitgtk.org/reference/webkit2gtk/2.36.8/WebKitWebContext.html#webkit-web-context-set-sandbox-enabled>), as recommended [here](<https://blogs.gnome.org/mcatanzaro/2022/11/04/stop-using-qtwebkit/>)
- [ ] Use something other than Whatsapp as an example syslink. - [ ] Use something other than Whatsapp as an example syslink.
- [ ] Fix bug about distorted audio. Maybe related to [this pipewire issue](<https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1547>)? - [ ] Fix bug about distorted audio. Maybe related to [this pipewire issue](<https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1547>)?
@ -101,6 +112,8 @@ About my own system:
#### Previously done #### Previously done
- [x] Figure out better way to have plugins => stand_in code seems superfluous
- [x] Double check newtab/next-tab behavior => custom style now loading correctly.
- [x] Add a shortcut for hiding the search tab. => Already exists: Ctrl+K - [x] Add a shortcut for hiding the search tab. => Already exists: Ctrl+K
- [x] Find out what each of the css elements refers to. => done, see make inspect - [x] Find out what each of the css elements refers to. => done, see make inspect
- [x] Figure out if downloading files is doable. => it is - [x] Figure out if downloading files is doable. => it is

View File

@ -1,31 +1,19 @@
# make
# make build
# (sudo) make install
# make format
# make clean
# make uninstall
## C compiler # C compiler
CC=gcc # gcc: more options. Also I don't know whether tcc has error messages/debug options. CC=gcc # other options: tcc, clang, zig cc
## CC=tcc # tcc: much faster compilation
## other alternatives; clang, zig cc
WARNINGS=-Wall WARNINGS=-Wall
OPTIMIZED=-O3 #-Ofast
LOCAL=-march=native # binary will not be compatible with other computers, but may be much faster
## Main file
SRC=rose.c
## Dependencies
DEPS='webkit2gtk-4.0'
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
# Dependencies
DEPS='webkit2gtk-4.0'
INCS=`pkg-config --cflags ${DEPS}` INCS=`pkg-config --cflags ${DEPS}`
LIBS=`pkg-config --libs ${DEPS}` LIBS=`pkg-config --libs ${DEPS}`
## Optional adblocking # Code
## depends on https://github.com/jun7/wyebadblock SRC=rose.c
ADBLOCK=#'-L/usr/lib/wyebrowser/adblock.so' CONFIG=config.h
## Plugins ## Plugins
LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.c ./plugins/libre_redirect/str_replace_start.c ./plugins/libre_redirect/str_init.c LIBRE_REDIRECT=./plugins/libre_redirect/libre_redirect.c ./plugins/libre_redirect/str_replace_start.c ./plugins/libre_redirect/str_init.c
@ -33,22 +21,14 @@ CUSTOM_STYLES=./plugins/style/style.c
READABILITY=./plugins/readability/readability.c READABILITY=./plugins/readability/readability.c
SHORTCUTS=./plugins/shortcuts/shortcuts.c SHORTCUTS=./plugins/shortcuts/shortcuts.c
STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing STAND_IN=./plugins/stand_in/stand_in.c # gives function definitions for the above, which do nothing
PLUGINS=$(LIBRE_REDIRECT) $(READABILITY) $(CUSTOM_STYLES) $(SHORTCUTS) PLUGINS=$(LIBRE_REDIRECT) $(READABILITY) $(CUSTOM_STYLES) $(SHORTCUTS)
# PLUGINS=$(STAND_IN) ADBLOCK='-L/usr/lib/wyebrowser/adblock.so' ## optional adblocking; depends on https://github.com/jun7/wyebadblock
# Note that if you want some plugins but not others,
# You should edit the stand_in.c file
# CONFIG
CONFIG=config.h
# cp -f config.def.h config.h
## Formatter ## Formatter
STYLE_BLUEPRINT=webkit STYLE_BLUEPRINT=webkit
FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
## Commands
## Hardcoded paths # Change hardcoded paths when building
## Cache ## Cache
USER=`whoami` USER=`whoami`
DEFAULT_CACHE_DIR=/home/loki/.cache/rose DEFAULT_CACHE_DIR=/home/loki/.cache/rose
@ -71,11 +51,16 @@ build: $(SRC) $(PLUGINS) $(CONFIG)
sed -i "s|$(DEFAULT_DIR)|$(CURRENT_DIR)|g" {} + sed -i "s|$(DEFAULT_DIR)|$(CURRENT_DIR)|g" {} +
# Compile rosenrot # Compile rosenrot
GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/ GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/
$(CC) $(WARNINGS) $(OPTIMIZED) $(DEBUG) $(INCS) $(PLUGINS) $(SRC) -o rose $(LIBS) $(ADBLOCK) $(CC) $(WARNINGS) $(OPTIMIZED_SOME) $(DEBUG) $(INCS) $(PLUGINS) $(SRC) -o rose $(LIBS) $(ADBLOCK)
local: $(SRC) $(PLUGINS) $(CONFIG) fast: $(SRC) $(PLUGINS) $(CONFIG)
rm -f *.gcda
GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/ GIO_MODULE_DIR=/usr/lib/x86_64-linux-gnu/gio/modules/
$(CC) $(WARNINGS) $(OPTIMIZED) $(LOCAL) $(INCS) $(PLUGINS) $(SRC) -o rose $(LIBS) $(ADBLOCK) $(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-generate $(INCS) $(PLUGINS) $(SRC) -o rose $(LIBS) $(ADBLOCK)
@echo "Now use the browser for a while to gather some profiling data"
./rose
$(CC) $(WARNINGS) $(OPTIMIZED_MORE) -fprofile-use $(INCS) $(PLUGINS) $(SRC) -o rose $(LIBS) $(ADBLOCK)
rm -f *.gcda
lint: lint:
clang-tidy $(SRC) $(PLUGINS) -- -Wall -O3 `pkg-config --cflags 'webkit2gtk-4.0'` -o rose `pkg-config --libs 'webkit2gtk-4.0'` clang-tidy $(SRC) $(PLUGINS) -- -Wall -O3 `pkg-config --cflags 'webkit2gtk-4.0'` -o rose `pkg-config --libs 'webkit2gtk-4.0'`

BIN
rose

Binary file not shown.