aboutsummaryrefslogtreecommitdiff
path: root/xconky
blob: c77df941475b296c6a4a62f73e36ec04ec27ccbb (plain)
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
#!/bin/bash
#
# Conky wrapper
#

# Start multiple conky instances
function xconky_start {
  # Default one, system status
  conky &

  # Personal status
  if [ -e "$HOME/.conky/status/conkyrc" ]; then
    conky --config $HOME/.conky/status/conkyrc &
  fi

  # Weather
  #if [ -e "$HOME/.brweather.conf" ]; then
  #  # Give time for networking
  #  sleep 60
  #
  #  # Load weather data first
  #  weather &> /dev/null
  #
  #  # Clear cache
  #  brweather --clean-cache
  #
  #  # Weather
  #  conky -c ~/.conky/weather/conkyrc &
  #fi
}

# Battery level if on laptop
function xconky_battery {
  if laptop-detect; then
    echo '${color grey}${color grey}Power: ${battery} ${battery_bar 6}'
  fi
}

# Show home usage
function xconky_fs_home {
  echo "~/ \$color\${fs_free $HOME}/\${fs_size $HOME} \${fs_bar 6 $HOME}"
}

# Refresh all instances
function xconky_refresh {
  # Clear cache
  #brweather --clean-cache

  # Send HUP
  killall -USR1 conky
}

# Kill all instances
function xconky_kill {
  kill -9 `pidof conky`
}

# Restart all instances
function xconky_restart {
  xconky_kill
  xconky_start
}

# Check
if ! which conky &> /dev/null; then
  exit
fi

# Parse
if [ -z "$1" ] || [ "$1" == "start" ]; then
  xconky_start
elif [ "$1" == "battery" ]; then
  xconky_battery
elif [ "$1" = "fs_home" ]; then
  xconky_fs_home
elif [ "$1" = "refresh" ]; then
  xconky_refresh
elif [ "$1" = "kill" ]; then
  xconky_kill
elif [ "$1" = "restart" ]; then
  xconky_restart
fi