Skip to content

Commit

Permalink
Added font customization
Browse files Browse the repository at this point in the history
Text font family styling can be changed in the configuration file.

closes issue #6
  • Loading branch information
jNullj committed Oct 28, 2022
1 parent ff41d52 commit bd6c507
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions example.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
background-color=black
package-color=green # color of up-to-date packages
old-package-color=red # color of outdated packages
font-family="'Courier New', Courier" # packages text font
logo-image=/opt/fox-neat-wallpaper/logo.svg # path to logo image to include in center, make sure permisions to the file is set correctly
2 changes: 2 additions & 0 deletions fox-neat-wallpaper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ get_config_file () {
[package-color]="green"
[old-package-color]="red"
[logo-image]="$INSTALL_PATH/logo.svg"
[font-family]="'Courier New', Courier"
)
# read system-wide config
read_config_file "$HOST_CONFIG_PATH"
Expand Down Expand Up @@ -121,6 +122,7 @@ generate_wallpaper () {
RENDER_URL="${RENDER_URL}&bg_color=${config[background-color]}"
RENDER_URL="${RENDER_URL}&pkg_color=${config[package-color]}"
RENDER_URL="${RENDER_URL}&old_color=${config[old-package-color]}"
RENDER_URL="${RENDER_URL}&font=${config[font-family]}"
# generate image of background text
# chromium spams lots of undesired output while attempting to use gpu acceleration. to avoid that output is redirected to /dev/null
chromium --headless --hide-scrollbars --window-size=$IMAGE_SIZE --screenshot=$IMG_NAME "$RENDER_URL" &> /dev/null
Expand Down
7 changes: 5 additions & 2 deletions render.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let img_height = parseInt(myurl.searchParams.get('height')) // image height to r
let background_color = myurl.searchParams.get('bg_color') // background color
let package_text_color = myurl.searchParams.get('pkg_color'); // package text color
let old_text_color = myurl.searchParams.get('old_color'); // package text color
let text_font = myurl.searchParams.get('font'); // package text color
// get the span element where packages are displayed
// this is used by the functions bellow
var container = document.getElementById('container') // container used for better dimensions control
Expand Down Expand Up @@ -66,19 +67,21 @@ function mark_outdated(pkg_names){
* @param {string} bg_color background color name supported by html
* @param {string} pkg_txt_color up-to-date package text color
* @param {string} old_txt_color out-dated package text color
* @param {string} txt_font packages names styling font family
*/
function updateTheme(bg_color, pkg_txt_color, old_txt_color){
function updateTheme(bg_color, pkg_txt_color, old_txt_color, txt_font){
document.body.style.backgroundColor = bg_color;
document.body.style.color = pkg_txt_color;
let old_array = document.getElementsByTagName('old');
for (let i = 0; i < old_array.length; i++) {
let element = old_array[i];
element.style.color = old_txt_color;
}
document.body.style.fontFamily = txt_font;
}

// generate the page
insert_pkg_list(pkg_list)
mark_outdated(outdated)
updateTheme(background_color, package_text_color, old_text_color)
updateTheme(background_color, package_text_color, old_text_color, text_font)
resizeFont(img_width, img_height)

0 comments on commit bd6c507

Please sign in to comment.