aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2014-11-15 23:29:05 +0100
committerGravatar Tom van der Lee <t0m.vd.l33@gmail.com>2014-11-15 23:29:05 +0100
commitf691f01606af95670e0983884062a1d70ec7bce9 (patch)
treec8e45309cbfd1f53682ef7d5297c6e2b012f5f7d
parentba4a9bca449de7e0f9ad0b1d2ebc104a45036638 (diff)
downloaddotfiles-f691f01606af95670e0983884062a1d70ec7bce9.tar.gz
dotfiles-f691f01606af95670e0983884062a1d70ec7bce9.tar.bz2
dotfiles-f691f01606af95670e0983884062a1d70ec7bce9.zip
Moved some panel code to seperate file
-rwxr-xr-xherbstluftwm/.config/herbstluftwm/autostart5
-rwxr-xr-xherbstluftwm/.config/herbstluftwm/notify.sh21
-rwxr-xr-xherbstluftwm/.config/herbstluftwm/panel.sh98
-rw-r--r--herbstluftwm/.config/herbstluftwm/panel_indicators.sh127
-rwxr-xr-xherbstluftwm/.config/herbstluftwm/popup.sh26
-rw-r--r--herbstluftwm/.config/herbstluftwm/theme.sh (renamed from herbstluftwm/.config/herbstluftwm/theme)2
-rwxr-xr-xliquidprompt/.lp_ps12
7 files changed, 149 insertions, 132 deletions
diff --git a/herbstluftwm/.config/herbstluftwm/autostart b/herbstluftwm/.config/herbstluftwm/autostart
index 9ec12f8..c93ff15 100755
--- a/herbstluftwm/.config/herbstluftwm/autostart
+++ b/herbstluftwm/.config/herbstluftwm/autostart
@@ -6,8 +6,9 @@ hc() {
6 herbstclient "$@" 6 herbstclient "$@"
7} 7}
8 8
9#Include the theming script
9dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 10dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
10source "$dir/theme" 11source "$dir/theme.sh"
11 12
12#Detect monitors 13#Detect monitors
13hc set auto_detect_monitors 1 14hc set auto_detect_monitors 1
@@ -186,4 +187,4 @@ $dir/start.sh "xrdb -load $HOME/.Xresources"
186$dir/start.sh "xset +fp /usr/share/fonts/local" 187$dir/start.sh "xset +fp /usr/share/fonts/local"
187$dir/start.sh "xset fp rehash" 188$dir/start.sh "xset fp rehash"
188$dir/start.sh "dropboxd" 189$dir/start.sh "dropboxd"
189#$dir/start.sh "$dir/notify.sh $monitor_w $window_p $panel_h $dir/popup.sh" 190#$dir/start.sh "$dir/notify.sh $dir/popup.sh"
diff --git a/herbstluftwm/.config/herbstluftwm/notify.sh b/herbstluftwm/.config/herbstluftwm/notify.sh
index 190d496..40c5330 100755
--- a/herbstluftwm/.config/herbstluftwm/notify.sh
+++ b/herbstluftwm/.config/herbstluftwm/notify.sh
@@ -1,29 +1,18 @@
1#!/bin/bash 1#!/bin/bash
2 2
3monitor_w=$1
4window_p=$2
5panel_h=$3
6
7popup_w=$(echo "$monitor_w - (2 * $window_p)" | bc)
8popup_h=$panel_h
9popup_x=$window_p
10popup_y=$window_p
11
12popup_opts="-w $popup_w -h $popup_h -x $popup_x -y $popup_y"
13
14while true; do 3while true; do
15 4
16 bat_lvl=$(cat /sys/class/power_supply/BAT1/capacity) 5 bat_lvl=$(cat /sys/class/power_supply/BAT1/capacity)
17 bat_stat=$(cat /sys/class/power_supply/BAT1/status) 6 bat_stat=$(cat /sys/class/power_supply/BAT1/status)
18 7
19 if [[ $bat_lvl -le 5 && $bat_stat == "Discharging" ]]; then 8 if [[ $bat_lvl -le 5 && $bat_stat == "Discharging" ]]; then
20 $4 -m "Battery level critical: $bat_lvl%%" -u "high" $popup_opts 9 $1 -m "Battery level critical: $bat_lvl%%" -u "high"
21 elif [[ $bat_lvl -eq 10 && $bat_stat == "Discharging" ]]; then 10 elif [[ $bat_lvl -eq 10 && $bat_stat == "Discharging" ]]; then
22 $4 -m "Battery level low: $bat_lvl%%" $popup_opts 11 $1 -m "Battery level low: $bat_lvl%%"
23 elif [[ $bat_lvl -eq 50 && $bat_stat == "Discharging" ]]; then 12 elif [[ $bat_lvl -eq 50 && $bat_stat == "Discharging" ]]; then
24 $4 -m "Battery level at $bat_lvl%%" $popup_opts 13 $1 -m "Battery level at $bat_lvl%%"
25 elif [[ $bat_lvl -eq 100 && $bat_stat == "Charging" ]]; then 14 elif [[ $bat_lvl -eq 100 && $bat_stat == "Charging" ]]; then
26 $4 -m "Battery fully charged" 15 $1 -m "Battery fully charged"
27 fi 16 fi
28 17
29 sleep 60; 18 sleep 60;
diff --git a/herbstluftwm/.config/herbstluftwm/panel.sh b/herbstluftwm/.config/herbstluftwm/panel.sh
index 9b8fb48..763c668 100755
--- a/herbstluftwm/.config/herbstluftwm/panel.sh
+++ b/herbstluftwm/.config/herbstluftwm/panel.sh
@@ -5,7 +5,8 @@ hc() {
5} 5}
6 6
7dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 7dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
8source "$dir/theme" 8source "$dir/theme.sh"
9source "$dir/panel_indicators.sh"
9 10
10monitor=${1:-0} 11monitor=${1:-0}
11 12
@@ -41,97 +42,12 @@ fi
41 # <eventname>\t<data> [...] 42 # <eventname>\t<data> [...]
42 # e.g. 43 # e.g.
43 # date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29 44 # date ^fg(#efefef)18:33^fg(#909090), 2013-10-^fg(#efefef)29
44
45 while true ; do 45 while true ; do
46 # Music 46 music
47 player_status=$(playerctl status) 47 volume
48 if [ $player_status = "Playing" ]; then 48 network
49 player_artist=$(playerctl metadata artist) 49 battery
50 player_title=$(playerctl metadata title) 50 clock
51 playing="$player_title - $player_artist"
52
53 if [ "$current" != "$playing" ] ; then
54 current=$playing
55 scrolling=$current
56 elif [ ${#scrolling} -gt "24" ] ; then
57 scrolling=${scrolling:1}
58 else
59 scrolling=$current
60 fi
61
62 echo -e "music\t\ue05c ${scrolling:0:24}"
63 else
64 echo -e "music\toff"
65 fi
66
67 # Volume
68 if pgrep pulseaudio >> /dev/null ; then
69 volumes=$(\
70 amixer get Master | \
71 grep "Front Right: Playback"\
72 )
73 vol=$(\
74 echo $volumes | \
75 sed "s/.*\[\([0-9]*\)%\].*/\1/"\
76 )
77 if [ -z $vol ] ; then
78 echo -e "volume\toff"
79 else
80 echo -e "volume\t%{F$acolor_fg}\ue05d $vol%%%{F-}"
81 fi
82 else
83 echo -e "volume\toff"
84 fi
85
86 # Network
87 read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'`
88 if iwconfig $int1 >/dev/null 2>&1; then
89 wifi=$int1
90 eth=$int2
91 else
92 wifi=$int2
93 eth=$int1
94 fi
95
96 ip link show $eth | grep 'state UP' >/dev/null && int=$eth || int=$wifi
97
98 if [ $int == "wlp3s0" ] ; then
99 iwconfig=$(iwconfig $int)
100 ssid=$(\
101 echo $iwconfig | \
102 sed "s/.*ESSID:\(\".*\"\).*/\1/" | \
103 sed "s/.*\(off\/any\).*/\"\1\"/" | \
104 sed "s/.*\"\(.*\)\".*/\1/"\
105 )
106
107 if [ $ssid != "off/any" ] ; then
108 echo -e "net\t\ue0f3 $ssid"
109 else
110 echo -e "net\toff"
111 fi
112
113 elif [ $int == "enp2s0" ] ; then
114 echo -e "net\t\ue0af ethernet"
115 else
116 echo -e "net\toff"
117 fi
118
119 # Battery
120 if $(test -e /sys/class/power_supply/BAT1) ; then
121 bat_lvl=$(cat /sys/class/power_supply/BAT1/capacity)
122 if [ $bat_lvl -lt 15 ] ; then
123 bat_color=$acolor_accent
124 else
125 bat_color=$acolor_fg
126 fi
127 state=$(cat /sys/class/power_supply/BAT1/status)
128 echo -e "battery\t%{F$acolor_fg}\ue03b %{F$bat_color}$bat_lvl%{F$acolor_fg}%%%{F-}"
129 else
130 echo -e "battery\toff"
131 fi
132
133 # Time
134 echo -e $(date +$"date\t%{F$acolor_fg}%H:%M:%S %{F$acolor_fg}(%d-%m-%Y)%{F-}")
135 sleep 1 || break 51 sleep 1 || break
136 done > >(uniq_linebuffered) & 52 done > >(uniq_linebuffered) &
137 childpid=$! 53 childpid=$!
diff --git a/herbstluftwm/.config/herbstluftwm/panel_indicators.sh b/herbstluftwm/.config/herbstluftwm/panel_indicators.sh
new file mode 100644
index 0000000..e450337
--- /dev/null
+++ b/herbstluftwm/.config/herbstluftwm/panel_indicators.sh
@@ -0,0 +1,127 @@
1#!/bin/bash
2battery_icon=("\ue113" "\ue114" "\ue115" "\ue116" "\ue042")
3network_icon=("\ue0f1" "\ue0f2" "\ue0f3" "\ue0af")
4music_icon="\ue05c"
5
6music()
7{
8 # Music
9 player_status=$(playerctl status)
10 if [ $player_status = "Playing" ]; then
11 player_artist=$(playerctl metadata artist)
12 player_title=$(playerctl metadata title)
13 playing="$player_title - $player_artist"
14
15 if [ "$current" != "$playing" ] ; then
16 current=$playing
17 scrolling=$current
18 elif [ ${#scrolling} -gt "24" ] ; then
19 scrolling=${scrolling:1}
20 else
21 scrolling=$current
22 fi
23
24 echo -e "music\t$music_icon ${scrolling:0:24}"
25 else
26 echo -e "music\toff"
27 fi
28}
29
30volume()
31{
32 # Volume
33 if pgrep pulseaudio >> /dev/null ; then
34 volumes=$(\
35 amixer get Master | \
36 grep "Front Right: Playback"\
37 )
38 vol=$(\
39 echo $volumes | \
40 sed "s/.*\[\([0-9]*\)%\].*/\1/"\
41 )
42 if [ -z $vol ] ; then
43 echo -e "volume\toff"
44 else
45 echo -e "volume\t%{F$acolor_fg}\ue05d $vol%%%{F-}"
46 fi
47 else
48 echo -e "volume\toff"
49 fi
50}
51
52network()
53{
54 # Network
55 read lo int1 int2 <<< `ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p'`
56 if iwconfig $int1 >/dev/null 2>&1; then
57 wifi=$int1
58 eth=$int2
59 else
60 wifi=$int2
61 eth=$int1
62 fi
63
64 ip link show $eth | grep 'state UP' >/dev/null && int=$eth || int=$wifi
65
66 if [ $int == $wifi ] ; then
67 iwconfig=$(iwconfig $int)
68 ssid=$(
69 echo $iwconfig | \
70 sed "s/.*ESSID:\(\".*\"\).*/\1/" | \
71 sed "s/.*\(off\/any\).*/\"\1\"/" | \
72 sed "s/.*\"\(.*\)\".*/\1/"
73 )
74
75 quality=$( \
76 echo $iwconfig | \
77 sed "s/^.*Link Quality=\([0-9]*\)\/\([0-9]*\) .*$/(\1*100)\/\2/" | \
78 bc
79 )
80
81 if [ $ssid == "off/any" ] ; then
82 echo -e "net\toff"
83 elif [ $quality -lt 33 ] ; then
84 echo -e "net\t${network_icon[0]} $ssid"
85 elif [ $quality -lt 66 ] ; then
86 echo -e "net\t${network_icon[1]} $ssid"
87 else
88 echo -e "net\t${network_icon[2]} $ssid"
89 fi
90
91 elif [ $int == $eth ] ; then
92 echo -e "net\t${network_icon[3]} ethernet"
93 else
94 echo -e "net\toff"
95 fi
96}
97
98battery()
99{
100 # Battery
101 if $(test -e /sys/class/power_supply/BAT1) ; then
102
103 bat_lvl=$(cat /sys/class/power_supply/BAT1/capacity)
104 bat_state=$(cat /sys/class/power_supply/BAT1/status)
105
106 if [ $bat_state == "Charging" ] ; then
107 bat_status="${battery_icon[4]}"
108 elif [ $bat_lvl -lt 10 ] ; then
109 bat_status="${F$acolor_accent}${battery_icon[0]}${F-}"
110 elif [ $bat_ -lt 33 ] ; then
111 bat_status="${battery_icon[1]}"
112 elif [ $bat_lvl -lt 66 ] ; then
113 bat_status="${battery_icon[2]}"
114 else
115 bat_status="${battery_icon[3]}"
116 fi
117
118 echo -e "battery\t$bat_status $bat_lvl%%%{F-}"
119 else
120 echo -e "battery\toff"
121 fi
122}
123
124clock()
125{
126 echo -e $(date +$"date\t%{F$acolor_fg}%H:%M:%S %{F$acolor_fg}(%d-%m-%Y)%{F-}")
127}
diff --git a/herbstluftwm/.config/herbstluftwm/popup.sh b/herbstluftwm/.config/herbstluftwm/popup.sh
index 41c5e9c..eda37f5 100755
--- a/herbstluftwm/.config/herbstluftwm/popup.sh
+++ b/herbstluftwm/.config/herbstluftwm/popup.sh
@@ -7,29 +7,20 @@ help () {
7 echo -e "Options:" 7 echo -e "Options:"
8 echo -e " -m MESSAGE\t\tSpecifies message to be displayed" 8 echo -e " -m MESSAGE\t\tSpecifies message to be displayed"
9 echo -e " -t TIMEOUT\t\tAmount of time in seconds the popup is displayed" 9 echo -e " -t TIMEOUT\t\tAmount of time in seconds the popup is displayed"
10 echo -e " -u LEVEL\t\tUrgency level (info or high)"
10} 11}
11 12
12add_alpha_channel(){ 13dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
13 echo "$1" | \ 14source "$dir/theme.sh"
14 sed "s/.*#\([0-9a-fA-F]*\).*/#ff\1/"
15}
16 15
17timeout=10 16timeout=10
18message="" 17message=""
19x=0
20y=0
21width=120
22height=90
23urgency="info" 18urgency="info"
24 19
25while getopts ":m:t:x:y:w:h:u:" opt; do 20while getopts ":m:t:x:y:w:h:u:" opt; do
26 case $opt in 21 case $opt in
27 m) message=$OPTARG ;; 22 m) message=$OPTARG ;;
28 t) timeout=$OPTARG ;; 23 t) timeout=$OPTARG ;;
29 x) x=$OPTARG ;;
30 y) y=$OPTARG ;;
31 w) width=$OPTARG ;;
32 h) height=$OPTARG ;;
33 u) urgency=$OPTARG ;; 24 u) urgency=$OPTARG ;;
34 esac 25 esac
35done 26done
@@ -37,13 +28,8 @@ done
37if test ! $message; then 28if test ! $message; then
38 help 29 help
39else 30else
40 light=$(add_alpha_channel $WM_LIGHT) 31
41 llight=$(add_alpha_channel $WM_LLIGHT) 32 bar_opts="-f $font,$font_sec -B $acolor_bg -F $acolor_fg -g ${popup_width}x${height}+${popup_x}+${popup_y} -u 2"
42 accent=$(add_alpha_channel $WM_ACCENT)
43 ldark=$(add_alpha_channel $WM_LDARK)
44 dark=$(add_alpha_channel $WM_DARK)
45 font="-*-fixed-medium-*-*-*-$(echo "$height - 10" | bc)-*-*-*-*-*-*-*"
46 bar_opts="-f ${font} -B $dark -F $light -g ${width}x${height}+${x}+${y} -u 2"
47 33
48 t=$(date +%T) 34 t=$(date +%T)
49 35
@@ -54,7 +40,7 @@ else
54 fi 40 fi
55 41
56 { 42 {
57 echo "%{F$accent} $prefix %{F$light}$message %{F$llight}($t)%{F-}" 43 echo "%{F$acolor_accent} $prefix %{F$acolor_fg}$message %{F$acolor_fg}($t)%{F-}"
58 sleep $timeout 44 sleep $timeout
59 } | bar $bar_opts 45 } | bar $bar_opts
60fi 46fi
diff --git a/herbstluftwm/.config/herbstluftwm/theme b/herbstluftwm/.config/herbstluftwm/theme.sh
index 810c5d2..bcbc6f7 100644
--- a/herbstluftwm/.config/herbstluftwm/theme
+++ b/herbstluftwm/.config/herbstluftwm/theme.sh
@@ -1,5 +1,3 @@
1#!/bin/bash
2
3# Get color from ~/.Xresources 1# Get color from ~/.Xresources
4get_x_color() { 2get_x_color() {
5 xresources=$(cat ~/.Xresources) 3 xresources=$(cat ~/.Xresources)
diff --git a/liquidprompt/.lp_ps1 b/liquidprompt/.lp_ps1
index 821dcf7..93987bb 100755
--- a/liquidprompt/.lp_ps1
+++ b/liquidprompt/.lp_ps1
@@ -22,7 +22,7 @@
22# Remember that most features come with their corresponding colors, 22# Remember that most features come with their corresponding colors,
23# see the README. 23# see the README.
24 24
25LP_PS1="[\d][\t]\u on \h\n\w${LP_VCS}${LP_MARK}" 25LP_PS1="[\d][\t]\u on \h\n\w${LP_VCS} ${LP_MARK}"
26 26
27LP_TITLE=$(_lp_title $PS1) 27LP_TITLE=$(_lp_title $PS1)
28PS1="${LP_TITLE}${PS1}" 28PS1="${LP_TITLE}${PS1}"