This commit is contained in:
Ray Elliott 2023-08-22 11:25:20 +01:00
parent 0fe1537373
commit b3cc2196f6
1 changed files with 35 additions and 0 deletions

35
bashrc
View File

@ -81,3 +81,38 @@ cd() {
builtin cd "$@" builtin cd "$@"
check_todo check_todo
} }
random-bg() {
local color='xxx'
while getopts ":mrgb" opt; do
case $opt in
m) muted=true ;;
r) color="ffxx" ;;
g) color="xffx" ;;
b) color="xxff" ;;
*) echo "Invalid option: -$OPTARG" >&2
return 1 ;;
esac
done
if [ "$muted" = true ]; then
# FIXME sometimes gives 7 digit value
# note value of 30 works
hue_range=360 # Restricted hue range (0-360 degrees)
hue=$((RANDOM % $hue_range))
saturation_range="50-80" # Adjust as needed
saturation=$((RANDOM % ($saturation_range + 1) + ${saturation_range%-*}))
lightness_range="60-80" # Adjust as needed
lightness=$((RANDOM % ($lightness_range + 1) + ${lightness_range%-*}))
color=$(printf "%02x%02x%02x" "$hue" "$saturation" "$lightness")
else
# FIXME: each x is replaced with same value, need a different value for each x
color=${color//x/$(openssl rand -hex 1)}
fi
echo "#$color"
xsetroot -solid "#$color"
}