commit
cd5e751419
12 changed files with 550 additions and 493 deletions
5
.editorconfig
Normal file
5
.editorconfig
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
[*]
|
||||||
|
indent_size = 2
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = true
|
||||||
|
trim_trailing_whitespace = true
|
141
INSTALL.md
141
INSTALL.md
|
@ -44,25 +44,122 @@ programs.tmux = {
|
||||||
|
|
||||||
#### Configuration
|
#### Configuration
|
||||||
|
|
||||||
Customize the status bar by adding any of these lines to your .tmux.conf as desired:
|
To enable plugins set up the `@dracula-plugins` option in you `.tmux.conf` file, separate plugin by space.
|
||||||
* Disable battery functionality: `set -g @dracula-show-battery false`
|
The order that you define the plugins will be the order on the status bar left to right.
|
||||||
* Disable network functionality: `set -g @dracula-show-network false`
|
|
||||||
* Enable network bandwith functionality: `set -g @dracula-network-bandwith $network_name`
|
```bash
|
||||||
- You could get the `$network_name` through the command: `sudo lshw -class network -short | grep wl | awk '{print $2}'`
|
# available plugins: battery, cpu-usage, gpu-usage, ram-usage, network, network-bandwith, weather, time
|
||||||
* Disable weather functionality: `set -g @dracula-show-weather false`
|
set -g @dracula-plugins "cpu-usage gpu-usage ram-usage"
|
||||||
* Disable time functionality: `set -g @dracula-show-time false`
|
```
|
||||||
* Disable location information: `set -g @dracula-show-location false`
|
|
||||||
* Switch from default fahrenheit to celsius: `set -g @dracula-show-fahrenheit false`
|
For each plugin is possible to customize background and foreground colors
|
||||||
* Enable powerline symbols: `set -g @dracula-show-powerline true`
|
|
||||||
* Switch powerline symbols `set -g @dracula-show-left-sep ` for left and `set -g @dracula-show-right-sep ` for right symbol (can set any symbol you like as seperator)
|
```bash
|
||||||
* Enable window flags: `set -g @dracula-show-flags true`
|
# available colors: white, gray, dark_gray, light_purple, dark_purple, cyan, green, orange, red, pink, yellow
|
||||||
* Adjust the refresh rate for the bar `set -g @dracula-refresh-rate 5` the default is 5, it can accept any number
|
# set -g @dracula-[plugin-name]-colors "[background] [foreground]"
|
||||||
* Enable military time: `set -g @dracula-military-time true`
|
set -g @dracula-cpu-usage-colors "pink dark_gray"
|
||||||
* Disable timezone: `set -g @dracula-show-timezone false`
|
```
|
||||||
* Switch the left smiley icon `set -g @dracula-show-left-icon session` it can accept `session`, `smiley`, `window`, or any character.
|
|
||||||
* Add padding to the left smiley icon `set -g @dracula-left-icon-padding` default is 1, it can accept any number and 0 disables padding.
|
#### Status bar options
|
||||||
* Enable high contrast pane border: `set -g @dracula-border-contrast true`
|
|
||||||
* Enable cpu usage: `set -g @dracula-cpu-usage true`
|
Enable powerline symbols
|
||||||
* Enable ram usage: `set -g @dracula-ram-usage true`
|
|
||||||
* Enable gpu usage: `set -g @dracula-gpu-usage true`
|
```bash
|
||||||
* Swap date to day/month `set -g @dracula-day-month true`
|
set -g @dracula-show-powerline true
|
||||||
|
```
|
||||||
|
|
||||||
|
Switch powerline symbols
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# for left
|
||||||
|
set -g @dracula-show-left-sep
|
||||||
|
|
||||||
|
# for right symbol (can set any symbol you like as seperator)
|
||||||
|
set -g @dracula-show-right-sep
|
||||||
|
```
|
||||||
|
|
||||||
|
Enable window flags
|
||||||
|
|
||||||
|
```bash
|
||||||
|
set -g @dracula-show-flags true
|
||||||
|
```
|
||||||
|
|
||||||
|
Adjust the refresh rate for the status bar
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# the default is 5, it can accept any number
|
||||||
|
set -g @dracula-refresh-rate 5
|
||||||
|
```
|
||||||
|
|
||||||
|
Switch the left smiley icon
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# it can accept `session`, `smiley`, `window`, or any character.
|
||||||
|
set -g @dracula-show-left-icon session
|
||||||
|
```
|
||||||
|
|
||||||
|
Add padding to the left smiley icon
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# default is 1, it can accept any number and 0 disables padding.
|
||||||
|
set -g @dracula-left-icon-padding 1
|
||||||
|
```
|
||||||
|
|
||||||
|
Enable high contrast pane border
|
||||||
|
|
||||||
|
```bash
|
||||||
|
set -g @dracula-border-contrast true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### cpu-usage options
|
||||||
|
|
||||||
|
Customize label
|
||||||
|
|
||||||
|
```bash
|
||||||
|
set -g @dracula-cpu-usage-label "CPU"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### gpu-usage options
|
||||||
|
|
||||||
|
Customize label
|
||||||
|
|
||||||
|
```bash
|
||||||
|
set -g @dracula-gpu-usage-label "GPU"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### ram-usage options
|
||||||
|
|
||||||
|
Customize label
|
||||||
|
|
||||||
|
```bash
|
||||||
|
set -g @dracula-ram-usage-label "RAM"
|
||||||
|
```
|
||||||
|
|
||||||
|
#### time options
|
||||||
|
|
||||||
|
Disable timezone
|
||||||
|
|
||||||
|
```bash
|
||||||
|
set -g @dracula-show-timezone false
|
||||||
|
```
|
||||||
|
|
||||||
|
Swap date to day/month
|
||||||
|
|
||||||
|
```bash
|
||||||
|
set -g @dracula-day-month true
|
||||||
|
```
|
||||||
|
|
||||||
|
Enable military time
|
||||||
|
|
||||||
|
```bash
|
||||||
|
set -g @dracula-military-time true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### weather options
|
||||||
|
|
||||||
|
Switch from default fahrenheit to celsius
|
||||||
|
|
||||||
|
```bash
|
||||||
|
set -g @dracula-show-fahrenheit false
|
||||||
|
```
|
||||||
|
|
||||||
|
|
|
@ -2,29 +2,8 @@
|
||||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||||
export LC_ALL=en_US.UTF-8
|
export LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
# function for getting the refresh rate
|
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
get_tmux_option() {
|
source $current_dir/utils.sh
|
||||||
local option=$1
|
|
||||||
local default_value=$2
|
|
||||||
local option_value=$(tmux show-option -gqv "$option")
|
|
||||||
if [ -z $option_value ]; then
|
|
||||||
echo $default_value
|
|
||||||
else
|
|
||||||
echo $option_value
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# normalize the percentage string to always have a length of 5
|
|
||||||
normalize_percent_len() {
|
|
||||||
# the max length that the percent can reach, which happens for a two digit number with a decimal house: "99.9%"
|
|
||||||
max_len=5
|
|
||||||
percent_len=${#1}
|
|
||||||
let diff_len=$max_len-$percent_len
|
|
||||||
# if the diff_len is even, left will have 1 more space than right
|
|
||||||
let left_spaces=($diff_len+1)/2
|
|
||||||
let right_spaces=($diff_len)/2
|
|
||||||
printf "%${left_spaces}s%s%${right_spaces}s\n" "" $1 ""
|
|
||||||
}
|
|
||||||
|
|
||||||
get_percent()
|
get_percent()
|
||||||
{
|
{
|
||||||
|
@ -52,8 +31,9 @@ main()
|
||||||
{
|
{
|
||||||
# storing the refresh rate in the variable RATE, default is 5
|
# storing the refresh rate in the variable RATE, default is 5
|
||||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||||
|
cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU")
|
||||||
cpu_percent=$(get_percent)
|
cpu_percent=$(get_percent)
|
||||||
echo "CPU $cpu_percent"
|
echo "$cpu_label $cpu_percent"
|
||||||
sleep $RATE
|
sleep $RATE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,28 +2,14 @@
|
||||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||||
export LC_ALL=en_US.UTF-8
|
export LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
get_tmux_option() {
|
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
local option=$1
|
source $current_dir/utils.sh
|
||||||
local default_value=$2
|
|
||||||
local option_value=$(tmux show-option -gqv "$option")
|
|
||||||
if [ -z $option_value ]; then
|
|
||||||
echo $default_value
|
|
||||||
else
|
|
||||||
echo $option_value
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
datafile=/tmp/.dracula-tmux-data
|
datafile=/tmp/.dracula-tmux-data
|
||||||
|
|
||||||
# set current directory variable
|
|
||||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
|
|
||||||
# set configuration option variables
|
# set configuration option variables
|
||||||
show_battery=$(get_tmux_option "@dracula-show-battery" true)
|
|
||||||
show_network=$(get_tmux_option "@dracula-show-network" true)
|
|
||||||
show_weather=$(get_tmux_option "@dracula-show-weather" true)
|
|
||||||
show_fahrenheit=$(get_tmux_option "@dracula-show-fahrenheit" true)
|
show_fahrenheit=$(get_tmux_option "@dracula-show-fahrenheit" true)
|
||||||
show_location=$(get_tmux_option "@dracula-show-location" true)
|
show_location=$(get_tmux_option "@dracula-show-location" true)
|
||||||
show_powerline=$(get_tmux_option "@dracula-show-powerline" false)
|
show_powerline=$(get_tmux_option "@dracula-show-powerline" false)
|
||||||
|
@ -35,13 +21,9 @@ main()
|
||||||
show_left_sep=$(get_tmux_option "@dracula-show-left-sep" )
|
show_left_sep=$(get_tmux_option "@dracula-show-left-sep" )
|
||||||
show_right_sep=$(get_tmux_option "@dracula-show-right-sep" )
|
show_right_sep=$(get_tmux_option "@dracula-show-right-sep" )
|
||||||
show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false)
|
show_border_contrast=$(get_tmux_option "@dracula-border-contrast" false)
|
||||||
show_cpu_usage=$(get_tmux_option "@dracula-cpu-usage" false)
|
|
||||||
show_ram_usage=$(get_tmux_option "@dracula-ram-usage" false)
|
|
||||||
show_gpu_usage=$(get_tmux_option "@dracula-gpu-usage" false)
|
|
||||||
show_day_month=$(get_tmux_option "@dracula-day-month" false)
|
show_day_month=$(get_tmux_option "@dracula-day-month" false)
|
||||||
show_time=$(get_tmux_option "@dracula-show-time" true)
|
|
||||||
show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5)
|
show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||||
show_network_bandwith=$(get_tmux_option "@dracula-network-bandwith" "")
|
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather")
|
||||||
|
|
||||||
# Dracula Color Pallette
|
# Dracula Color Pallette
|
||||||
white='#f8f8f2'
|
white='#f8f8f2'
|
||||||
|
@ -83,7 +65,7 @@ main()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# start weather script in background
|
# start weather script in background
|
||||||
if $show_weather; then
|
if [[ "${plugins[@]}" =~ "weather" ]]; then
|
||||||
$current_dir/sleep_weather.sh $show_fahrenheit $show_location &
|
$current_dir/sleep_weather.sh $show_fahrenheit $show_location &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -132,117 +114,88 @@ main()
|
||||||
# status bar
|
# status bar
|
||||||
tmux set-option -g status-style "bg=${gray},fg=${white}"
|
tmux set-option -g status-style "bg=${gray},fg=${white}"
|
||||||
|
|
||||||
|
# Status left
|
||||||
|
if $show_powerline; then
|
||||||
|
tmux set-option -g status-left "#[bg=${green},fg=${dark_gray}]#{?client_prefix,#[bg=${yellow}],} ${left_icon} #[fg=${green},bg=${gray}]#{?client_prefix,#[fg=${yellow}],}${left_sep}"
|
||||||
|
powerbg=${gray}
|
||||||
|
else
|
||||||
|
tmux set-option -g status-left "#[bg=${green},fg=${dark_gray}]#{?client_prefix,#[bg=${yellow}],} ${left_icon}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Status right
|
||||||
|
tmux set-option -g status-right ""
|
||||||
|
|
||||||
|
for plugin in "${plugins[@]}"; do
|
||||||
|
if [ $plugin = "battery" ]; then
|
||||||
|
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-battery-colors" "pink dark_gray")
|
||||||
|
script="#($current_dir/battery.sh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $plugin = "gpu-usage" ]; then
|
||||||
|
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-gpu-usage-colors" "pink dark_gray")
|
||||||
|
script="#($current_dir/gpu_usage.sh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $plugin = "cpu-usage" ]; then
|
||||||
|
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-cpu-usage-colors" "orange dark_gray")
|
||||||
|
script="#($current_dir/cpu_info.sh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $plugin = "ram-usage" ]; then
|
||||||
|
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-ram-usage-colors" "cyan dark_gray")
|
||||||
|
script="#($current_dir/ram_info.sh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $plugin = "network" ]; then
|
||||||
|
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-network-colors" "cyan dark_gray")
|
||||||
|
script="#($current_dir/network.sh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $plugin = "network-bandwith" ]; then
|
||||||
|
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-network-bandwith-colors" "cyan dark_gray")
|
||||||
|
tmux set-option -g status-right-length 250
|
||||||
|
script="#($current_dir/network_bandwith.sh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $plugin = "weather" ]; then
|
||||||
# wait unit $datafile exists just to avoid errors
|
# wait unit $datafile exists just to avoid errors
|
||||||
# this should almost never need to wait unless something unexpected occurs
|
# this should almost never need to wait unless something unexpected occurs
|
||||||
while $show_weather && [ ! -f $datafile ]; do
|
while [ ! -f $datafile ]; do
|
||||||
sleep 0.01
|
sleep 0.01
|
||||||
done
|
done
|
||||||
|
|
||||||
# Powerline Configuration
|
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-weather-colors" "orange dark_gray")
|
||||||
|
script="#(cat $datafile)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $plugin = "time" ]; then
|
||||||
|
IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-weather-colors" "dark_purple white")
|
||||||
|
if $show_day_month && $show_military ; then # military time and dd/mm
|
||||||
|
script="%a %d/%m %R ${timezone} "
|
||||||
|
elif $show_military; then # only military time
|
||||||
|
script="%a %m/%d %R ${timezone} "
|
||||||
|
elif $show_day_month; then # only dd/mm
|
||||||
|
script="%a %d/%m %I:%M %p ${timezone} "
|
||||||
|
else
|
||||||
|
script="%a %m/%d %I:%M %p ${timezone} "
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if $show_powerline; then
|
if $show_powerline; then
|
||||||
|
tmux set-option -ga status-right "#[fg=${!colors[0]},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${!colors[1]},bg=${!colors[0]}] $script"
|
||||||
tmux set-option -g status-left "#[bg=${green},fg=${dark_gray}]#{?client_prefix,#[bg=${yellow}],} ${left_icon} #[fg=${green},bg=${gray}]#{?client_prefix,#[fg=${yellow}],}${left_sep}"
|
powerbg=${!colors[0]}
|
||||||
tmux set-option -g status-right ""
|
|
||||||
powerbg=${gray}
|
|
||||||
|
|
||||||
if $show_battery; then # battery
|
|
||||||
tmux set-option -g status-right "#[fg=${pink},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${pink}] #($current_dir/battery.sh)"
|
|
||||||
powerbg=${pink}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $show_ram_usage; then
|
|
||||||
tmux set-option -ga status-right "#[fg=${cyan},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${cyan}] #($current_dir/ram_info.sh)"
|
|
||||||
powerbg=${cyan}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $show_cpu_usage; then
|
|
||||||
tmux set-option -ga status-right "#[fg=${orange},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${orange}] #($current_dir/cpu_info.sh)"
|
|
||||||
powerbg=${orange}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $show_gpu_usage; then
|
|
||||||
tmux set-option -ga status-right "#[fg=${pink},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${pink}] #($current_dir/gpu_usage.sh)"
|
|
||||||
powerbg=${pink}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $show_network; then # network
|
|
||||||
tmux set-option -ga status-right "#[fg=${cyan},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${cyan}] #($current_dir/network.sh)"
|
|
||||||
powerbg=${cyan}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$show_network_bandwith" != "" ]]; then # network bandwith
|
|
||||||
tmux set-option -g status-right-length 250
|
|
||||||
tmux set-option -ga status-right "#[fg=${green},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${green}] #($current_dir/network_bandwith.sh)"
|
|
||||||
powerbg=${green}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $show_weather; then # weather
|
|
||||||
tmux set-option -ga status-right "#[fg=${orange},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${dark_gray},bg=${orange}] #(cat $datafile)"
|
|
||||||
powerbg=${orange}
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $show_time; then
|
|
||||||
if $show_day_month && $show_military ; then # military time and dd/mm
|
|
||||||
tmux set-option -ga status-right "#[fg=${dark_purple},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${white},bg=${dark_purple}] %a %d/%m %R ${timezone} "
|
|
||||||
elif $show_military; then # only military time
|
|
||||||
tmux set-option -ga status-right "#[fg=${dark_purple},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${white},bg=${dark_purple}] %a %m/%d %R ${timezone} "
|
|
||||||
elif $show_day_month; then # only dd/mm
|
|
||||||
tmux set-option -ga status-right "#[fg=${dark_purple},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${white},bg=${dark_purple}] %a %d/%m %I:%M %p ${timezone} "
|
|
||||||
else
|
else
|
||||||
tmux set-option -ga status-right "#[fg=${dark_purple},bg=${powerbg},nobold,nounderscore,noitalics] ${right_sep}#[fg=${white},bg=${dark_purple}] %a %m/%d %I:%M %p ${timezone} "
|
tmux set-option -ga status-right "#[fg=${!colors[1]},bg=${!colors[0]}] $script"
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
tmux set-option -ga status-right " "
|
||||||
|
|
||||||
|
# Window option
|
||||||
|
if $show_powerline; then
|
||||||
tmux set-window-option -g window-status-current-format "#[fg=${gray},bg=${dark_purple}]${left_sep}#[fg=${white},bg=${dark_purple}] #I #W${current_flags} #[fg=${dark_purple},bg=${gray}]${left_sep}"
|
tmux set-window-option -g window-status-current-format "#[fg=${gray},bg=${dark_purple}]${left_sep}#[fg=${white},bg=${dark_purple}] #I #W${current_flags} #[fg=${dark_purple},bg=${gray}]${left_sep}"
|
||||||
|
|
||||||
# Non Powerline Configuration
|
|
||||||
else
|
else
|
||||||
tmux set-option -g status-left "#[bg=${green},fg=${dark_gray}]#{?client_prefix,#[bg=${yellow}],} ${left_icon}"
|
|
||||||
|
|
||||||
tmux set-option -g status-right ""
|
|
||||||
|
|
||||||
if $show_battery; then # battery
|
|
||||||
tmux set-option -g status-right "#[fg=${dark_gray},bg=${pink}] #($current_dir/battery.sh) "
|
|
||||||
fi
|
|
||||||
if $show_ram_usage; then
|
|
||||||
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${cyan}] #($current_dir/ram_info.sh) "
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $show_cpu_usage; then
|
|
||||||
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${orange}] #($current_dir/cpu_info.sh) "
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $show_gpu_usage; then
|
|
||||||
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${pink}] #($current_dir/gpu_usage.sh) "
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $show_network; then # network
|
|
||||||
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${cyan}] #($current_dir/network.sh) "
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$show_network_bandwith" != "" ]]; then # network bandwith
|
|
||||||
tmux set-option -g status-right-length 250
|
|
||||||
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${green}] #($current_dir/network_bandwith.sh) "
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $show_weather; then # weather
|
|
||||||
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${orange}] #(cat $datafile) "
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $show_time; then
|
|
||||||
if $show_day_month && $show_military ; then # military time and dd/mm
|
|
||||||
tmux set-option -ga status-right "#[fg=${white},bg=${dark_purple}] %a %d/%m %R ${timezone} "
|
|
||||||
elif $show_military; then # only military time
|
|
||||||
tmux set-option -ga status-right "#[fg=${white},bg=${dark_purple}] %a %m/%d %R ${timezone} "
|
|
||||||
elif $show_day_month; then # only dd/mm
|
|
||||||
tmux set-option -ga status-right "#[fg=${white},bg=${dark_purple}] %a %d/%m %I:%M %p ${timezone} "
|
|
||||||
else
|
|
||||||
tmux set-option -ga status-right "#[fg=${white},bg=${dark_purple}] %a %m/%d %I:%M %p ${timezone} "
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
tmux set-window-option -g window-status-current-format "#[fg=${white},bg=${dark_purple}] #I #W${current_flags} "
|
tmux set-window-option -g window-status-current-format "#[fg=${white},bg=${dark_purple}] #I #W${current_flags} "
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmux set-window-option -g window-status-format "#[fg=${white}]#[bg=${gray}] #I #W${flags}"
|
tmux set-window-option -g window-status-format "#[fg=${white}]#[bg=${gray}] #I #W${flags}"
|
||||||
|
@ -252,3 +205,4 @@ main()
|
||||||
|
|
||||||
# run main function
|
# run main function
|
||||||
main
|
main
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,8 @@
|
||||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||||
export LC_ALL=en_US.UTF-8
|
export LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
# function for getting the refresh rate
|
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
get_tmux_option() {
|
source $current_dir/utils.sh
|
||||||
local option=$1
|
|
||||||
local default_value=$2
|
|
||||||
local option_value=$(tmux show-option -gqv "$option")
|
|
||||||
if [ -z $option_value ]; then
|
|
||||||
echo $default_value
|
|
||||||
else
|
|
||||||
echo $option_value
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
get_platform()
|
get_platform()
|
||||||
{
|
{
|
||||||
|
@ -31,6 +22,7 @@ get_platform()
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
get_gpu()
|
get_gpu()
|
||||||
{
|
{
|
||||||
gpu=$(get_platform)
|
gpu=$(get_platform)
|
||||||
|
@ -39,15 +31,18 @@ get_gpu()
|
||||||
else
|
else
|
||||||
usage='unknown'
|
usage='unknown'
|
||||||
fi
|
fi
|
||||||
echo $usage
|
normalize_percent_len $usage
|
||||||
}
|
}
|
||||||
|
|
||||||
main()
|
main()
|
||||||
{
|
{
|
||||||
# storing the refresh rate in the variable RATE, default is 5
|
# storing the refresh rate in the variable RATE, default is 5
|
||||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||||
|
gpu_label=$(get_tmux_option "@dracula-gpu-usage-label" "GPU")
|
||||||
gpu_usage=$(get_gpu)
|
gpu_usage=$(get_gpu)
|
||||||
echo "GPU $gpu_usage"
|
echo "$gpu_label $gpu_usage"
|
||||||
sleep $RATE
|
sleep $RATE
|
||||||
}
|
}
|
||||||
|
|
||||||
# run the main driver
|
# run the main driver
|
||||||
main
|
main
|
||||||
|
|
|
@ -28,10 +28,10 @@ get_percent()
|
||||||
echo $memory_usage\M\B/$total_mem_mb\M\B
|
echo $memory_usage\M\B/$total_mem_mb\M\B
|
||||||
elif (( $used_mem == 0 )); then
|
elif (( $used_mem == 0 )); then
|
||||||
memory_usage=$(free -m | awk '/^Mem/ {print $3}')
|
memory_usage=$(free -m | awk '/^Mem/ {print $3}')
|
||||||
echo $memory_usage\M\B/$total_mem\G\B
|
echo $memory_usage\M\B/$total_mem_gb\G\B
|
||||||
else
|
else
|
||||||
memory_usage=$(free -g | awk '/^Mem/ {print $3}')
|
memory_usage=$(free -g | awk '/^Mem/ {print $3}')
|
||||||
echo $memory_usage\G\B/$total_mem\G\B
|
echo $memory_usage\G\B/$total_mem_gb\G\B
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -77,8 +77,9 @@ main()
|
||||||
{
|
{
|
||||||
# storing the refresh rate in the variable RATE, default is 5
|
# storing the refresh rate in the variable RATE, default is 5
|
||||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||||
|
ram_label=$(get_tmux_option "@dracula-ram-usage-label" "RAM")
|
||||||
ram_percent=$(get_percent)
|
ram_percent=$(get_percent)
|
||||||
echo "RAM $ram_percent"
|
echo "$ram_label $ram_percent"
|
||||||
sleep $RATE
|
sleep $RATE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
25
scripts/utils.sh
Normal file
25
scripts/utils.sh
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
get_tmux_option() {
|
||||||
|
local option=$1
|
||||||
|
local default_value=$2
|
||||||
|
local option_value=$(tmux show-option -gqv "$option")
|
||||||
|
if [ -z "$option_value" ]; then
|
||||||
|
echo $default_value
|
||||||
|
else
|
||||||
|
echo $option_value
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# normalize the percentage string to always have a length of 5
|
||||||
|
normalize_percent_len() {
|
||||||
|
# the max length that the percent can reach, which happens for a two digit number with a decimal house: "99.9%"
|
||||||
|
max_len=5
|
||||||
|
percent_len=${#1}
|
||||||
|
let diff_len=$max_len-$percent_len
|
||||||
|
# if the diff_len is even, left will have 1 more space than right
|
||||||
|
let left_spaces=($diff_len+1)/2
|
||||||
|
let right_spaces=($diff_len)/2
|
||||||
|
printf "%${left_spaces}s%s%${right_spaces}s\n" "" $1 ""
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue