6 votes

What are some startup scripts you have on your daily driver?

In the everlasting quest to customize my laptop and make my life easier, I'm looking for any ideas for startup scripts to run on user login.
Personally, I don't know how to write bash scripts yet and unfortunately I won't have time to pick it up on the side in the near future seeing as how I'm swamped between my studies and work—nevertheless, it's always nice to see how others might have under the hood for future tinkering :)
I'm currently running i3-gaps on Arch Linux. I have a few programs that I like to run inside i3's config file (Polybar, firefox, file manager, Thunderbird) every time I start i3.
The problem that I seem to have is that I lack imagination. I don't know the potential of what else I could be doing with startup scripts, so I'm turning to Tildes to see what you guys might have.

2 comments

  1. DMBuce
    Link
    It's not exactly a startup script but I've posted before about how I have cron jobs set up to play music as an alarm clock in the morning and when I get home from work. Is that sort of thing...

    It's not exactly a startup script but I've posted before about how I have cron jobs set up to play music as an alarm clock in the morning and when I get home from work. Is that sort of thing helpful or are you only interested in startup scripts?

    4 votes
  2. bme
    (edited )
    Link
    I don't think most peoples innovations are driven by imagination, they are driven problems that they look to solve. What currently bugs you about your workflow? Is there a collection of windowing...

    I don't think most peoples innovations are driven by imagination, they are driven problems that they look to solve. What currently bugs you about your workflow? Is there a collection of windowing tasks that you regularly perform? Would it make sense to automate them? Do you manually place your applications into windows / workspaces on startup?

    I'll give you one example of a typical problem:
    You have some environment variables relevant to a given project, which only need to exist within the project folder. This is easily solved with direnv. Ok fine. What if you want those values to encrypted because they are secrets and only decrypted on demand? I use pass so naturally I came up with the following: I will encode collections of env vars into yaml files that I will keep in my pass directory. I'll write a script to decode them and stick it in my ~/.direnvrc. So in my ~/.direnvrc I have the following function:

    pass-export() {
    
      [[ -n "$1" ]] || { >&2 echo "Must pass pass arg"; return 63; }
      
      while read -r key; do
        key=${key#'"'}
        key=${key%'"'}
    
        read -r value
        value=${value#'"'}
        value=${value%'"'}
    
        export $key="$value"
      done < <(pass "$1" | yq 'to_entries | .[] | .key, .value')
    
    }
    

    and in a .envrc file I might have

    #!/bin/bash
    
    export AWS_DEFAULT_REGION=eu-west-1
    pass-export work/outw/web/aws-keys
    

    which exports my secret keys for a given aws project so they can be used with terraform or aws cli or whatever. This is typical of my collection of random bits and bobs. Search is another regular problem. Learn how to wield things like fzf well and you'll get around your computer with ease, but it can be inserted in all kinds of places. For instance if I have more than one git remote I want to be prompted to pick where to push an upstream branch for the first time otherwise just send it! For this I use a little git alias:

    [alias]
    	p  = !just-push-it
    

    and a dumb script:

    #!/bin/bash
    
    if [[ -n "$(git for-each-ref --format '%(upstream:short)' $(git symbolic-ref -q HEAD))" ]]; then
       exec git push 
    else
       exec git push -u "$(git remote | fzf -1)" HEAD 
    fi
    

    The script basically does the right thing if there is just one option and if there are multiple it gives me the choices piped into a fuzzy finder and then does the right thing once the choice is made. This pattern can be repeated all over the place. The fzf wiki is full of them.

    The point of all this is that efficiency doesn't require imagination, it only requires the will to be lazy enough to learn how to not do things. I don't have time to not be intentionally improving my workflow. I doubt many people do, and yet somehow they make time for it by refusing to learn the skills they need to stop wasting time.

    4 votes