~mil/f_scripts

ref: 0.2 f_scripts/scripts/f_theme -rwxr-xr-x 1.9 KiB
4522c8b5Miles Alan f_networks: Ensure networkmanager running on boot 11 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env osh
shopt -s strict:all
DEP="terminus-font util-linux-misc"
DEC="Change the framebuffer theme (font & colors)"
DOC="
  Allows customizing your framebuffer's theme by setting
  the font and colors. Uses the setterm and setfont command line
  tools - so only applicable in the TTY / framebuffer. Also uses
  escape codes to make colors (true black / true white).

  Use the variables for \$F_THEME_FONT_{SM,MD,LG} to set the fonts
  used for {sm,md,lg}{white,dark}.
"
VAR='
  F_THEME_FONTSM="/usr/share/consolefonts/ter-114n.psf.gz"
  F_THEME_FONTMD="/usr/share/consolefonts/ter-920n.psf.gz"
  F_THEME_FONTLG="/usr/share/consolefonts/ter-v32n.psf.gz"
'


fontchange() {
  local FONTS PICKED

  FONTS="$(ls -1 /usr/share/consolefonts/ | sed 's/.psf.gz//g' )"
  echo -e "\b\fcancel\n$FONTS" > /tmp/fbp.fifo
  echo "$FONTS"
  echo "Pick a font:"
  read -r PICKED
  [ "$PICKED" = cancel ] && return
  setfont /usr/share/consolefonts/$PICKED.psf.gz
  echo -e "\v" > /tmp/fbp.fifo
}

blackonwhite() {
  setterm -foreground black -background white --clear --store
  echo  -en "\e]P7ffffff"
  echo -e "\v" > /tmp/fbp.fifo
}

whiteonblack() {
  setterm -foreground white -background black --clear --store
  echo  -en "\e]P7ffffff"
  echo -e "\v" > /tmp/fbp.fifo
}

lgdark() { setfont $F_THEME_FONTLG; whiteonblack; }
mddark() { setfont $F_THEME_FONTMD; whiteonblack; }
smdark() { setfont $F_THEME_FONTSM; whiteonblack; }

lgwhite() { setfont $F_THEME_FONTLG; blackonwhite; }
mdwhite() { setfont $F_THEME_FONTMD; blackonwhite; }
smwhite() { setfont $F_THEME_FONTSM; blackonwhite; }

main() {
  local RUN

  env | grep -q "^$(basename "$0" | tr '[a-z]' '[A-Z]')=" || eval "$VAR"

  while true; do
    OPTS="lgdark mddark smdark lgwhite mdwhite smwhite fontchange"
    [ -p /tmp/fbp.fifo ] && { echo -e "\b\f\r"; echo "$OPTS" | tr " " "\n"; } > /tmp/fbp.fifo
    read -p "Choice ($OPTS)" RUN
    "$RUN"
  done
}

if [ -n "$1" ]; then "$@"; else main; fi