From e2b9f534cf88a0a8319e72dcf679e68289d55c0e Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Fri, 29 Jul 2022 13:56:42 -0400 Subject: [PATCH] Make new todo with launcher, reorg dpi scaling, remove today --- home/.profile | 22 +++++++--- home/.xbindkeysrc | 8 +++- home/.xlaunch | 31 ++++++++++++- home/bin/today | 86 ------------------------------------- home/bin/todo.launch.sh | 6 +++ home/lib/login_aliases.sh | 1 - home/lib/login_functions.sh | 18 ++++++++ home/lib/login_variables.sh | 4 +- 8 files changed, 75 insertions(+), 101 deletions(-) delete mode 100755 home/bin/today create mode 100755 home/bin/todo.launch.sh diff --git a/home/.profile b/home/.profile index c7c3a4a..96a3198 100644 --- a/home/.profile +++ b/home/.profile @@ -1,11 +1,14 @@ -. $HOME/lib/login_variables.private.sh # Personal data variables +# XXX Setting the scaling variables causes inconsistent response from apps. +# However, launching mate-appearance-properties after startx - causes +# something to be adjusted and most apps scale up correctly. With some +# exceptions, like zeal. +#. $HOME/lib/login_variables_dpi.sh +. $HOME/lib/login_variables.private.sh +. $HOME/lib/login_variables.sh +. $HOME/lib/login_functions.sh unalias d 2> /dev/null || true # Defined by oh-my-zsh, but I want it for dict/fzf function. - -for file in $HOME/lib/login_*.sh -do - . $file -done +. $HOME/lib/login_aliases.sh umask 077 @@ -14,10 +17,15 @@ then eval "$(ssh-agent)" fi -status +## TODO Rename status to motd +case "$-" in + # Only execute if shell is interactive. + *i*) status;; +esac printf '\n' +# TODO File per quote. Seed rng with date and select quote of the day. #awk \ # -v RS='' \ # 'BEGIN {srand()} {fortunes[n++] = $0} END {print fortunes[int(n * rand())]}' \ diff --git a/home/.xbindkeysrc b/home/.xbindkeysrc index 977d9d4..b3e1808 100644 --- a/home/.xbindkeysrc +++ b/home/.xbindkeysrc @@ -138,9 +138,12 @@ "emacs" Mod4 + Shift + e -# Edit specific files -"cd ~/doc/TODO && gvim TODO.md" + +### Edit specific files + +"todo.launch.sh" Mod4 + t + "cd ~/doc/ideas && gvim ideas.md" Mod4 + i #"cd ~/doc/drafts && drafts_prepend && gvim -c NERDTreeFind drafts.md" @@ -153,6 +156,7 @@ "cd ~/doc/quotations && gvim quotations.md" Mod4 + q + # File browser "pcmanfm" Mod4 + f diff --git a/home/.xlaunch b/home/.xlaunch index 0cf046b..5be1cb8 100755 --- a/home/.xlaunch +++ b/home/.xlaunch @@ -2,12 +2,39 @@ set -e +launch_then_killall() { + local -r program="$1" + local -r timeout="${2:-1}" # 2nd arg or default to 1. + + "$program"& + sleep "$timeout" + killall "$program" +} + +dpi_scale() { + # IDK what magic is at work here, but launching mate-appearance-properties + # does the job better than setting scaling variables. + # TODO Get to the bottom of how it works and replicate directly. + launch_then_killall 'mate-appearance-properties' 1 + + # GDK 3 (GTK 3) + # https://wiki.archlinux.org/index.php/HiDPI#GDK_3_(GTK_3) + #export GDK_SCALE=2 + + # QT + # https://wiki.archlinux.org/index.php/HiDPI#Qt_5 + # https://doc.qt.io/qt-5/highdpi.html + # https://blog.qt.io/blog/2016/01/26/high-dpi-support-in-qt-5-6/ + #export QT_SCALE_FACTOR=2 # Causes qutebrowser UI fonts to have large gaps. + #export QT_FONT_DPI=192 # Scales qutebrowser UI fonts as expected. +} launch_common() { xbindkeys xscreensaver & - mpd --kill || true - mpd + dpi_scale& + #mpd --kill || true + #mpd for script in ~/.xlaunch.d/*; do "$script" done diff --git a/home/bin/today b/home/bin/today deleted file mode 100755 index f9c2d28..0000000 --- a/home/bin/today +++ /dev/null @@ -1,86 +0,0 @@ -#! /bin/bash - -set -e - -DIR_DATA="$HOME/var/run/today" -FILE_WEATHER="$DIR_DATA/weather" - -mkdir -p "$DIR_DATA" - -repeat() { - x="$1" - n="$2" - awk -v x="$x" -v n="$n" 'BEGIN {for (i=1; i<=n; i++) {printf x}}' -} - -bar=$(repeat '-' '80') -ts_fmt='+%A, %Y %B %d, %H:%M:%S' -ts_lang='el_GR.UTF-8' -timestamp_local=$(LANG="$ts_lang" date "$ts_fmt") -timestamp_west=$( LANG="$ts_lang" TZ='US/Pacific' date "$ts_fmt") -timestamp_pl=$( LANG="$ts_lang" TZ='Poland' date "$ts_fmt") -timestamp_nz=$( LANG="$ts_lang" TZ='NZ' date "$ts_fmt") - -ip_addresses=$( - ip addr \ - | awk ' - /^[0-9]+:/ { - interface = $2 - sub(":$", "", interface) - interfaces[++interface_count] = interface - } - - /^ +inet +/ { - addr = $2 - sub("/[0-9]+$", "", addr) - addrs[interface] = addr - } - - END { - for (i=1; i<=interface_count; i++) { - interface = interfaces[i] - print interface, addrs[interface] - } - }' \ - | column -t -) - -weather_fetch() { - curl "http://wttr.in/${ZIP_CODE}?1" \ - 1> "$FILE_WEATHER" \ - 2> /dev/null -} - -weather_file_age() { - echo $(( $(date +%s) - $(stat -c '%Y' "$FILE_WEATHER") )) -} - -weather_get_or_fetch() { - weather_file_age_limit=$(( 3 * 60 * 60 )) - if [[ ! -e $FILE_WEATHER || weather_file_age -ge $weather_file_age_limit ]] - then - weather_fetch - fi - cat "$FILE_WEATHER" -} - -weather="$(weather_get_or_fetch)" - -clear -#LANG="$ts_lang" ncal -M $(date +%Y) -LANG="$ts_lang" ncal -M -echo "$bar" -( - echo 'LOCAL' ',' "$timestamp_local" - echo 'Pacific' ',' "$timestamp_west" - echo 'Poland' ',' "$timestamp_pl" - echo 'New Zealand' ',' "$timestamp_nz" -) \ -| column -ts, -echo "$bar" -echo "$ip_addresses" -echo "$bar" -echo '' -echo "Fetched on: $(stat -c %y $FILE_WEATHER)" -echo "$weather" -echo '' diff --git a/home/bin/todo.launch.sh b/home/bin/todo.launch.sh new file mode 100755 index 0000000..ee1bcad --- /dev/null +++ b/home/bin/todo.launch.sh @@ -0,0 +1,6 @@ +#! /bin/bash + +. ~/lib/login_variables.sh # To get $DIR_TODO +. ~/lib/login_functions.sh # To get todo + +EDITOR=gvim todo diff --git a/home/lib/login_aliases.sh b/home/lib/login_aliases.sh index 11ebfa1..36ac6ba 100644 --- a/home/lib/login_aliases.sh +++ b/home/lib/login_aliases.sh @@ -17,7 +17,6 @@ alias tm='tmux' #alias startx='printf "Use a specialized startx-...\n"' alias mans='man $(man -k . | sort | fzf -e | awk "{print \$1}")' alias twread='twtxt timeline --limit 1000 | less' -alias todo='cd ~/doc/TODO && vim TODO.md' alias work_todo="cd $DIR_WORK/docs/TODO && vim -c NERDTreeFind TODO" alias drafts='cd ~/doc/drafts && drafts_prepend && vim -c NERDTreeFind drafts.md' alias notes='cd ~/doc/notes && notes_prepend && vim notes.md' diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh index 7bd88cb..d1d458a 100644 --- a/home/lib/login_functions.sh +++ b/home/lib/login_functions.sh @@ -425,6 +425,24 @@ gh_clone_repo() { git clone "$1" } +todo() { + local date + local timestamp + local bar + date=$(date +%F) + timestamp=$(date '+%F %A') + bar=$(for _ in {1..80}; do printf '='; done) + local -r dir="$DIR_TODO/daily" + local -r file="$dir/$date.txt" + + mkdir -p "$dir" + if [ ! -f "$file" ] + then + printf '%s\n%s\n%s\n' "$bar" "$timestamp" "$bar" > "$file" + fi + cd "$DIR_TODO" && "$EDITOR" "$file" +} + work_log_template() { cat << EOF $(date '+%F %A') diff --git a/home/lib/login_variables.sh b/home/lib/login_variables.sh index 95df0a5..24ccee7 100644 --- a/home/lib/login_variables.sh +++ b/home/lib/login_variables.sh @@ -12,6 +12,7 @@ export DIR_LOG="$HOME/var/log" export DIR_LOG_MPD="$DIR_LOG/mpd" export DIR_NQ="$HOME/var/run/nq" export DIR_WALLPAPERS="$HOME/arc/img/Wallpapers" +export DIR_TODO="$HOME/doc/TODO" # ensure all DIRs exist: env | grep ^DIR_ | awk -F= '{print $2}' | xargs -I% mkdir -p '%' @@ -45,9 +46,6 @@ export PATH=$PATH:$HOME/.racket/"$RACKET_VERSION"/bin # Gambit Scheme export PATH=$PATH:/usr/local/Gambit/bin -# DPI -. "$HOME/lib/login_variables_dpi.sh" - # Doom export PATH=$PATH:$HOME/.emacs.d/bin -- 2.20.1