File: gauge

package info (click to toggle)
konversation 25.12.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,364 kB
  • sloc: cpp: 46,929; xml: 779; python: 556; sh: 96; perl: 86; makefile: 7
file content (79 lines) | stat: -rwxr-xr-x 1,560 bytes parent folder | download | duplicates (2)
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
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env bash

SERVER=$1
TARGET=$2

shift
shift

PERCENTAGE=$1

# special handling for qdbus variants
_qdbus=${KONVERSATION_DBUS_BIN:-qdbus-qt6}
if ! [ "$(which $_qdbus 2> /dev/null)" ]; then
    _qdbus=qdbus
    if ! [ "$(which $_qdbus 2> /dev/null)" ]; then
        echo "Error: The qdbus (or qdbus-qt6) utility is missing."
        exit 1
    fi
fi

if [ ! $TARGET ]
then
  $_qdbus org.kde.konversation /irc error "Can't write into status view."
else
  if [ ! $PERCENTAGE ]
  then
    $_qdbus org.kde.konversation /irc error "USAGE: $0 <percentage>"
  else
    PERCENTAGE=`echo $PERCENTAGE | sed 's/^0\+//'`
    LEFT=$(($PERCENTAGE/5))
    RIGHT=$((20-$LEFT))

    if [[ $PERCENTAGE -lt 0 ]]; then
      $_qdbus org.kde.konversation /irc error "Percentage has to be bigger than 0"
      exit
    fi
    
    if [[ $PERCENTAGE -gt 100 ]]; then
      $_qdbus org.kde.konversation /irc error "Percentage has to be smaller than 100"
      exit
    fi


    if [ $PERCENTAGE = 50 ]
    then
      METER="|"
    else
      if [[ $PERCENTAGE -lt 50 ]]
      then
        METER="\\"
      else
        METER="/"
      fi
    fi

    for (( i=$LEFT ; $i != 0 ; i-- ))
    do
      OUTPUT="$OUTPUT,"
    done

    OUTPUT="$OUTPUT$METER"

    for (( i=$RIGHT ; $i != 0 ; i-- ))
    do
      OUTPUT="$OUTPUT,"
    done

    OUTPUT=`echo $OUTPUT | sed 's/,/ /g'`
    
    OUTPUT="[$OUTPUT] $PERCENTAGE%"

    if [ $PERCENTAGE = 100 ]
    then
	OUTPUT="$OUTPUT *ding*"
    fi

    $_qdbus org.kde.konversation /irc say $SERVER "$TARGET" "Beer load $OUTPUT"
  fi
fi