Skip to content

Commit 7c882d8

Browse files
Merge branch 'dracula:master' into feature/custom-colors
2 parents a1c3faf + 66e0910 commit 7c882d8

File tree

11 files changed

+169
-59
lines changed

11 files changed

+169
-59
lines changed

β€Žscripts/battery.shβ€Ž

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ battery_percent()
4141
case $(uname -s) in
4242
Linux)
4343
percent=$(linux_acpi percent)
44-
[ -n "$percent" ] && echo " $percent"
44+
[ -n "$percent" ] && echo "$percent%"
4545
;;
4646

4747
Darwin)
@@ -112,17 +112,17 @@ battery_status()
112112
charging|Charging)
113113
# charging from AC
114114
declare -A battery_labels=(
115-
[0]="ξ€Šσ°‚Ž"
116-
[10]="ξ€Šσ°Ί"
117-
[20]="ξ€Šσ°»"
118-
[30]="ξ€Šσ°Ό"
119-
[40]="ξ€Šσ°½"
120-
[50]="ξ€Šσ°Ύ"
121-
[60]="ξ€Šσ°Ώ"
122-
[70]="ξ€Šσ°‚€"
123-
[80]="ξ€Šσ°‚"
124-
[90]="ξ€Šσ°‚‚"
125-
[100]="ξ€Šσ°Ή"
115+
[0]="󰒟"
116+
[10]="󰒜"
117+
[20]="󰂆"
118+
[30]="󰂇"
119+
[40]="σ°‚ˆ"
120+
[50]="󰒝"
121+
[60]="󰂉"
122+
[70]="󰒞"
123+
[80]="σ°‚Š"
124+
[90]="σ°‚‹"
125+
[100]="σ°‚…"
126126
)
127127
echo "${battery_labels[$((bat_perc/10*10))]:-󰂃}"
128128
;;
@@ -131,7 +131,7 @@ battery_status()
131131
echo 'ξ€Š'
132132
;;
133133
finishingcharge)
134-
echo 'ξ€Šσ°Ή'
134+
echo 'σ°‚…'
135135
;;
136136
*)
137137
# something wrong...
@@ -175,4 +175,3 @@ main()
175175

176176
#run main driver program
177177
main
178-

β€Žscripts/dracula.shβ€Ž

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ main()
99
{
1010
# set configuration option variables
1111
show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "")
12+
show_only_kubernetes_context=$(get_tmux_option "@dracula-show-only-kubernetes-context" "")
1213
eks_hide_arn=$(get_tmux_option "@dracula-kubernetes-eks-hide-arn" false)
1314
eks_extract_account=$(get_tmux_option "@dracula-kubernetes-eks-extract-account" false)
1415
hide_kubernetes_user=$(get_tmux_option "@dracula-kubernetes-hide-user" false)
@@ -231,7 +232,7 @@ main()
231232

232233
elif [ $plugin = "kubernetes-context" ]; then
233234
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray")
234-
script="#($current_dir/kubernetes_context.sh $eks_hide_arn $eks_extract_account $hide_kubernetes_user $show_kubernetes_context_label)"
235+
script="#($current_dir/kubernetes_context.sh $eks_hide_arn $eks_extract_account $hide_kubernetes_user $show_only_kubernetes_context $show_kubernetes_context_label)"
235236

236237
elif [ $plugin = "terraform" ]; then
237238
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-terraform-colors" "light_purple dark_gray")
@@ -253,7 +254,7 @@ main()
253254
if $show_day_month && $show_military ; then # military time and dd/mm
254255
script="%a %d/%m %R ${timezone} "
255256
elif $show_military; then # only military time
256-
script="%a %m/%d %R ${timezone} "
257+
script="%R ${timezone} "
257258
elif $show_day_month; then # only dd/mm
258259
script="%a %d/%m %I:%M %p ${timezone} "
259260
else

β€Žscripts/gpu_power.shβ€Ž

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,48 @@ get_platform()
99
{
1010
case $(uname -s) in
1111
Linux)
12-
# use this option for when you know that there is an NVIDIA gpu, but you cant use lspci to determine
13-
ignore_lspci=$(get_tmux_option "@dracula-ignore-lspci" false)
14-
if [[ "$ignore_lspci" = true ]]; then
15-
echo "NVIDIA"
12+
# use this option for when your gpu isn't detected
13+
gpu_label=$(get_tmux_option "@dracula-force-gpu" false)
14+
if [[ "$gpu_label" != false ]]; then
15+
echo $gpu_label
1616
else
17+
# attempt to detect the gpu
1718
gpu=$(lspci -v | grep VGA | head -n 1 | awk '{print $5}')
18-
echo $gpu
19+
if [[ -n $gpu ]]; then
20+
# if a gpu is detected, return it
21+
echo $gpu
22+
elif type -a nvidia-smi >> /dev/null; then
23+
# if no gpu was detected, and nvidia-smi is installed, we'll still try nvidia
24+
echo "NVIDIA"
25+
fi
1926
fi
2027
;;
2128

2229
Darwin)
23-
# TODO - Darwin/Mac compatability
30+
# WARNING: for this to work the powermetrics command needs to be run without password
31+
# add this to the sudoers file, replacing the username and omitting the quotes.
32+
# be mindful of the tabs: "username ALL = (root) NOPASSWD: /usr/bin/powermetrics"
33+
echo "apple"
2434
;;
2535

2636
CYGWIN*|MINGW32*|MSYS*|MINGW*)
2737
# TODO - windows compatability
2838
;;
2939
esac
3040
}
31-
3241
get_gpu()
3342
{
3443
gpu=$(get_platform)
44+
gpu_power_percent=$(get_tmux_option "@dracula-gpu-power-percent" false)
3545
if [[ "$gpu" == NVIDIA ]]; then
36-
usage=$(nvidia-smi --query-gpu=power.draw,power.limit --format=csv,noheader,nounits | awk '{ draw += $0; max +=$2 } END { printf("%dW/%dW\n", draw, max) }')
46+
if $gpu_power_percent; then
47+
usage=$(nvidia-smi --query-gpu=power.draw,power.limit --format=csv,noheader,nounits | awk '{ draw += $0; max +=$2 } END { printf("%d%%\n", draw / max * 100) }')
48+
else
49+
usage=$(nvidia-smi --query-gpu=power.draw,power.limit --format=csv,noheader,nounits | awk '{ draw += $0; max +=$2 } END { printf("%dW/%dW\n", draw, max) }')
50+
fi
3751

52+
elif [[ "$gpu" == apple ]]; then
53+
usage="$(sudo powermetrics --samplers gpu_power -i500 -n 1 | grep 'GPU Power' | sed 's/GPU Power: \(.*\) \(.*\)/\1\2/g')"
3854
else
3955
usage='unknown'
4056
fi
@@ -45,7 +61,7 @@ main()
4561
{
4662
# storing the refresh rate in the variable RATE, default is 5
4763
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
48-
gpu_label=$(get_tmux_option "@dracula-gpu-usage-label" "GPU")
64+
gpu_label=$(get_tmux_option "@dracula-gpu-power-label" "GPU")
4965
gpu_usage=$(get_gpu)
5066
echo "$gpu_label $gpu_usage"
5167
sleep $RATE

β€Žscripts/gpu_ram_info.shβ€Ž

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,20 @@ get_platform()
99
{
1010
case $(uname -s) in
1111
Linux)
12-
# use this option for when you know that there is an NVIDIA gpu, but you cant use lspci to determine
13-
ignore_lspci=$(get_tmux_option "@dracula-ignore-lspci" false)
14-
if [[ "$ignore_lspci" = true ]]; then
15-
echo "NVIDIA"
12+
# use this option for when your gpu isn't detected
13+
gpu_label=$(get_tmux_option "@dracula-force-gpu" false)
14+
if [[ "$gpu_label" != false ]]; then
15+
echo $gpu_label
1616
else
17+
# attempt to detect the gpu
1718
gpu=$(lspci -v | grep VGA | head -n 1 | awk '{print $5}')
18-
echo $gpu
19+
if [[ -n $gpu ]]; then
20+
# if a gpu is detected, return it
21+
echo $gpu
22+
elif type -a nvidia-smi >> /dev/null; then
23+
# if no gpu was detected, and nvidia-smi is installed, we'll still try nvidia
24+
echo "NVIDIA"
25+
fi
1926
fi
2027
;;
2128

@@ -32,19 +39,29 @@ get_platform()
3239
get_gpu()
3340
{
3441
gpu=$(get_platform)
42+
gpu_vram_percent=$(get_tmux_option "@dracula-gpu-vram-percent" false)
3543
if [[ "$gpu" == NVIDIA ]]; then
36-
usage=$(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk '{ used += $0; total +=$2 } END { printf("%dGB/%dGB\n", used / 1024, total / 1024) }')
44+
if $gpu_vram_percent; then
45+
usage=$(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk '{ used += $0; total +=$2 } END { printf("%d%%\n", used / total * 100 ) }')
46+
normalize_percent_len $usage
47+
exit 0
48+
else
49+
# to add finer grained info
50+
used_accuracy=$(get_tmux_option "@dracula-gpu-vram-used-accuracy" "d")
51+
total_accuracy=$(get_tmux_option "@dracula-gpu-vram-total-accuracy" "d")
52+
usage=$(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk "{ used += \$0; total +=\$2 } END { printf(\"%${used_accuracy}GB/%${total_accuracy}GB\n\", used / 1024, total / 1024) }")
53+
fi
3754
else
3855
usage='unknown'
3956
fi
40-
normalize_percent_len $usage
57+
echo $usage
4158
}
4259

4360
main()
4461
{
4562
# storing the refresh rate in the variable RATE, default is 5
4663
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
47-
gpu_label=$(get_tmux_option "@dracula-gpu-usage-label" "VRAM")
64+
gpu_label=$(get_tmux_option "@dracula-gpu-vram-label" "VRAM")
4865
gpu_usage=$(get_gpu)
4966
echo "$gpu_label $gpu_usage"
5067
sleep $RATE

β€Žscripts/gpu_usage.shβ€Ž

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,28 @@ get_platform()
99
{
1010
case $(uname -s) in
1111
Linux)
12-
# use this option for when you know that there is an NVIDIA gpu, but you cant use lspci to determine
13-
ignore_lspci=$(get_tmux_option "@dracula-ignore-lspci" false)
14-
if [[ "$ignore_lspci" = true ]]; then
15-
echo "NVIDIA"
12+
# use this option for when your gpu isn't detected
13+
gpu_label=$(get_tmux_option "@dracula-force-gpu" false)
14+
if [[ "$gpu_label" != false ]]; then
15+
echo $gpu_label
1616
else
17+
# attempt to detect the gpu
1718
gpu=$(lspci -v | grep VGA | head -n 1 | awk '{print $5}')
18-
echo $gpu
19+
if [[ -n $gpu ]]; then
20+
# if a gpu is detected, return it
21+
echo $gpu
22+
elif type -a nvidia-smi >> /dev/null; then
23+
# if no gpu was detected, and nvidia-smi is installed, we'll still try nvidia
24+
echo "NVIDIA"
25+
fi
1926
fi
2027
;;
2128

2229
Darwin)
23-
# TODO - Darwin/Mac compatability
30+
# WARNING: for this to work the powermetrics command needs to be run without password
31+
# add this to the sudoers file, replacing the username and omitting the quotes.
32+
# be mindful of the tabs: "username ALL = (root) NOPASSWD: /usr/bin/powermetrics"
33+
echo "apple"
2434
;;
2535

2636
CYGWIN*|MINGW32*|MSYS*|MINGW*)
@@ -34,6 +44,8 @@ get_gpu()
3444
gpu=$(get_platform)
3545
if [[ "$gpu" == NVIDIA ]]; then
3646
usage=$(nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits | awk '{ sum += $0 } END { printf("%d%%\n", sum / NR) }')
47+
elif [[ "$gpu" == apple ]]; then
48+
usage="$(sudo powermetrics --samplers gpu_power -i500 -n 1 | grep 'active residency' | sed 's/[^0-9.%]//g' | sed 's/[%].*$//g')%"
3749
else
3850
usage='unknown'
3951
fi

β€Žscripts/kubernetes_context.shβ€Ž

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export LC_ALL=en_US.UTF-8
55
hide_arn_from_cluster=$1
66
extract_account=$2
77
hide_user=$3
8-
label=$4
8+
just_current_context=$4
9+
label=$5
910

1011
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
1112
source $current_dir/utils.sh
@@ -34,6 +35,19 @@ main()
3435
# storing the refresh rate in the variable RATE, default is 5
3536
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
3637
OUTPUT_STRING=""
38+
39+
if [ "$just_current_context" = "true" ]
40+
then
41+
echo "$current_context"
42+
else
43+
getFullMessage
44+
fi
45+
46+
sleep $RATE
47+
}
48+
49+
getFullMessage()
50+
{
3751
if [ ! -z "$current_account_id" ]
3852
then
3953
OUTPUT_STRING="${current_account_id}/"
@@ -65,8 +79,6 @@ main()
6579
else
6680
echo "${label} ${OUTPUT_STRING}"
6781
fi
68-
69-
sleep $RATE
7082
}
7183

7284
# run the main driver

β€Žscripts/network.shβ€Ž

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@
22
# setting the locale, some users have issues with different locales, this forces the correct one
33
export LC_ALL=en_US.UTF-8
44

5-
HOSTS="google.com github.com example.com"
5+
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
6+
source $current_dir/utils.sh
7+
8+
# set your own hosts so that a wifi is recognised even without internet access
9+
HOSTS=$(get_tmux_option "@dracula-network-hosts" "google.com github.com example.com")
610

711
get_ssid()
812
{
@@ -11,17 +15,18 @@ get_ssid()
1115
Linux)
1216
SSID=$(iw dev | sed -nr 's/^\t\tssid (.*)/\1/p')
1317
if [ -n "$SSID" ]; then
14-
printf '%s' "$SSID"
18+
printf '%s' "$wifi_label$SSID"
1519
else
16-
echo 'Ethernet'
20+
echo "$(get_tmux_option "@dracula-network-ethernet-label" "Ethernet")"
1721
fi
1822
;;
1923

2024
Darwin)
2125
if networksetup -getairportnetwork en0 | cut -d ':' -f 2 | sed 's/^[[:blank:]]*//g' &> /dev/null; then
22-
echo "$(networksetup -getairportnetwork en0 | cut -d ':' -f 2)" | sed 's/^[[:blank:]]*//g'
26+
wifi_label=$(get_tmux_option "@dracula-network-wifi-label" "")
27+
echo "$wifi_label$(networksetup -getairportnetwork en0 | cut -d ':' -f 2)" | sed 's/^[[:blank:]]*//g'
2328
else
24-
echo 'Ethernet'
29+
echo "$(get_tmux_option "@dracula-network-ethernet-label" "Ethernet")"
2530
fi
2631
;;
2732

@@ -37,7 +42,7 @@ get_ssid()
3742

3843
main()
3944
{
40-
network="Offline"
45+
network="$(get_tmux_option "@dracula-network-offline-label" "Offline")"
4146
for host in $HOSTS; do
4247
if ping -q -c 1 -W 1 $host &>/dev/null; then
4348
network="$(get_ssid)"

β€Žscripts/network_bandwidth.shβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ main() {
112112
IFS=" " read -ra bandwidth <<<"$(get_bandwidth "$network_name")"
113113

114114
if [[ $show_interface == "true" ]]; then echo -n "[$network_name] "; fi
115-
echo "↓ $(bandwidth_to_unit "${bandwidth[$DOWNLOAD]}") β€’ ↑ $(bandwidth_to_unit "${bandwidth[$UPLOAD]}")"
115+
printf "↓ %6s %-4s β€’ ↑ %6s %-4s\n" $(bandwidth_to_unit "${bandwidth[$DOWNLOAD]}") $(bandwidth_to_unit "${bandwidth[$UPLOAD]}")
116116

117117
((counter = counter - 1))
118118
sleep "$interval_update"

0 commit comments

Comments
Β (0)