#!/bin/sh # # bgcol - set a random background color on X # # SPDX-FileCopyrightText: 2023 Daniel Kalak # SPDX-License-Identifier: GPL-3.0-or-later # # This program sets a random background color on the X window server. # This is useful if you use dwm, for example. The script selects one of # the 16'777'216 colors from #000000 to #ffffff and prints it to stdout # so that you can save it if you like it. random_digit() { local digits digit digits="0 1 2 3 4 5 6 7 8 9 a b c d e f" for digit in $digits do printf '%s\n' "$digit" done | shuf -n1 } color='#' for i in $(seq 6) do color="$color$(random_digit)" done printf '%s\n' "$color" xsetroot -solid "$color"