DEV Community

Cover image for I've automated my morning routine ๐Ÿค–

I've automated my morning routine ๐Ÿค–

Chris Bongers on August 31, 2020

Call me lazy, but I just love automating things. Today we are automating my morning routine. You may be wondering what that routine is. Make cof...
Collapse
 
darkwiiplayer profile image
๐’ŽWii ๐Ÿณ๏ธโ€โšง๏ธ

At work I have a today script that recursively fetches every git repo in my ~/workspace, sets some at timers to remind me of break time and calls fortune at the end :D

It also brings up a list of unpushed repositories at the end of the day and lets me select which ones I want automatically pushed.

Collapse
 
piotroxp profile image
Piotr Sล‚upski

share

Collapse
 
darkwiiplayer profile image
๐’ŽWii ๐Ÿณ๏ธโ€โšง๏ธ

Here's the main script that does most of the stuff:

#!/bin/bash

pushd darkrc
git pull
popd

at 11:55 <<'BASH' 2>/dev/null
  DISPLAY=:0 notify-send 'Pause in 5 minuten'
BASH

at 12:00 <<'BASH' 2>/dev/null
  playerctl pause
  aplay gong.wav &
  DISPLAY=:0 zenity --warning --text 'Es ist 12:00' --title 'Pause!' --width=300 --height=100
BASH

if [ $(date +%w) -lt 5 ];
then
  h_end=16
else
  h_end=14
fi

at $h_end:20 <<'BASH' 2>/dev/null
  export DISPLAY=:0
  notify-send 'Feierabend in 10 minuten'
  GIT_ASKPASS=askpass git-push-pending $HOME/workspace & disown
BASH

at $h_end:30 <<'BASH' 2>/dev/null
  DISPLAY=:0 zenity --warning --text 'Feierabend! JETZT! ๐Ÿป' --title 'Feierabend!' --width=300 --height=100
BASH

farfetched ~/workspace

echo โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
fortune
echo โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

Most of the output is in German, but otherwise it should be fairly easy to follow.

The git-push-pending script is a bit more complex:

#!/bin/sh

(for name in $@; do find -L $name -name '*.git' -type d | sed 's/\/.git$//'; done) \
    | xargs git-pending \
    | grep '^ahead' \
    | lua -e 'for line in io.lines() do print(line:match("[^/]+$")); print((line:gsub("^[^ ]* ", ""))) end' \
    | zenity --list --column Repository --column Path --text "Repositories that need pushing:" --multiple --title "Git" --separator ';' --width 800 --height 300 --print-column=2 2>/dev/null \
    | tr ';' '\n' \
    | xargs -L 1 -Iโ‚ฌ sh -c 'cd โ‚ฌ && git push'

and it makes use of the git-pending script which looks like this:

#!/bin/sh

for line in $@
do
    dir=$(pwd)
    cd "$line"
    if git log -0 2>/dev/null
    then
        stat=$(git branch -vv | grep -P '^\*' | grep -Po '\[.*\]')
        if echo $stat | grep -P 'behind' > /dev/null
            then echo behind $line
        fi
        if echo $stat | grep -P 'ahead' > /dev/null
            then echo ahead $line
        fi
    fi
    cd $dir
done
Thread Thread
 
dailydevtips1 profile image
Chris Bongers

Awesome, ssst. but I'm posting my GIT status script tomorrow, all build in bash to tell you what your git statusses are.

Collapse
 
dailydevtips1 profile image
Chris Bongers

What that sounds amazing actually what a great idea!!

Collapse
 
crimsonmed profile image
Mรฉdรฉric Burlet

Technically you could automate the coffee with bash. It has been done before:

github.com/NARKOZ/hacker-scripts

Check the fu*ng-coffee.sh and fu*ng-coffee.rb

Collapse
 
dailydevtips1 profile image
Chris Bongers

Jep, would be lovely to have a internet connected coffee machine ๐Ÿ‘€๐Ÿ’™

Collapse
 
nombrekeff profile image
Keff

Ohh that would be nice, offering some hacker the option to make coffee for you lol

Just kidding, it would be awesome, I thought about it before

Thread Thread
 
dailydevtips1 profile image
Chris Bongers

Haha isnโ€™t that what interns are for? ๐Ÿ˜‚๐Ÿง

Collapse
 
mhatvan profile image
Markus Hatvan • Edited

Cool post Chris, it makes sense to automate the morning routine if you can save time with it!

I used to automate my routine at the last company too.
When the computer boots:

  • open terminal, launch multiple tabs with frontend/backend/database connection
  • open VSCode
  • open LibreOffice todo notes
  • open Postman
  • open Email client

I just couldn't automate the work unfortunately :P

Collapse
 
dailydevtips1 profile image
Chris Bongers

Seems like a good startup script Markus!

Perhaps GPT-3 could automate your work?
I still want to see if it can write blogposts for me ๐Ÿ˜‚

Collapse
 
mhatvan profile image
Markus Hatvan

Probably, I am scared of GPT-3 becoming too powerful :P

Yes, I want that too! Tell me about it when a blog post starts writing itself :D

Thread Thread
 
dailydevtips1 profile image
Chris Bongers
Collapse
 
leonardomaier profile image
Leonardo Maier

You could also pin the tabs to chrome, it would have the same behaviour

Collapse
 
dailydevtips1 profile image
Chris Bongers

Yeah, but let cool :P does pinning also work on reboot? (might be, I never use it)

Collapse
 
leonardomaier profile image
Leonardo Maier

Yes, it works. Actually, I found out this feature recently, that's why I shared it here, I used to make scripts like that too.

Thread Thread
 
dailydevtips1 profile image
Chris Bongers

That's awesome! Nice feature indeed

Collapse
 
ben profile image
Ben Halpern

This is really cool!

Make coffee (Shit, we won't automate this, Yet!)

I came here for something like this. No reason this can't be automated!

Collapse
 
dailydevtips1 profile image
Chris Bongers

Getting my arduino in soon, might use it for something like that ๐Ÿ™†โ€โ™‚๏ธ

Collapse
 
m4r4v profile image
m4r4v

Love it man!!
I have my Linux to ask me if I want to check logs from remote servers whenever I turn on my computer.

Automation is life!!!!

Collapse
 
dailydevtips1 profile image
Chris Bongers

That sounds amazing Jorge!
Nice to see so many people into automation ๐ŸคŸ

Collapse
 
mofiqul profile image
Mofiqul Islam

I use a tiling window manager in Linux and Everything is ready in assigned workspaces as soon as I boot my pc.

Collapse
 
dailydevtips1 profile image
Chris Bongers

That's cool! Linux is so much easier though

Collapse
 
andrewbaisden profile image
Andrew Baisden

Nice living in the future with all of these automated workflows.

Collapse
 
dailydevtips1 profile image
Chris Bongers

It could be way more automated with some raspberry pi's and wifi adopted machines.

Collapse
 
alekseiberezkin profile image
Aleksei Berezkin

How about just not turning off a computer? ๐Ÿ˜‰

Collapse
 
dailydevtips1 profile image
Chris Bongers

Mac for instance gets so bloated if you don't fully turn them off every now and then ๐Ÿ˜‚