dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit b1cb7d6edef28161173f397e9affa35dd779bceb
parent 019d059ee911d29bdb77aa517c8cb6d7c78c15ec
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Thu, 25 Jul 2019 18:11:49 +0200

Spaces to tabs, bash to sh

Diffstat:
M.local/bin/articlesearch | 20++++++++++----------
D.local/bin/battery-linux | 34----------------------------------
D.local/bin/battery-osx | 30------------------------------
M.local/bin/board | 56++++++++++++++++++++++++++++++--------------------------
4 files changed, 40 insertions(+), 100 deletions(-)

diff --git a/.local/bin/articlesearch b/.local/bin/articlesearch @@ -9,17 +9,17 @@ query="$(find $dir -type f | sed "s|$HOME/||" | dmenu_themed -i -l 10 -p "Search action="$(printf "Open\nSci-Hub\nAdd citation" | dmenu_themed -i -p "Action:")" if [ "$action" = "Open" ]; then - if [ -f "$HOME/$query" ]; then - xdg-open "$HOME/$query" - else - $browser "https://scholar.google.com/scholar?q=$query" - fi + if [ -f "$HOME/$query" ]; then + xdg-open "$HOME/$query" + else + $browser "https://scholar.google.com/scholar?q=$query" + fi elif [ "$action" = "Sci-Hub" ]; then - getdoi "$query" | shdl --tor-socks --notify --open + getdoi "$query" | shdl --tor-socks --notify --open elif [ "$action" = "Add citation" ]; then - reference="$(scholarref "$query")" - echo "$reference" >> "$BIB" - notify-send "Added citation" "$reference" + reference="$(scholarref "$query")" + echo "$reference" >> "$BIB" + notify-send "Added citation" "$reference" else - notify-send --category=error "${0##*/}" "Action not understood" + notify-send --category=error "${0##*/}" "Action not understood" fi diff --git a/.local/bin/battery-linux b/.local/bin/battery-linux @@ -1,34 +0,0 @@ -#!/bin/sh -# Give a battery name (e.g. BAT0) as an optional argument. -battery=${1:-BAT0} - -case $BLOCK_BUTTON in - 3) pgrep -x dunst >/dev/null && notify-send "Battery module" "🔋: discharging -♻: stagnant charge -🔌: charging -⚡: charged -❗: battery very low! -- Text color reflects charge left" ;; -esac - -capacity=$(cat /sys/class/power_supply/"$battery"/capacity) || exit -status=$(cat /sys/class/power_supply/"$battery"/status) - -if [ "$capacity" -ge 80 ]; then - color="#b8bb26" -elif [ "$capacity" -ge 60 ]; then - color="#ebdbb2" -elif [ "$capacity" -ge 40 ]; then - color="#fabd2f" -elif [ "$capacity" -ge 20 ]; then - color="#fe8019" -else - color="#fb4934" - warn="❗" -fi - -[ -z $warn ] && warn=" " - -[ "$status" = "Charging" ] && color="#FFF" - -printf "%s%s%s" "$(echo "$status" | sed -e "s/,//g;s/Discharging/🔋/;s/Charging/🔌/;s/Unknown/♻️/;s/Full/⚡/;s/ 0*/ /g;s/ :/ /g")" "$warn" "$(echo "$capacity" | sed -e 's/$/%/')" diff --git a/.local/bin/battery-osx b/.local/bin/battery-osx @@ -1,30 +0,0 @@ -#!/bin/bash -e -pmset -g batt | head -n 2 | tail -n 1 |\ - awk '{ print $3 $4 $5 }' |\ - sed 's/;/ /g' |\ - sed 's/(no//' |\ - sed 's/ discharging//' |\ - sed 's/ charged//' |\ - sed 's/ 0:00//' |\ - sed 's/ charging/ ☇/' |\ - sed 's/ACattached/☇/' |\ - sed 's/finishingcharge/☇/' |\ - sed 's/ $//' |\ - sed "s/drawingfrom'AC//" |\ - sed "s/from'ACPower'//" |\ - sed 's/failure.*/batt fail/' - -# El Capitan and prior -#pmset -g batt | head -n 2 | tail -n 1 |\ -# awk '{ print $2 $3 $4 }' |\ -# sed 's/;/ /g' |\ -# sed 's/(no//' |\ -# sed 's/ discharging//' |\ -# sed 's/ charged//' |\ -# sed 's/ 0:00//' |\ -# sed 's/ charging/ ☇/' |\ -# sed 's/ACattached/☇/' |\ -# sed 's/finishingcharge/☇/' |\ -# sed 's/ $//' |\ -# sed "s/drawingfrom'AC//" |\ -# sed 's/failure.*/batt fail/' diff --git a/.local/bin/board b/.local/bin/board @@ -1,33 +1,37 @@ -#!/usr/bin/env bash +#!/bin/sh board() { - #dir="$HOME/iawriter/" - dir="." - format="-O" + #dir="$HOME/iawriter/" + dir="." + format="-O" - if [ $# -gt 0 ]; then - if [ "$1" = "-h" ]; then - echo "board: Open a progress board of markdown files." - echo "usage: $0 [options] [target_directory]" - echo "options:" - printf "\\t-h show this info\n" - printf "\\t-s open view as horizontal splits\n" - printf "By default the {todo,progress,done}.md files are opened in " - printf "the current directory. Optionally, a different directory " - printf "is used if a 'target_directory' is specified.\n" - exit 0 + if [ $# -gt 0 ]; then + if [ "$1" = "-h" ]; then + echo "board: Open a progress board of markdown files." + echo "usage: $0 [options] [target_directory]" + echo "options:" + printf "\\t-h show this info\n" + printf "\\t-s open view as horizontal splits (if $EDITOR is vim)\n" + printf "By default the {todo,progress,done}.md files are opened in " + printf "the current directory. Optionally, a different directory " + printf "is used if a 'target_directory' is specified.\n" + exit 0 - elif [ "$1" = "-h" ]; then - format="-o" - if [ $# -gt 1 ]; then - dir="$2" - fi - else - dir="$1" - fi - fi - - vim +'windo normal G' -c "windo set tw=1000" "$format" "$dir"/{todo,progress,done}.md + elif [ "$1" = "-h" ]; then + format="-o" + if [ $# -gt 1 ]; then + dir="$2" + fi + else + dir="$1" + fi + fi + + if [ "$EDITOR" = "vim" ]; then + vim +'windo normal G' -c "windo set tw=1000" "$format" "$dir"/{todo,progress,done}.md + else + $EDITOR "$dir"/{todo,progress,done}.md + fi } board "$@"