File: make-conf.sh

package info (click to toggle)
wbar 2.3.4-14
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,440 kB
  • sloc: cpp: 3,577; sh: 1,288; makefile: 114
file content (53 lines) | stat: -rwxr-xr-x 1,310 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/env bash

CFGDIR=/tmp
APPDIRS=(/usr/share/applications)
ICONDIRS=(/usr/share/icons/hicolor /usr/share/pixmaps)
MAXICONS=10

apps=$(find "${APPDIRS[@]}" -name '*.desktop' 2>/dev/null |
        xargs grep -l ^Name |
        xargs grep -l ^Icon |
        xargs grep -l ^Exec |
        xargs grep -l ^Type=Application |
        sort -R
     )

# print the dock background settings
cat > "$CFGDIR/wbar.cfg" <<-EOF
i: /usr/local/share/pixmaps/wbar/dock.png
c: wbar --bpress --above-desk --isize 64 --idist 5 --nanim 3 --pos bottom
t: /usr/share/fonts/TTF/UbuntuMono-B/12

EOF

for app in $apps; do
  _name=$(grep ^Name= $app | sed 's/^.*=//')
  _exec=$(grep ^Exec= $app | sed 's/^.*=//')
  _icon=$(grep ^Icon= $app | sed 's/^.*=//')
  icons=$(find "${ICONDIRS[@]}" | grep -i "${_icon}")

  # get the biggest resolution icon
  for size in 128 64 48; do
    for icon in $icons; do
      if [[ "$icon" =~ $size ]] && [ -f "$icon" ]; then
        selected_icon="$icon"
        break 2
      fi
    done
  done

  if [ -s "$selected_icon" ]; then
    grep -q $(basename $selected_icon) "$CFGDIR/wbar.cfg" && continue
    cat >> "$CFGDIR/wbar.cfg" <<-EOF
i: $selected_icon
c: $_exec
t: $(echo $_name | sed 's/[^ a-zA-Z0-9.-]/./g')

EOF
  fi

  [ $((MAXICONS--)) -le 1 ] && break
done

# vim: set sw=2 sts=2 : #