t push origin masterMerge branch 'ethancedwards8-master'

This commit is contained in:
Dane Williams 2020-06-28 15:51:01 -07:00
commit a68dcc7d88
5 changed files with 99 additions and 2 deletions

View file

@ -24,3 +24,5 @@ Customize the status bar by adding any of these lines to your .tmux.conf as desi
* Enable military time: `set -g @dracula-military-time true` * Enable military time: `set -g @dracula-military-time true`
* Switch the left smiley icon `set -g @dracula-show-left-icon session` it can accept `session`, `smiley`, `window`, or any character. * Switch the left smiley icon `set -g @dracula-show-left-icon session` it can accept `session`, `smiley`, `window`, or any character.
* Enable high contrast pane border: `set -g @dracula-border-contrast true` * Enable high contrast pane border: `set -g @dracula-border-contrast true`
* Enable cpu percentage: `set -g @dracula-cpu-usage true`
* Enable ram percentage: `set -g @dracula-ram-usage true`

View file

@ -19,6 +19,8 @@ Configuration and options can be found at [draculatheme.com/tmux](https://dracul
* Current location based on network with temperature and forecast icon (if available) * Current location based on network with temperature and forecast icon (if available)
* Network connection status and SSID * Network connection status and SSID
* Battery percentage and AC power connection status * Battery percentage and AC power connection status
* CPU usage
* RAM usage
* Color code based on if prefix is active or not * Color code based on if prefix is active or not
* List of windows with current window highlighted * List of windows with current window highlighted
* When prefix is enabled smiley face turns from green to yellow * When prefix is enabled smiley face turns from green to yellow

30
scripts/cpu_info.sh Executable file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env bash
get_percent()
{
case $(uname -s) in
Linux)
percent=$(top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
echo $percent
;;
Darwin)
percent=$(ps -A -o %cpu | awk '{s+=$1} END {print s "%"}')
echo $percent
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*)
# TODO - windows compatability
;;
esac
}
main()
{
cpu_percent=$(get_percent)
echo "CPU $cpu_percent"
sleep 10
}
# run main driver
main

View file

@ -27,6 +27,8 @@ 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)
# Dracula Color Pallette # Dracula Color Pallette
white='#f8f8f2' white='#f8f8f2'
@ -64,8 +66,7 @@ main()
if $show_weather; then if $show_weather; then
$current_dir/sleep_weather.sh $show_fahrenheit & $current_dir/sleep_weather.sh $show_fahrenheit &
fi fi
# sets refresh interval to every 5 seconds # sets refresh interval to every 5 seconds
tmux set-option -g status-interval 5 tmux set-option -g status-interval 5
@ -103,6 +104,16 @@ main()
powerbg=${pink} powerbg=${pink}
fi 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_network; then # network 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)" 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} powerbg=${cyan}
@ -130,6 +141,13 @@ main()
if $show_battery; then # battery if $show_battery; then # battery
tmux set-option -g status-right "#[fg=${dark_gray},bg=${pink}] #($current_dir/battery.sh) " tmux set-option -g status-right "#[fg=${dark_gray},bg=${pink}] #($current_dir/battery.sh) "
fi 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_network; then # network if $show_network; then # network
tmux set-option -ga status-right "#[fg=${dark_gray},bg=${cyan}] #($current_dir/network.sh) " tmux set-option -ga status-right "#[fg=${dark_gray},bg=${cyan}] #($current_dir/network.sh) "

45
scripts/ram_info.sh Executable file
View file

@ -0,0 +1,45 @@
#!/usr/bin/env bash
get_percent()
{
case $(uname -s) in
Linux)
# percent=$(free -m | awk 'NR==2{printf "%.1f%%\n", $3*100/$2}')
used_mem=$(free -g | grep Mem: | awk '{mem += $3} END {print mem}')
total_mem=$(free -h | grep Mem: | awk '{mem += $2} END {print mem}')
if (( $used_mem == 0 )); then
memory_usage=$(free -m | grep Mem: | awk '{mem += $3} END {print mem}')
echo $memory_usage\M\B/$total_mem\G\B
else
memory_usage=$(free -g | grep Mem: | awk '{mem += $3} END {print mem}')
echo $memory_usage\G\B/$total_mem\G\B
fi
;;
Darwin)
# percent=$(ps -A -o %mem | awk '{mem += $1} END {print mem}')
used_mem=$(top -l 1 -s 0 | grep PhysMem | sed 's/[a-z]//g; s/[A-Z]//g; s/[()]//g' | awk '{printf "%d\n", $2-$3-$5}')
total_mem=$(system_profiler SPHardwareDataType | grep "Memory:" | awk '{print $2 $3}')
if (( $used_mem < 1024 )); then
echo $used_mem\M\B/$total_mem
else
memory=$(($used_mem/1024))
echo $memory\G\B/$total_mem
fi
;;
CYGWIN*|MINGW32*|MSYS*|MINGW*)
# TODO - windows compatability
;;
esac
}
main()
{
ram_percent=$(get_percent)
echo "RAM $ram_percent"
sleep 10
}
#run main driver
main