Created
November 3, 2016 15:52
-
-
Save AlbericC/e0702dd9831f4a025b45c49bf11b61e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# launch a desktop output stuff ! | |
# requires : an internet connection, | |
# curl | |
# remind (and a .reminders file) | |
# fortune (and custom fortune at ~/.fortunes/cusfor) | |
# ~/planning and ~/todo | |
# t command-line twitter client | |
# Font 'Noto-Mono' free as in whatever from google | |
UPDTIME=3m # delay for the main loop | |
DIMS=($(xrandr | grep '+0+0' | grep -o '[[:digit:]]\+x[[:digit:]]\+' | sed 's/x/ /')) | |
HEIGHT=${DIMS[1]} | |
WIDTH=${DIMS[0]} | |
FONT=Atrafont | |
POINTSIZE1=14 | |
POINTSIZE2=15 | |
COLUMNS=80 | |
CAL_COLUMNS=80 | |
function mkoutput { | |
# make a few tmp files for different topics | |
weather=$(mktemp) | |
reminders=$(mktemp) | |
weeks_to_come=$(mktemp) | |
fortune=$(mktemp) | |
date_time=$(mktemp) | |
planning=$(mktemp) | |
todo=$(mktemp) | |
twitter_feed=$(mktemp) | |
left_column=$(mktemp) | |
right_column=$(mktemp) | |
# build useful variables for later on | |
calendar_line=$(let day=$(date +%d) ; while [[ $day > 0 ]] ;do echo -n '##' ; let day-=1 ; done) | |
# definition of colors from Tango | |
butter1='#fce94f' | |
butter2='#edd400' | |
butter3='#c4a000' | |
orange1='#fcaf3e' | |
orange2='#f57900' | |
orange3='#ce5c00' | |
chocolate1='#e9b96e' | |
chocolate2='#c17d11' | |
chocolate2='#8f5902' | |
chameleon1='#8ae234' | |
chameleon2='#73d216' | |
chameleon3='#4e9a06' | |
skyblue1='#729fcf' | |
skyblue2='#3465a4' | |
skyblue3='#204a87' | |
plum1='#ad7fa8' | |
plum2='#75507b' | |
plum3='#5c3566' | |
scarletred1='#ef2929' | |
scarletred2='#cc0000' | |
scarletred3='#a40000' | |
al1='#eeeeec' | |
al2='#d3d7cf' | |
al3='#babdb6' | |
al4='#888a85' | |
al5='#555753' | |
al6='#2e3436' | |
# fill these files with relevant info | |
curl wttr.in \ | |
| head -n 7 \ | |
| sed -e 's/\[[0-9;]*m//g' \ | |
| tail -n +3 \ | |
> ${weather} # color stripped away | |
remind -g ~/.reminders \ | |
> ${reminders} | |
remind -c+2 -m -w${CAL_COLUMNS} -b1 .reminders \ | |
> ${weeks_to_come} | |
fortune ~/.fortunes/cusfor \ | |
| fmt -${COLUMNS} -s \ | |
> ${fortune} | |
(date +'%A %Y-%m-%d %H:%M:%S (week %W)' \ | |
&& (uptime | grep -oe 'up .*') \ | |
)\ | |
> ${date_time} | |
grep -B 20 -m 3 '^$' ~/planning \ | |
| sed "3i${calendar_line}" \ | |
> ${planning} | |
cat ~/todo \ | |
> ${todo} | |
t timeline -l -n 5 \ | |
| awk '{print $2 " " $3 " " $4 " " $5 "\n" substr($0, index($0,$6)) "\n"} ' \ | |
| fmt -${COLUMNS} -s \ | |
>${twitter_feed} | |
# get the source wp | |
source_wp=~/.config/awesome/wallpaper.png | |
# populate it with imagemagick | |
convert -font ${FONT} \ | |
-background black \ | |
-pointsize ${POINTSIZE1} \ | |
-gravity West \ | |
-fill ${skyblue2} label:@${weather} -append \ | |
label:'\n' -append \ | |
-fill ${al4} label:@${planning} -append \ | |
label:'\n' -append \ | |
label:@${weeks_to_come} -append \ | |
label:'\n' -append \ | |
label:@${reminders} -append \ | |
-resize $(( $WIDTH / 3 ))x${HEIGHT}\> \ | |
png:- > ${left_column} | |
convert -font ${FONT} \ | |
-background black \ | |
-pointsize ${POINTSIZE1} -fill ${al4} \ | |
-gravity West \ | |
-fill ${butter3} label:@${fortune} -append -fill ${al4} \ | |
label:'\n' -append \ | |
label:@${todo} -append \ | |
label:'\n' -append \ | |
-fill ${plum2} label:@${twitter_feed} -append \ | |
-resize $(( $WIDTH / 3 ))x${HEIGHT}\> \ | |
png:- > ${right_column} | |
# add this line (right below convert) to visualise the central area (useful to select fontsize) | |
#-fill ${scarletred3} -draw 'rectangle 640,0 1279,1080' \ | |
convert ${source_wp} \ | |
${left_column} -gravity West -geometry +0+0 -compose Over -composite \ | |
${right_column} -gravity East -geometry +0+0 -compose Over -composite \ | |
-font ${FONT} \ | |
-pointsize ${POINTSIZE2} \ | |
-fill ${al4} \ | |
-gravity South -background black \ | |
label:@${date_time} -geometry +0-${POINTSIZE2} -compose screen -composite\ | |
png:- \ | |
| feh --no-fehbg --bg-center - | |
# cleanup - remove tmp files we created earlier | |
rm $weather $reminders $weeks_to_come $fortune $date_time $planning $todo $twitter_feed $left_column $right_column | |
} | |
mkoutput | |
while `sleep $UPDTIME` | |
do | |
mkoutput | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment