dots

git clone git://mattcarlson.org/repos/dots.git
Log | Files | Refs

commit 780b32eb39ade2d147e4085ed8aab4f75817ab96
parent 885f67917248768323d43f78f0a0b12da9af5633
Author: Matthew Carlson <matt@mcarlson.xyz>
Date:   Thu, 19 Aug 2021 21:23:17 -0400

even more scripting

Diffstat:
M.config/sh/aliasrc | 4++--
M.config/sh/profile | 5+++++
M.config/x/xprofile | 1+
M.config/x/xresources | 32++++++++++++++++----------------
M.config/zathura/zathurarc | 54+++++++++++++++++++++++++++---------------------------
M.local/bin/bar/mail.sh | 2+-
M.local/bin/bar/pkgs.sh | 42++++++++++++++++++++++++++++++++++--------
M.local/bin/bar/vol.sh | 14+++++++++-----
M.local/bin/menu.sh | 30++++++++++++++++++++----------
M.local/bin/shot.sh | 2+-
M.local/bin/wp.sh | 3+++
M.local/share/wp | 4++--
12 files changed, 121 insertions(+), 72 deletions(-)

diff --git a/.config/sh/aliasrc b/.config/sh/aliasrc @@ -69,7 +69,7 @@ alias \ alias dots='/usr/bin/git --git-dir=${HOME}/.dots/ --work-tree=${HOME}' # sync mail on mail exit when entered thru cmd line -alias ${MAIL_CLIENT}='${MAIL_CLIENT}; mail.sh -g &' +alias ${MAIL_CLIENT}='cd "${DOWNLOADS_DIR}"; ${TERMINAL} -c "${MAIL_CLIENT}" -e "${MAIL_CLIENT}"; mail.sh -g &' # youtube alias \ @@ -78,4 +78,4 @@ alias \ ytp='youtube-dl -i -o "${DOWNLOADS_DIR}/%(uploader)s/%(playlist_index)s-%(title)s.%(ext)s" --add-metadata' \ ytpa='ytp -f bestaudio/best -x' \ ytall='yt -cw -f best' \ - ytw='ytfzf' + ytw='${YOUTUBE_CLIENT}' diff --git a/.config/sh/profile b/.config/sh/profile @@ -18,7 +18,11 @@ export EDITOR='vim' export MAIL_CLIENT='neomutt' export MUSIC_PLAYER='ncmpcpp' export READER='zathura' +export YOUTUBE_CLIENT='ytfzf' export IMG_VIEWER='feh' +export MIXER='alsamixer' +export TORRENT_CLIENT='deluge-gtk' +export IMAGE_EDITOR='gimp-2.99' # xdg base directories export XDG_CONFIG_HOME="${HOME}/.config/" @@ -39,6 +43,7 @@ export STARDICT_DATA_DIR="${XDG_DATA_HOME:-${HOME}/.local/share/}" # folders export MAIL_DIR="${HOME}/mail/" export PICTURES_DIR="${HOME}/pix/" +export DOWNLOADS_DIR="${HOME}/dl/" # colorful man pages LESS_TERMCAP_mb="$(printf '%b' '\x1b[1;32m')" diff --git a/.config/x/xprofile b/.config/x/xprofile @@ -5,6 +5,7 @@ xrdb "${XDG_CONFIG_HOME:-${HOME}/.config/}/x/xresources" lock.sh & feh --no-fehbg --bg-scale "${XDG_DATA_HOME:-${HOME}/.local/share/}/wp" +xclickroot -r menu.sh & # "${BAR}" & xcompmgr & mpd & diff --git a/.config/x/xresources b/.config/x/xresources @@ -1,20 +1,20 @@ ! colors -#define col0 #121613 -#define col1 #c3619a -#define col2 #6f92af -#define col3 #76b3c9 -#define col4 #7bc2d4 -#define col5 #9b91ae -#define col6 #b08fab -#define col7 #c5d1dc -#define col8 #89929a -#define col9 #c3619a -#define col10 #6f92af -#define col11 #76b3c9 -#define col12 #7bc2d4 -#define col13 #9b91ae -#define col14 #b08fab -#define col15 #c5d1dc +#define col0 #0f0807 +#define col1 #70694f +#define col2 #7d7f6a +#define col3 #9a5837 +#define col4 #ab4336 +#define col5 #936f4f +#define col6 #b0924d +#define col7 #c2bfa8 +#define col8 #878575 +#define col9 #70694f +#define col10 #7d7f6a +#define col11 #9a5837 +#define col12 #ab4336 +#define col13 #936f4f +#define col14 #b0924d +#define col15 #c2bfa8 ! font Xft.antialias : 1 diff --git a/.config/zathura/zathurarc b/.config/zathura/zathurarc @@ -19,35 +19,35 @@ set recolor-keephue 'false' set recolor-reverse-video 'false' # Command line completion entries -set completion-fg '#c5d1dc' -set completion-bg '#121613' +set completion-fg '#c2bfa8' +set completion-bg '#0f0807' # Command line completion group elements -set completion-group-fg '#6F92AF' -set completion-group-bg '#121613' +set completion-group-fg '#7D7F6A' +set completion-group-bg '#0f0807' # Current command line completion element -set completion-highlight-fg '#121613' -set completion-highlight-bg '#c5d1dc' +set completion-highlight-fg '#0f0807' +set completion-highlight-bg '#c2bfa8' # Default foreground/background color -set default-bg rgba(18,22,19,0.95) +set default-bg rgba(15,8,7,0.95) # Input bar -set inputbar-fg '#c5d1dc' -set inputbar-bg '#121613' +set inputbar-fg '#c2bfa8' +set inputbar-bg '#0f0807' # Notification -set notification-fg '#c5d1dc' -set notification-bg '#121613' +set notification-fg '#c2bfa8' +set notification-bg '#0f0807' # Error notification -set notification-error-fg '#c5d1dc' -set notification-error-bg '#C3619A' +set notification-error-fg '#c2bfa8' +set notification-error-bg '#70694F' # Warning notification -set notification-warning-fg '#c5d1dc' -set notification-warning-bg '#C3619A' +set notification-warning-fg '#c2bfa8' +set notification-warning-bg '#70694F' # Tab - TODO # set tabbar-fg @@ -58,25 +58,25 @@ set notification-warning-bg '#C3619A' # set tabbar-focus-bg # Status bar -set statusbar-fg '#c5d1dc' -set statusbar-bg '#121613' +set statusbar-fg '#c2bfa8' +set statusbar-bg '#0f0807' # Highlighting parts of the document (e.g. show search results) -set highlight-color '#6F92AF' -set highlight-active-color '#6F92AF' +set highlight-color '#7D7F6A' +set highlight-active-color '#7D7F6A' # Represent light/dark colors in recoloring mode set recolor-lightcolor rgba(0,0,0,0) -set recolor-darkcolor '#c5d1dc' +set recolor-darkcolor '#c2bfa8' # 'Loading...' text -set render-loading-fg '#c5d1dc' -set render-loading-bg '#121613' +set render-loading-fg '#c2bfa8' +set render-loading-bg '#0f0807' # Index mode -set index-fg '#c5d1dc' -set index-bg '#121613' +set index-fg '#c2bfa8' +set index-bg '#0f0807' # Selected element in index mode -set index-active-fg '#121613' -set index-active-bg '#c5d1dc' -\ No newline at end of file +set index-active-fg '#0f0807' +set index-active-bg '#c2bfa8' +\ No newline at end of file diff --git a/.local/bin/bar/mail.sh b/.local/bin/bar/mail.sh @@ -20,7 +20,7 @@ get_mail() { rm -f "${TMP}" } -open() { "${TERMINAL}" -c "${TERMINAL}" -e "${MAIL_CLIENT}" && { get_mail & } ; } +open() { cd "${DOWNLOADS_DIR}"; "${TERMINAL}" -c "${MAIL_CLIENT}" -e "${MAIL_CLIENT}" && { get_mail & } ; } bar() { # count personal and school mail then sum together diff --git a/.local/bin/bar/pkgs.sh b/.local/bin/bar/pkgs.sh @@ -11,6 +11,7 @@ GET_TMP='/tmp/get-pkgs' GET_ICON='' get_os() { + # oses defined by their pkg managers command -v pacman >/dev/null && os='arch' { command -v apt || command -v apt-get ; } >/dev/null && os='debian' command -v emerge >/dev/null && os='gentoo' @@ -18,19 +19,24 @@ get_os() { } upgrade_pkgs() { + # remove the temp icon when the process is suddenly stopped/killed trap 'rm -f ${UPGRADE_TMP}; exit 1' INT TERM - trap exit 1 + # for arch-based systems upgrade_arch_pkgs() { + # arch has both pacman and AUR repos; handle them upgrade_repo_pkgs() { while :; do get_pkgs case "${1}" in + # official repos 'pacman') repo_type='Official' + # grep -c is more accurate than wc -l available_upgrades=$(printf '%s' "${pacman_pkgs}" | grep -c '^') - cmd='pacman' + cmd='doas pacman' ;; + # aur repo 'aur') repo_type='AUR' available_upgrades=$(printf '%s' "${aur_pkgs}" | grep -c '^') cmd="${AUR_HELPER} -a" @@ -38,13 +44,16 @@ upgrade_pkgs() { *) return 1 ;; esac + # no available upgrades at the moment if [ "${available_upgrades}" -eq 0 ]; then [ "${repo_type}" = 'Official' ] && repo_type="$(printf '%s\n' "${repo_type}" | tr '[:upper:]' '[:lower:]')" printf '%s\n' "No ${repo_type} packages available for upgrade at the moment. Press any key to continue." read -r input return else - if ! doas ${cmd} -Syu; then + # try the command; pacman and AUR helper will use similar flags + # if it fails ask the user to retry + if ! ${cmd} -Syu; then printf '%s\n' "${repo_type} packages failed to upgrade. Retry? [Y/n] " read -r input input="$(printf '%s\n' "${input}" | tr '[:upper:]' '[:lower:]')" @@ -63,8 +72,8 @@ upgrade_pkgs() { touch "${UPGRADE_TMP}" + # upgrade pkgs depending on os get_os - case "${os}" in 'arch') upgrade_arch_pkgs ;; esac rm -f "${UPGRADE_TMP}" @@ -74,16 +83,29 @@ get_pkgs() { touch "${GET_TMP}" get_os - case "${os}" in - 'arch') pacman_pkgs="$(pacman -Qu 2>/dev/null)" + 'arch') # user will not need to input pass if set up correctly + # -Sy simply syncs the databases + doas pacman -Sy >/dev/null 2>&1 + # -Qu will print out the actual upgrades + pacman_pkgs="$(pacman -Qu 2>/dev/null)" if command -v "${AUR_HELPER}" >/dev/null; then + # print just AUR upgrades with AUR helper aur_pkgs="$("${AUR_HELPER}" -Qum --devel 2>/dev/null)" fi - pkgs="$(printf '%s\n%s' "${pacman_pkgs}" "${aur_pkgs}")" + + pkgs="$(printf '%s\n' "${pacman_pkgs}")" + + # if there are no pacman pkgs we do not need a newline + # but we do need a newline if there are + [ ! "${pkgs}" ] && pkgs="${pkgs}$(printf '%s\n' "${aur_pkgs}")" \ + || pkgs="${pkgs}$(printf '\n%s\n' "${aur_pkgs}")" ;; esac + # print pkgs to cache + # cache is useful in case of internet loss, etc. + # do NOT use newline with printf here or else count will be messed up if [ -f "${PKGS}" ]; then printf '%s' "${pkgs}" > "${PKGS}" else touch "${PKGS}" @@ -93,10 +115,14 @@ get_pkgs() { } bar() { + # get count from cache, will be updated whenever get_pkgs is called, either manually or from cron, etc. [ -f "${PKGS}" ] && pkgs=$(grep -c '^' < "${PKGS}") + # upgrade icon if [ -f "${UPGRADE_TMP}" ]; then printf '%s\n' "${UPGRADE_ICON}" + # get icon elif [ -f "${GET_TMP}" ]; then printf '%s\n' "${GET_ICON}" + # icon and count else printf '%s\n' "${ICON} ${pkgs}" fi } @@ -106,7 +132,7 @@ main() { [ ${#} -eq 0 ] && bar # bar usage - case ${BLOCK_BUTTON} in esac + case ${BLOCK_BUTTON} in 2) get_pkgs ;; esac while getopts 'gu' opt; do case "${opt}" in diff --git a/.local/bin/bar/vol.sh b/.local/bin/bar/vol.sh @@ -29,6 +29,8 @@ set_vol() { env HERBE_ID=/0 herbe "Volume: ${vol}%" & } +open() { "${TERMINAL}" -c "${MIXER}" -e "${MIXER}" ; } + bar() { get_vol @@ -57,14 +59,16 @@ main() { # bar usage case ${BLOCK_BUTTON} in - 1) "${TERMINAL}" -c 'alsamixer' -e 'alsamixer' ;; - 2) toggle ;; - 4) set_vol + 1 ;; - 5) set_vol - 1 ;; + 1) open ;; + 2) toggle ;; + 4) set_vol + 1 ;; + 5) set_vol - 1 ;; esac - while getopts 't' opt; do + while getopts 'ot' opt; do case "${opt}" in + # open mixer + o) open && return ;; # toggle if t flag used t) toggle && return ;; *) return ;; diff --git a/.local/bin/menu.sh b/.local/bin/menu.sh @@ -4,16 +4,26 @@ main() { xmenu << EOF | sh & - Programs -  Web Browser ${BROWSER} -  Image editor gimp-2.99 -  Text Editor ${TERMINAL} -c ${TERMINAL} -e ${EDITOR} - - Terminal ${TERMINAL} - - Lock lock.sh - Shutdown doas shutdown -h now - Restart doas shutdown -r now + Programs +  Web Browser "${BROWSER}" +  File Viewer "${TERMINAL}" -c "${FILE_VIEWER}" -e "${FILE_VIEWER}" +  Text Editor "${TERMINAL}" -c "${EDITOR}" -e "${EDITOR}" +  Music Player "${HOME}/.local/bin/bar/music.sh" -o +  Mail Client "${HOME}/.local/bin/bar/mail.sh" -o +  RSS Feed Reader "${HOME}/.local/bin/bar/rss.sh" -o +  YouTube "${TERMINAL}" -c "${YOUTUBE_CLIENT}" -e "${YOUTUBE_CLIENT}" +  Torrent Client "${TORRENT_CLIENT}" +  Image Editor "${IMAGE_EDITOR}" + Tools +  Terminal "${TERMINAL}" +  Screenshot "${HOME}/.local/bin/shot.sh" +  Password Manager "${HOME}/.local/bin/pass.sh" +  Wifi Menu iwd-dmenu +  Mixer "${HOME}/.local/bin/bar/vol.sh" -o + System +  Lock "${HOME}/.local/bin/lock.sh" +  Shutdown doas shutdown -h now +  Restart doas shutdown -r now EOF } diff --git a/.local/bin/shot.sh b/.local/bin/shot.sh @@ -21,7 +21,7 @@ main() { gf=$(printf '%s\n' "scale=10; ${g}/255" | bc) bf=$(printf '%s\n' "scale=10; ${b}/255" | bc) - scrot -a "$(slop -b 3 -c "${rf}","${gf}","${bf}",1.0 -f '%x,%y,%w,%h')" -q 100 -z -C 'screenshot' "${HOME}/pix/captures/%m-%d-%Y-%I-%M-%S.png" + scrot -a "$(slop -b 3 -c "${rf}","${gf}","${bf}",1.0 -f '%x,%y,%w,%h')" -q 100 -z -C 'screenshot' "${PICTURES_DIR}/captures/%m-%d-%Y-%I-%M-%S.png" } main "${@}" diff --git a/.local/bin/wp.sh b/.local/bin/wp.sh @@ -128,6 +128,9 @@ main() { *) path="${PWD}/${1}" ;; esac + # handle symlinks + path="$("${HOME}/.local/bin/symlink.sh" "${path}")" + # if dir get rand file if [ -d "${path}" ]; then get_rand_file "${path}" && wp "${file}" diff --git a/.local/share/wp b/.local/share/wp @@ -1 +1 @@ -/home/mc/pix/wp/cassettes.jpg -\ No newline at end of file +/home/mc/pix/wp/paladin-charge.jpg +\ No newline at end of file