Merge branch 'master' of ssh://git.dismyserver.net:22516/WhatTheMike/scripts

master
commit 8692d3e8ca

@ -15,6 +15,9 @@ I wrote this script because I was tired of using the excuse that the folder name
**terminalTweaks.txt**
This isn't so much a script as some small quality of life improvements I've made to my WSL Ubuntu 20.04 systems and Ubuntu 20.04 server. Add whichever you like to the end of your .profile and use 'source ~/.profile' to load it immediately.
**tmux-idle**
This is a script I keep running in my tmux session. This version simply pulls the weather for your local area (provided you enter your zip code at the top) and updates every hour with the forecast for the day. My version has been customized to show the status of several services and other information that I use on my server. It should be easy to edit and print things related to your services as well.
### AutoHotKey

@ -0,0 +1,79 @@
#!/bin/bash
# Enter your zipcode here for local weather.
zipcode=20001
# Colors are nice
blk=$(tput setaf 0)
red=$(tput setaf 1)
grn=$(tput setaf 2)
ylw=$(tput setaf 3)
blu=$(tput setaf 4)
cyn=$(tput setaf 6)
wht=$(tput setaf 7)
und=$(tput smul)
bld=$(tput bold)
# Uncoloring is important
rst=$(tput sgr0)
# Get the number of columns and rows to center the
# last updated time on the bottom of the window.
cols=$(tput cols)
rows=$(tput lines)
# trap ctrl-c and call ctrl_c()
# https://rimuhosting.com/knowledgebase/linux/misc/trapping-ctrl-c-in-bash
trap ctrl_c INT
function ctrl_c() {
clear
tput cnorm
echo "${rst}${red}CTRL+C Detected, exiting.${rst}"
exit
}
function dothething() {
# Grab the size of the window again as the window size
# may have changed since the script was started.
cols=$(tput cols)
rows=$(tput lines)
clear
updatedstring="Last updated: `date \"+%F %X\"`"
# Sometimes this may not complete due to wttr.in running
# out of available queries to their weather provider.
# This should only last for a day or so.
curl wttr.in/${zipcode}?1QnuFA
# Make sure the updated line is at the bottom of the screen
down=$rows
# Do some math to center the string horizontally
let over="$cols/2-${#updatedstring}/2"
# Move the cursor over to the correct starting location
tput cup $down $over
# Print the last time the weather was updated
echo -n "${rst}${ylw}${updatedstring}${rst}"
# Reset the cursor back to 0,0
tput cup 0 0
}
# Clear the screen and let's get going
clear
# Make the cursor invisible for the terminal
tput civis
# Programmers are great at naming things
dothething
# Loop forever. Use ctrl+c to exit.
while true; do
# We want to make sure we only check once per hour
# in order to not overwhelm the wttr.in service.
# Octal fix: https://stackoverflow.com/a/24777667
if [ `date +%M` -eq "00" ]; then
# Don't forget to check the seconds or it'll run
# the command every second of the 0th minute.
if [ `date +%S` -eq "00" ]; then
dothething
fi
fi
# Sleep for a second so we're not hammering the system
# with date checks.
sleep 1
done
Loading…
Cancel
Save