reorganized files
This commit is contained in:
parent
4b8413f359
commit
b1df587d6e
8 changed files with 71 additions and 61 deletions
32
scripts/battery.sh
Executable file
32
scripts/battery.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#author: Dane Williams
|
||||
#scipt for gathering battery percentage and A/C status
|
||||
#script is called in dracula.tmux program
|
||||
|
||||
battery_percent()
|
||||
{
|
||||
echo $(pmset -g batt | grep -Eo '[0-9]?[0-9]?[0-9]%')
|
||||
}
|
||||
|
||||
battery_status()
|
||||
{
|
||||
status=$(pmset -g batt | sed -n 2p | cut -d ';' -f 2)
|
||||
|
||||
if [ $status = 'discharging' ]; then
|
||||
echo ''
|
||||
else
|
||||
echo 'AC '
|
||||
fi
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
bat_stat=$(battery_status)
|
||||
bat_perc=$(battery_percent)
|
||||
echo "♥ $bat_stat$bat_perc"
|
||||
}
|
||||
|
||||
#run main driver program
|
||||
main
|
||||
|
60
scripts/dracula.sh
Executable file
60
scripts/dracula.sh
Executable file
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# a tmux color scheme inspired by dracula
|
||||
# author: Dane Williams
|
||||
|
||||
main()
|
||||
{
|
||||
# set current directory variable
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
# Dracula Color Pallette
|
||||
white='#f8f8f2'
|
||||
gray='#44475a'
|
||||
dark_gray='#282a36'
|
||||
light_purple='#bd93f9'
|
||||
dark_purple='#6272a4'
|
||||
cyan='#8be9fd'
|
||||
green='#50fa7b'
|
||||
orange='#ffb86c'
|
||||
red='#ff5555'
|
||||
pink='#ff79c6'
|
||||
yellow='#f1fa8c'
|
||||
|
||||
# start weather script in background
|
||||
$current_dir/sleep_weather.sh &
|
||||
|
||||
# set refresh interval
|
||||
tmux set-option -g status-interval 5
|
||||
|
||||
# set clock
|
||||
tmux set-option -g clock-mode-style 12
|
||||
|
||||
# set length
|
||||
tmux set-option -g status-left-length 100
|
||||
tmux set-option -g status-right-length 100
|
||||
|
||||
# pane border styling
|
||||
tmux set-option -g pane-active-border-style "fg=${dark_purple}"
|
||||
tmux set-option -g pane-border-style "fg=${gray}"
|
||||
|
||||
# message styling
|
||||
tmux set-option -g message-style "bg=${gray},fg=${white}"
|
||||
|
||||
# status bar
|
||||
tmux set-option -g status-style "bg=${gray},fg=${white}"
|
||||
|
||||
tmux set-option -g status-left "#[bg=${green},fg=${dark_gray}]#{?client_prefix,#[bg=${yellow}],} ☺ "
|
||||
|
||||
tmux set-option -g status-right "#[fg=${dark_gray},bg=${pink}] #($current_dir/battery.sh) "
|
||||
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=${orange}] #(cat $current_dir/../data/weather.txt) "
|
||||
tmux set-option -ga status-right "#[fg=${white},bg=${dark_purple}] %a %m/%d %I:%M %p #(date +%Z) "
|
||||
|
||||
# window tabs
|
||||
tmux set-window-option -g window-status-current-format "#[fg=${white},bg=${dark_purple}] #I #W "
|
||||
tmux set-window-option -g window-status-format "#[fg=${white}]#[bg=${gray}] #I #W "
|
||||
}
|
||||
|
||||
# run main function
|
||||
main
|
27
scripts/network.sh
Executable file
27
scripts/network.sh
Executable file
|
@ -0,0 +1,27 @@
|
|||
#/usr/bin/env bash
|
||||
|
||||
#author: Dane Williams
|
||||
#script for gathering internet connectivity info
|
||||
#script is called in dracula.tmux program
|
||||
|
||||
|
||||
get_ssid()
|
||||
{
|
||||
if /System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep -E ' SSID' | cut -d ':' -f 2 &> /dev/null; then
|
||||
echo "$(/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep -E ' SSID' | cut -d ':' -f 2)"
|
||||
else
|
||||
echo ' Ethernet'
|
||||
fi
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
if ping -q -c 1 -W 1 google.com &>/dev/null; then
|
||||
echo "$(get_ssid)"
|
||||
else
|
||||
echo ' Offline'
|
||||
fi
|
||||
}
|
||||
|
||||
#run main driver function
|
||||
main
|
24
scripts/sleep_weather.sh
Executable file
24
scripts/sleep_weather.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#/usr/bin/env bash
|
||||
|
||||
#wrapper script for running weather on interval
|
||||
|
||||
main()
|
||||
{
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
$current_dir/weather.sh > $current_dir/../data/weather.txt
|
||||
|
||||
while tmux has-session &> /dev/null
|
||||
do
|
||||
$current_dir/weather.sh > $current_dir/../data/weather.txt
|
||||
if tmux has-session &> /dev/null
|
||||
then
|
||||
sleep 1000
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#run main driver function
|
||||
main
|
69
scripts/weather.sh
Executable file
69
scripts/weather.sh
Executable file
|
@ -0,0 +1,69 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#author: Dane Williams
|
||||
#script for gathering current location and weather at location
|
||||
#script is then called in the dracula.tmux program
|
||||
|
||||
city=$(curl -s https://ipinfo.io/city 2> /dev/null)
|
||||
region=$(curl -s https://ipinfo.io/region 2> /dev/null)
|
||||
zip=$(curl -s https://ipinfo.io/postal 2> /dev/null | tail -1)
|
||||
country=$(curl -s https://ipinfo.io/country 2> /dev/null)
|
||||
|
||||
region_code_url=http://www.ip2country.net/ip2country/region_code.html
|
||||
weather_url=https://forecast.weather.gov/zipcity.php
|
||||
|
||||
#substitute region code for regions in north america
|
||||
get_region_code()
|
||||
{
|
||||
curl -s $region_code_url | grep $region &> /dev/null && region=$(curl -s $region_code_url | grep $region | cut -d ',' -f 2)
|
||||
echo $region
|
||||
}
|
||||
|
||||
weather_information()
|
||||
{
|
||||
curl -sL $weather_url?inputstring=$zip | grep myforecast-current | grep -Eo '>.*<' | sed -E 's/>(.*)</\1/'
|
||||
}
|
||||
get_temp()
|
||||
{
|
||||
weather_information | grep 'deg;F' | cut -d '&' -f 1
|
||||
}
|
||||
forecast_unicode()
|
||||
{
|
||||
forecast=$(weather_information | head -n 1)
|
||||
|
||||
if [[ $forecast =~ 'Snow' ]]; then
|
||||
echo '❄ '
|
||||
elif [[ (($forecast =~ 'Rain') || ($forecast =~ 'Shower')) ]]; then
|
||||
echo '☂ '
|
||||
elif [[ (($forecast =~ 'Overcast') || ($forecast =~ 'Cloud')) ]]; then
|
||||
echo '☁ '
|
||||
elif [[ $forecast = 'NA' ]]; then
|
||||
echo ''
|
||||
else
|
||||
echo '☀ '
|
||||
fi
|
||||
|
||||
|
||||
}
|
||||
#get weather display if in US
|
||||
display_weather()
|
||||
{
|
||||
if [ $country = 'US' ]; then
|
||||
echo "$(forecast_unicode)$(get_temp)°F"
|
||||
else
|
||||
echo ''
|
||||
fi
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
# process should be cancelled when session is killed
|
||||
if ping -q -c 1 -W 1 ipinfo.io &>/dev/null; then
|
||||
echo "$(display_weather) $city, $(get_region_code)"
|
||||
else
|
||||
echo "Location Unavailable"
|
||||
fi
|
||||
}
|
||||
|
||||
#run main driver program
|
||||
main
|
Loading…
Add table
Add a link
Reference in a new issue