This file is indexed.

/usr/bin/battery-graph is in battery-stats 0.3.6-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/bin/bash
#
# This file is part of the battery-stats package.
# Copyright (C) 2002 Karl E. Jørgensen <karl@jorgensen.com> 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software

set -e

prefix=/usr
exec_prefix=${prefix}
libdir=${prefix}/share/battery-stats

TEMP=`getopt -o f:s:t:d:TAg:D --long from:,since:,to:,duration:,text,title:,geometry:,display:,libdir: -n battery-graph -- "$@"`

now=$( date +%s --date=now ) 

from=0
to=0
duration=0
default_duration=10800 # 3 hours
text=false
title="Battery Graph"

eval set -- "$TEMP"
while true ; do
    case "$1" in
	-f|--from)
	    from=`date --date="$2" +%s`
	    shift 2
	    ;;
	-s|--since)
	    from=`date --date="$2" +%s`
	    shift 2
	    to=`date --date=now +%s`
	    ;;
	    
	-t|--to)
	    to=`date --date="$2" +%s`
	    shift 2
	    ;;
	-d|--duration)
	    case "$2" in
		*s) duration=$(basename $2 s) ;;
		*m) duration=$(( $(basename $2 m) * 60 )) ;;
		*h) duration=$(( $(basename $2 h) * 60 * 60 )) ;;
		*d) duration=$(( $(basename $2 d) * 24 * 60 * 60 )) ;;
		*w) duration=$(( $(basename $2 w) * 24 * 60 * 60 * 7 )) ;;
		*) duration=$(( $2 * 60 )) ;;
	    esac
	    shift 2;
	    ;;
	-T)
	    echo 1>&2 battery-graph: Warning: Deprecated option "$1": Use --text instead
	    text=true;
	    shift
	    ;;
	--text)
	    text=true;
	    shift
	    ;;
	-D|--display)
	    DISPLAY=$2
	    export DISPLAY
	    shift 2
	    text=false
	    ;;
	-g|--geometry)
	    geometry=$2
	    shift 2
	    text=false
	    ;;
	--title)
	    title="$2"
	    shift 2
	    text=false
	    ;;
	--libdir)
	    libdir="$2"
	    shift 2
	    ;;
	--)
	    shift
	    break;
	    ;;
	*)
	    echo 1>&2 $0: Internal error - please report as bug '[Parsing args]'
	    exit 2;
    esac
done

if [ -z "$DISPLAY" ] ; then
    text=true
fi

if [ $from -eq 0 ] && [ $duration -eq 0 ] && [ $to -eq 0 ] 
then
    # No options specified at all. 
    duration=$default_duration
    to=$now
fi

case "${from}:${duration}:${to}" in
    0:0:*)	# Only 'to' given
	from=$(( $to - $default_duration ))
	;;
    0:*:0)	# Only duration given
	to=$now
	from=$(( $to - $duration ))
	;;
    0:*:*)	# Only 'duration' and 'to' given
	from=$(( $to - $duration ))
	;;
    *:0:0)	# Only 'from' given
	to=$(( $from + $default_duration ))
	;;
    *:0:*)	# Only 'from' and 'to' given. Great!
	;;
    *:*:0)	# Only 'from' and 'duration' given
	to=$(( $from + $duration ))
	;;
    *:*:*)	# All 3 specified. Make sure that they match up
	if [ $(( $from + $duration )) -ne $to ] ; then
	    echo $0: Inconsistent from/to/duration: $from/$to/$duration
	    exit 2
	fi
	;;
    *)
	echo $0: Internal error - please report bug 1>&2 '[Time calculation]'
	exit 2
esac

# So far, $from and $to are 'seconds since 1st Jan 1970 00:00:00 UTC'.
# But gnuplot uses 'seconds since '1st Jan 2000 00:00:00 UTC'...

adjustment=$(( $(TZ=UTC date +%s --date='1/1/2000') - $(TZ=UTC date +%s --date='1/1/1970') ))

# Adjustment between UTC and local time
utc_adjust=$(( $( date -u --date=12:00 +%s) - $(date --date=12:00 +%s) ))

adjustment=$(( $adjustment - $utc_adjust ))

from2000=$(( $from - $adjustment ))
to2000=$(( $to - $adjustment ))

(   
    if $text ; then
	echo set terminal dumb ${COLUMNS:-$(tput cols)} ${LINES:-$(tput lines)}
    fi
    echo call \"${libdir}/graph-setup\" 
    echo "set xrange [ $from2000 : $to2000 ] noreverse"
    echo plot "\"-\" using (\$1 - $adjustment):2 smooth unique axis x1y1 title \"Battery %\" with lines linewidth 3"
    
    battery-log "$@"
)  | gnuplot -persist ${geometry:+-geometry} $geometry ${title:+-title} "${title}"