|
|
#1 |
|
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9
Karma: 18470
Join Date: Jun 2026
Device: none
|
calibre viewer css file?
Calibre -> Preferences -> Styles
leads to the viewer custom css file configuration. Using this interface to edit the css file is a huge pain point. It is MUCH easier to use a proper file editor on the local system. I can not find a file one can edit on the local system that would have the same effect. Am I missing something? The file viewer-webengine.json in CALIBRE_CONFIG_DIRECTORY stores this css style sheet inside the user_stylesheet variable. Changing the style sheet there has the desired effect. The below bash script (Linux) automates this task. It's basically a one liner. You edit a local file in your favorite editor then inject it into viewer-webengine.json. NOTE: calibre viewer should be closed doing this, or it doesn't work. #!/bin/bash ### # set these accordingly MYFILE=$HOME/calibre.css CALIBRE_CONFIG_DIRECTORY=$HOME/.config/calibre ### config_file=$CALIBRE_CONFIG_DIRECTORY/viewer-webengine.json tmp=$(mktemp) # create a temporary file jq --arg val "$(<"$MYFILE")" '."session_data"."user_stylesheet" = $val' "$config_file" >"$tmp" && mv "$tmp" "$config_file" |
|
|
|
|
|
#2 |
|
Junior Member
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9
Karma: 18470
Join Date: Jun 2026
Device: none
|
line cut off
|
|
|
|
| Advert | |
|
|
|
|
#3 |
|
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 55,248
Karma: 182532776
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Code should be wrapped in [CODE][/CODE] (the # tool)...
Code:
#!/bin/sh ### # set these accordingly CSS_FILE=$HOME/calibre.css CALIBRE_CONFIG_DIRECTORY=$HOME/.config/calibre ### config_file=$CALIBRE_CONFIG_DIRECTORY/viewer-webengine.json tmp=$(mktemp) # create a temporary file jq --arg val "$(cat "$CSS_FILE")" '."session_data"."user_stylesheet" = $val' "$config_file" >"$tmp" && mv "$tmp" "$config_file" Code:
--arg val "$(cat "$CSS_FILE")" : sets the variable val to the contents of $CSS_FILE '."session_data"."user_stylesheet" = $val' : jq program to run. It assigns the variable "session_data"."user_stylesheet" to the value of the variable val, i.e. the contents of $CSS_FILE "$config_file" : is the source file > "$tmp" : send the output of jq to a temporary file && mv "$tmp" "$config_file" : and if all goes well replace the original with the temporary file Last edited by DNSB; Yesterday at 11:44 PM. |
|
|
|
![]() |
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Custom CSS Stylesheets for Calibre's Viewer | Ralob | Viewer | 396 | 06-26-2026 09:30 AM |
| Customize viewer css. pygments.css not found | drglenn | Viewer | 2 | 12-18-2020 04:52 PM |
| Css for Calibre viewer background-color | Cjammi | Calibre | 5 | 03-10-2017 12:09 PM |
| Calibre: eBook Viewer - CSS Bug | navjot001 | Library Management | 1 | 03-25-2014 08:55 AM |
| # user css for viewer.py/ ebook-viewer/ prs-650 | tscamera | Calibre | 0 | 01-02-2011 06:28 PM |