#!/usr/bin/env bash # klevstul :: 26.02.26 # help function, to locate the profile dir for the browser librewolf_profile_dir() { ffdir=/home/poq/.config/librewolf/librewolf/ if ! [ -d "$ffdir" ] then echo "error: librewolf's main directory was not found at: '${ffdir}'" else pattern=".default-default" old_dir=`pwd` cd ${ffdir} for _dir in *"${pattern}"*; do [ -d "${_dir}" ] && dir="${_dir}" && break done cd ${old_dir} if [ -z "$dir" ] then echo "error: librewolf's profile directory not found" else ffprofiledir=${ffdir}${dir} echo "${ffprofiledir}" fi fi } trg="/home/poq/syncDir/gitRepos/gi.op.fo/lnx-arch/dots/librewolf/user.js" # get the browser's profile dir, and get the ui customisation preference line from that file lwpd=$(librewolf_profile_dir) if [[ ${lwpd} == error* ]] ; then echo ${lwpd} else prefs=${lwpd}/prefs.js echo "prefs=${prefs}" custState=$(grep -i "browser.uicustomization.state" ${prefs}) echo "" echo ${custState} echo "" # update user.js in the repo # case sensitive replace: # flags: -i edit file in place, c - replace the line # sed -i "/search_string/c replacement_string" ${filename} # case insensitive replace: # move old settings from the target file sed -i '/browser.uiCustomization.state/d' ${trg} # add new settings to the target file echo ${custState} >> ${trg} more ${trg} fi