Merge branch 'master' into synchronize-panes
This commit is contained in:
commit
92583ed8b4
9 changed files with 155 additions and 38 deletions
|
@ -2,6 +2,9 @@
|
|||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
linux_acpi() {
|
||||
arg=$1
|
||||
BAT=$(ls -d /sys/class/power_supply/BAT* | head -1)
|
||||
|
@ -86,10 +89,10 @@ battery_status()
|
|||
discharging|Discharging)
|
||||
echo ''
|
||||
;;
|
||||
high)
|
||||
high|Full)
|
||||
echo ''
|
||||
;;
|
||||
charging)
|
||||
charging|Charging)
|
||||
echo 'AC'
|
||||
;;
|
||||
*)
|
||||
|
@ -108,15 +111,16 @@ battery_status()
|
|||
|
||||
main()
|
||||
{
|
||||
bat_label=$(get_tmux_option "@dracula-battery-label" "♥")
|
||||
bat_stat=$(battery_status)
|
||||
bat_perc=$(battery_percent)
|
||||
|
||||
if [ -z "$bat_stat" ]; then # Test if status is empty or not
|
||||
echo "♥ $bat_perc"
|
||||
echo "$bat_label $bat_perc"
|
||||
elif [ -z "$bat_perc" ]; then # In case it is a desktop with no battery percent, only AC power
|
||||
echo "♥ $bat_stat"
|
||||
echo "$bat_label $bat_stat"
|
||||
else
|
||||
echo "♥ $bat_stat $bat_perc"
|
||||
echo "$bat_label $bat_stat $bat_perc"
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ get_percent()
|
|||
{
|
||||
case $(uname -s) in
|
||||
Linux)
|
||||
percent=$(LC_NUMERIC=en_US.UTF-8 top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
|
||||
percent=$(LC_NUMERIC=en_US.UTF-8 top -bn2 -d 0.01 | grep "Cpu(s)" | tail -1 | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1"%"}')
|
||||
normalize_percent_len $percent
|
||||
;;
|
||||
|
||||
|
@ -27,13 +27,30 @@ get_percent()
|
|||
esac
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
get_load() {
|
||||
case $(uname -s) in
|
||||
Linux | Darwin)
|
||||
loadavg=$(uptime | awk -F'[a-z]:' '{ print $2}' | sed 's/,//g')
|
||||
echo $loadavg
|
||||
;;
|
||||
|
||||
CYGWIN* | MINGW32* | MSYS* | MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main() {
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU")
|
||||
cpu_percent=$(get_percent)
|
||||
echo "$cpu_label $cpu_percent"
|
||||
cpu_load=$(get_tmux_option "@dracula-cpu-display-load" false)
|
||||
if [ "$cpu_load" = true ]; then
|
||||
echo "$(get_load)"
|
||||
else
|
||||
cpu_label=$(get_tmux_option "@dracula-cpu-usage-label" "CPU")
|
||||
cpu_percent=$(get_percent)
|
||||
echo "$cpu_label $cpu_percent"
|
||||
fi
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ main()
|
|||
# set configuration option variables
|
||||
show_fahrenheit=$(get_tmux_option "@dracula-show-fahrenheit" true)
|
||||
show_location=$(get_tmux_option "@dracula-show-location" true)
|
||||
fixed_location=$(get_tmux_option "@dracula-fixed-location")
|
||||
show_powerline=$(get_tmux_option "@dracula-show-powerline" false)
|
||||
show_flags=$(get_tmux_option "@dracula-show-flags" false)
|
||||
show_left_icon=$(get_tmux_option "@dracula-show-left-icon" smiley)
|
||||
|
@ -66,7 +67,7 @@ main()
|
|||
|
||||
# start weather script in background
|
||||
if [[ "${plugins[@]}" =~ "weather" ]]; then
|
||||
$current_dir/sleep_weather.sh $show_fahrenheit $show_location &
|
||||
$current_dir/sleep_weather.sh $show_fahrenheit $show_location $fixed_location &
|
||||
fi
|
||||
|
||||
# Set timezone unless hidden by configuration
|
||||
|
@ -163,6 +164,11 @@ main()
|
|||
script="#($current_dir/network_bandwidth.sh)"
|
||||
fi
|
||||
|
||||
if [ $plugin = "network-ping" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-network-ping-colors" "cyan dark_gray")
|
||||
script="#($current_dir/network_ping.sh)"
|
||||
fi
|
||||
|
||||
if [ $plugin = "weather" ]; then
|
||||
# wait unit $datafile exists just to avoid errors
|
||||
# this should almost never need to wait unless something unexpected occurs
|
||||
|
|
|
@ -7,6 +7,7 @@ IFS=' ' read -r -a hide_status <<< $(get_tmux_option "@dracula-git-disable-statu
|
|||
IFS=' ' read -r -a current_symbol <<< $(get_tmux_option "@dracula-git-show-current-symbol" "✓")
|
||||
IFS=' ' read -r -a diff_symbol <<< $(get_tmux_option "@dracula-git-show-diff-symbol" "!")
|
||||
IFS=' ' read -r -a no_repo_message <<< $(get_tmux_option "@dracula-git-no-repo-message" "")
|
||||
IFS=' ' read -r -a no_untracked_files <<< $(get_tmux_option "@dracula-git-no-untracked-files" "false")
|
||||
|
||||
# Get added, modified, updated and deleted files from git status
|
||||
getChanges()
|
||||
|
@ -16,7 +17,7 @@ getChanges()
|
|||
declare -i updated=0;
|
||||
declare -i deleted=0;
|
||||
|
||||
for i in $(git -C $path status -s)
|
||||
for i in $(git -C $path --no-optional-locks status -s)
|
||||
|
||||
do
|
||||
case $i in
|
||||
|
@ -77,8 +78,9 @@ checkEmptySymbol()
|
|||
# check to see if the current repo is not up to date with HEAD
|
||||
checkForChanges()
|
||||
{
|
||||
[ $no_untracked_files == "false" ] && no_untracked="" || no_untracked="-uno"
|
||||
if [ "$(checkForGitDir)" == "true" ]; then
|
||||
if [ "$(git -C $path status -s)" != "" ]; then
|
||||
if [ "$(git -C $path --no-optional-locks status -s $no_untracked)" != "" ]; then
|
||||
echo "true"
|
||||
else
|
||||
echo "false"
|
||||
|
|
35
scripts/network_ping.sh
Normal file
35
scripts/network_ping.sh
Normal file
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
# configuration
|
||||
# @dracula-ping-server "example.com"
|
||||
# @dracula-ping-rate 5
|
||||
|
||||
current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source $current_dir/utils.sh
|
||||
|
||||
ping_function() {
|
||||
case $(uname -s) in
|
||||
Linux | Darwin)
|
||||
# storing the hostname/IP in the variable PINGSERVER, default is google.com
|
||||
pingserver=$(get_tmux_option "@dracula-ping-server" "google.com")
|
||||
pingtime=$(ping -c 1 "$pingserver" | tail -1 | awk '{print $4}' | cut -d '/' -f 2)
|
||||
echo "$pingtime ms"
|
||||
;;
|
||||
|
||||
CYGWIN* | MINGW32* | MSYS* | MINGW*)
|
||||
# TODO - windows compatability
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
main() {
|
||||
|
||||
echo $(ping_function)
|
||||
RATE=$(get_tmux_option "@dracula-ping-rate" 5)
|
||||
sleep $RATE
|
||||
}
|
||||
|
||||
# run main driver
|
||||
main
|
|
@ -6,6 +6,7 @@ export LC_ALL=en_US.UTF-8
|
|||
|
||||
fahrenheit=$1
|
||||
location=$2
|
||||
fixedlocation=$3
|
||||
|
||||
LOCKFILE=/tmp/.dracula-tmux-weather.lock
|
||||
DATAFILE=/tmp/.dracula-tmux-data
|
||||
|
@ -31,7 +32,7 @@ main()
|
|||
|
||||
while tmux has-session &> /dev/null
|
||||
do
|
||||
$current_dir/weather.sh $fahrenheit $location > $DATAFILE
|
||||
$current_dir/weather.sh $fahrenheit $location $fixedlocation > $DATAFILE
|
||||
if tmux has-session &> /dev/null
|
||||
then
|
||||
sleep 1200
|
||||
|
|
|
@ -4,10 +4,13 @@ export LC_ALL=en_US.UTF-8
|
|||
|
||||
fahrenheit=$1
|
||||
location=$2
|
||||
fixedlocation=$3
|
||||
|
||||
display_location()
|
||||
{
|
||||
if $location; then
|
||||
if $location && [[ ! -z "$fixedlocation" ]]; then
|
||||
echo " $fixedlocation"
|
||||
elif $location; then
|
||||
city=$(curl -s https://ipinfo.io/city 2> /dev/null)
|
||||
region=$(curl -s https://ipinfo.io/region 2> /dev/null)
|
||||
echo " $city, $region"
|
||||
|
@ -20,7 +23,7 @@ fetch_weather_information()
|
|||
{
|
||||
display_weather=$1
|
||||
# it gets the weather condition textual name (%C), and the temperature (%t)
|
||||
curl -sL wttr.in\?format="%C+%t$display_weather"
|
||||
curl -sL wttr.in/$fixedlocation\?format="%C+%t$display_weather"
|
||||
}
|
||||
|
||||
#get weather display
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue