dots

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

commit ac4e93a6ab6935397e4e18ebc0f87897e9062099
parent b223c318d259419bdf61f116546a3d483b2af0cb
Author: Matthew Carlson <matt@mcarlson.xyz>
Date:   Tue, 31 May 2022 16:40:51 -0400

rss and torr; fixed mpv and hosts; other small changes here and there

Diffstat:
M.config/mimeapps.list | 4++++
A.config/mpv/input.conf | 1+
M.config/mpv/mpv.conf | 6+++---
M.config/mutt/muttrc | 4++--
M.config/ncmpcpp/config | 3++-
A.config/newsboat/config | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M.config/sh/aliasrc | 12+++++++-----
M.config/sh/functionrc | 1+
M.config/sh/profile | 2++
A.config/transmission-daemon/settings.json | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A.config/tremc/settings.cfg | 36++++++++++++++++++++++++++++++++++++
M.config/x/xprofile | 1+
M.config/x/xresources | 32++++++++++++++++----------------
M.config/zathura/zathurarc | 54+++++++++++++++++++++++++++---------------------------
M.local/bin/bar/monitor.sh | 6+++---
M.local/bin/bar/pkgs.sh | 2+-
A.local/bin/bar/rss.sh | 55+++++++++++++++++++++++++++++++++++++++++++++++++++++++
A.local/bin/bar/torr.sh | 91+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M.local/bin/bar/vol.sh | 36++++++++++++++++++++----------------
M.local/bin/hosts.sh | 11+++++------
A.local/bin/links.sh | 84+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M.local/bin/menu.sh | 2++
M.local/bin/open.sh | 5+++++
A.local/bin/thumb.sh | 18++++++++++++++++++
M.local/bin/vultr.sh | 2+-
A.local/share/applications/torr.desktop | 2++
M.local/share/wp | 4++--
27 files changed, 542 insertions(+), 83 deletions(-)

diff --git a/.config/mimeapps.list b/.config/mimeapps.list @@ -4,6 +4,7 @@ application/epub+zip=doc.desktop application/json=txt.desktop application/pdf=doc.desktop +application/x.bittorrent=torr.desktop application/x-tex=txt.desktop # audio @@ -53,3 +54,6 @@ video/mp4=vid.desktop video/webm=vid.desktop video/x-matroska=vid.desktop video/x-msvideo=vid.desktop + +# url handler for magnet links +x-scheme-handler/magnet=torr.desktop diff --git a/.config/mpv/input.conf b/.config/mpv/input.conf @@ -0,0 +1 @@ +I cycle-values vf "sub,lavfi=negate" "" diff --git a/.config/mpv/mpv.conf b/.config/mpv/mpv.conf @@ -25,7 +25,7 @@ screenshot-jpeg-quality = 100 screenshot-png-compression = 0 screenshot-tag-colorspace = 'yes' screenshot-template = '%F-%wH-%wM-%wS-%wT' -screenshot-directory = '~/pix/captures' +screenshot-directory = '~/pix/shots' # sub blend-subtitles = 'yes' @@ -51,12 +51,12 @@ deband-grain = 48 deband-iterations = 4 deband-range = 16 deband-threshold = 48 -deband = 'yes' +#deband = 'yes' dscale-antiring = 0.0 force-seekable = 'yes' hr-seek-framedrop = 'no' interpolation = 'yes' -profile = 'gpu-hq' +#profile = 'gpu-hq' scale-antiring = 0.0 video-sync = 'audio' vo = 'gpu' diff --git a/.config/mutt/muttrc b/.config/mutt/muttrc @@ -38,7 +38,7 @@ bind index,pager \Co sidebar-open color attachment bold color2 default color body bold color2 default "(https?|ftp)://[\-\.,/%~_:?&=\#a-zA-Z0-9]+" color body bold color2 default "[\-\.+_a-zA-Z0-9]+@[\-\.a-zA-Z0-9]+" -color error bold color1 default +color error bold color6 default color hdrdefault bold color2 default color index bold default default '~N' color index_author bold default default '~N' @@ -55,7 +55,7 @@ color quoted2 color4 default color quoted3 color5 default color quoted4 color6 default color sidebar_divider color7 default -color sidebar_highlight bold color3 default +color sidebar_highlight bold color2 default color status bold color0 color2 color tilde color0 default diff --git a/.config/ncmpcpp/config b/.config/ncmpcpp/config @@ -13,7 +13,8 @@ selected_item_prefix = $3 selected_item_suffix = $3 modified_item_prefix = $3 song_window_title_format = {%a - }{%t}|{%f} -song_columns_list_format = (20)[green]{a} (6f)[green]{NE} (50)[white]{t|f:Title} (20)[green]{b} (7f)[green]{l} +#song_columns_list_format = (20)[green]{a} (6f)[green]{NE} (50)[white]{t|f:Title} (20)[green]{b} (7f)[green]{l} +song_columns_list_format = (5f)[green]{d} (6f)[green]{NE} (0)[white]{t} (5f)[green]{l} volume_change_step = 1 user_interface = alternative media_library_primary_tag = genre diff --git a/.config/newsboat/config b/.config/newsboat/config @@ -0,0 +1,83 @@ +# bindings +unbind-key -a +bind-key ENTER open +bind-key q quit +bind-key r reload +bind-key R reload-all +bind-key A mark-feed-read +bind-key l next +bind-key RIGHT next +bind-key h prev +bind-key LEFT prev +bind-key o open-in-browser +bind-key ? help +bind-key u show-urls +bind-key / open-search +bind-key : cmdline +bind-key 1 cmd-one +bind-key 2 cmd-two +bind-key 3 cmd-three +bind-key 4 cmd-four +bind-key 5 cmd-five +bind-key 6 cmd-six +bind-key 7 cmd-seven +bind-key 8 cmd-eight +bind-key 9 cmd-nine +bind-key k up +bind-key UP up +bind-key j down +bind-key DOWN down +bind-key m macro-prefix + +# colors +color background default default +color listnormal white default +color listfocus green default bold +color listnormal_unread white default bold +color listfocus_unread green default bold +color title black green bold +color info black green bold +color hint-key black green bold +color hint-keys-delimiter black green bold +color hint-separator black green bold +color hint-description black green bold +color article default default + +# misc +always-display-description yes +articlelist-format "%-3i %f%D %t" +articlelist-title-format "%N %V - %T" +browser "links.sh %u" +confirm-delete-all-articles no +confirm-mark-all-feeds-read no +confirm-mark-feed-read no +datetime-format "%Y-%m-%d" +display-article-progress no +download-retries 10 +download-timeout 60 +# feed-sort-order firsttag +feedlist-format "%?T?┃ %-3i %n %t %u&┣━ %t %>━?" +feedlist-title-format "%N %V - Feeds" +goto-next-feed no +highlight article "^(Feed|Title|Author|Date|Link(s)?):.*$" green default bold +highlight article "^\[[0-9]+\]:\ .*\ [(].+[)]$" green default bold +highlight article "(\\w+)(\\.|_)?(\\w*)@(\\w+)(\\.(\\w+))+" green default bold +highlight article "((http|https)://)(www.)?[a-zA-Z0-9@:%._\\+~#?&//=]{2,256}\\.[a-z]{2,6}\\b([-a-zA-Z0-9@:%._\\+~#?&//=]*)" green default bold +highlight article "\\[[0-9]+\\]" green default bold +highlight article "\\[image [0-9]+ \\(link #[0-9]+\\)\\]" green default bold +highlight articlelist "^[0-9]+\ +(N|D)?\ +" green default bold +highlight feedlist "\ *[0-9]+\ +N?\ +" green default bold +highlight feedlist "[(][0-9]*\/[0-9]*[)]" green default bold +highlight feedlist "┃" green default bold +highlight feedlist "┣.*" green default bold +history-limit 0 +itemview-title-format "%N %V - %T" +refresh-on-startup yes +reload-threads 100 +reload-time 0 +save-path "~/dl" +searchresult-title-format "%N %V - Search" +search-highlight-colors green default bold +show-keymap-hint no +wrap-scroll yes +highlight articlelist "[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])" green default bold diff --git a/.config/sh/aliasrc b/.config/sh/aliasrc @@ -92,9 +92,11 @@ alias ${MAIL_CLIENT}='"${HOME}/.local/bin/bar/mail.sh" -o' # all programs that rely on youtube-dl should work # https://github.com/yt-dlp/yt-dlp alias \ - yt='youtube-dl -i -o "${DOWNLOADS_DIR}/%(uploader)s/%(title)s.%(ext)s" --add-metadata' \ - yta='yt -f bestaudio/best -x' \ - 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' \ + yt='youtube-dl -i -o "${DOWNLOADS_DIR}/%(uploader)s/%(title)s.%(ext)s" --add-metadata' \ + yta='yt -f bestaudio/best -x' \ + yts='youtube-dl --sub-lang en --write-sub --convert-subs=srt --skip-download' \ + ytp='youtube-dl -i -o "${DOWNLOADS_DIR}/%(uploader)s/%(playlist_index)s-%(title)s.%(ext)s" --add-metadata' \ + ytpa='ytp -f bestaudio/best -x' \ + ytps='youtube-dl --sub-lang en --write-sub --convert-subs=srt --skip-download -i -o "${DOWNLOADS_DIR}/%(uploader)s/%(playlist_index)s-%(title)s.%(ext)s"' \ + ytall='yt -cw -f best' \ ytw='${YOUTUBE_CLIENT}' diff --git a/.config/sh/functionrc b/.config/sh/functionrc @@ -6,3 +6,4 @@ f() { fff "${@}" && cd "$(cat "${XDG_CACHE_HOME:-${HOME}/.cache/}/fff/.fff_d")" s() { du -a "${HOME}" | awk '{ $1="" } { gsub("^ ", "", $0); print "\"" $0 "\"" }' | fzf | sed -e 's/^.//' -e 's/.$//' | open.sh ; } rands() { </dev/urandom tr -dc 'A-Za-z0-9!"#$%&'\''()*+,-./:;<=>?@[\]^_`{|}~' | head -c "${1}"; printf '\n' ; } rp() { for f in *; do mv "${f}" "$(printf '%s\n' "${f}" | sed "s/${1}/${2}/g")"; done ; } +utl() { for f in *; do mv "${f}" "$(printf '%s\n' "${f}" | tr '[:upper:]' '[:lower:]')"; done ; } diff --git a/.config/sh/profile b/.config/sh/profile @@ -21,7 +21,9 @@ export READER='zathura' export YOUTUBE_CLIENT='ytfzf' export IMG_VIEWER='feh' export MIXER='alsamixer' +export TORRENT_CLIENT='tremc' export IMAGE_EDITOR='gimp-2.99' +export RSS_READER='newsboat' # xdg base directories export XDG_CONFIG_HOME="${HOME}/.config/" diff --git a/.config/transmission-daemon/settings.json b/.config/transmission-daemon/settings.json @@ -0,0 +1,68 @@ +{ + "alt-speed-down": 0, + "alt-speed-enabled": false, + "alt-speed-time-begin": 0, + "alt-speed-time-day": 0, + "alt-speed-time-enabled": false, + "alt-speed-time-end": 0, + "alt-speed-up": 0, + "bind-address-ipv4": "0.0.0.0", + "bind-address-ipv6": "::", + "blocklist-enabled": false, + "blocklist-url": "http://www.example.com/blocklist", + "cache-size-mb": 16, + "dht-enabled": true, + "download-dir": "/home/mc/dl/", + "download-queue-enabled": false, + "download-queue-size": -1, + "encryption": 1, + "idle-seeding-limit": 0, + "idle-seeding-limit-enabled": true, + "incomplete-dir": "/home/mc/dl/", + "incomplete-dir-enabled": false, + "lpd-enabled": false, + "message-level": 0, + "peer-congestion-algorithm": "", + "peer-id-ttl-hours": 0, + "peer-limit-global": 65535, + "peer-limit-per-torrent": 65535, + "peer-port": 61619, + "peer-port-random-high": 65535, + "peer-port-random-low": 49152, + "peer-port-random-on-start": true, + "peer-socket-tos": "default", + "pex-enabled": true, + "port-forwarding-enabled": true, + "preallocation": 2, + "prefetch-enabled": true, + "queue-stalled-enabled": false, + "queue-stalled-minutes": 0, + "ratio-limit": 0, + "ratio-limit-enabled": true, + "rename-partial-files": false, + "rpc-authentication-required": false, + "rpc-bind-address": "0.0.0.0", + "rpc-enabled": true, + "rpc-host-whitelist": "", + "rpc-host-whitelist-enabled": false, + "rpc-password": "{e289f8a6e6c6829cf34b7c8ea6cd97498c1381caMfBs6RQq", + "rpc-port": 9091, + "rpc-url": "/transmission/", + "rpc-username": "", + "rpc-whitelist": "", + "rpc-whitelist-enabled": false, + "scrape-paused-torrents-enabled": false, + "script-torrent-done-enabled": true, + "script-torrent-done-filename": "/home/mc/.local/bin/bar/torr.sh", + "seed-queue-enabled": true, + "seed-queue-size": 0, + "speed-limit-down": 4294966, + "speed-limit-down-enabled": false, + "speed-limit-up": 0, + "speed-limit-up-enabled": true, + "start-added-torrents": true, + "trash-original-torrent-files": false, + "umask": 18, + "upload-slots-per-torrent": 0, + "utp-enabled": true +} diff --git a/.config/tremc/settings.cfg b/.config/tremc/settings.cfg @@ -0,0 +1,36 @@ +[Connection] +host = localhost +port = 9091 +path = /transmission/rpc + +[Sorting] +order = addedDate + +[Colors] +header = bg:default,fg:green +footer = bg:default,fg:green +title_seed = bg:default,fg:blue +title_download = bg:default,fg:default +title_idle = bg:default,fg:default +title_incomplete = bg:default,fg:default +title_verify = bg:default,fg:default +title_paused = bg:default,fg:default +title_error = bg:default,fg:cyan +download_rate = bg:default,fg:green +upload_rate = bg:default,fg:green +eta+ratio = bg:default,fg:green +filter_status = bg:default,fg:green +multi_filter_status = bg:default,fg:green +window = bg:green,fg:black +dialog = bg:green,fg:black +dialog_important = bg:green,fg:black +file_prio_high = fg:green,bg:default +file_prio_normal = fg:green,bg:default +file_prio_low = fg:green,bg:default +file_prio_off = fg:green,bg:default + +[Misc] +lines_per_torrent = 1 +torrentname_is_progressbar = False +file_viewer = xdg-open %%s +file_open_in_terminal = True diff --git a/.config/x/xprofile b/.config/x/xprofile @@ -9,5 +9,6 @@ xrdb "${XDG_CONFIG_HOME:-${HOME}/.config/}/x/xresources" feh --no-fehbg --bg-scale "${XDG_DATA_HOME:-${HOME}/.local/share/}/wp" xclickroot -r "${HOME}/.local/bin/menu.sh" & mpd & +transmission-daemon & unclutter & xset m 0 0 r rate 250 50 s noblank diff --git a/.config/x/xresources b/.config/x/xresources @@ -1,20 +1,20 @@ ! colors -#define col0 #17100c -#define col1 #936521 -#define col2 #9f6f5c -#define col3 #bd904a -#define col4 #a67e81 -#define col5 #c8b3b1 -#define col6 #d5caca -#define col7 #e9e3df -#define col8 #a39e9c -#define col9 #936521 -#define col10 #9f6f5c -#define col11 #bd904a -#define col12 #a67e81 -#define col13 #c8b3b1 -#define col14 #d5caca -#define col15 #e9e3df +#define col0 #090c09 +#define col1 #636655 +#define col2 #8a6938 +#define col3 #8a7657 +#define col4 #76857d +#define col5 #988f6e +#define col6 #c2ac5e +#define col7 #c7c7bf +#define col8 #8b8b85 +#define col9 #636655 +#define col10 #8a6938 +#define col11 #8a7657 +#define col12 #76857d +#define col13 #988f6e +#define col14 #c2ac5e +#define col15 #c7c7bf ! 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 '#e9e3df' -set completion-bg '#17100c' +set completion-fg '#c7c7bf' +set completion-bg '#090c09' # Command line completion group elements -set completion-group-fg '#9F6F5C' -set completion-group-bg '#17100c' +set completion-group-fg '#8A6938' +set completion-group-bg '#090c09' # Current command line completion element -set completion-highlight-fg '#17100c' -set completion-highlight-bg '#e9e3df' +set completion-highlight-fg '#090c09' +set completion-highlight-bg '#c7c7bf' # Default foreground/background color -set default-bg rgba(23,16,12,0.95) +set default-bg rgba(9,12,9,0.95) # Input bar -set inputbar-fg '#e9e3df' -set inputbar-bg '#17100c' +set inputbar-fg '#c7c7bf' +set inputbar-bg '#090c09' # Notification -set notification-fg '#e9e3df' -set notification-bg '#17100c' +set notification-fg '#c7c7bf' +set notification-bg '#090c09' # Error notification -set notification-error-fg '#e9e3df' -set notification-error-bg '#936521' +set notification-error-fg '#c7c7bf' +set notification-error-bg '#636655' # Warning notification -set notification-warning-fg '#e9e3df' -set notification-warning-bg '#936521' +set notification-warning-fg '#c7c7bf' +set notification-warning-bg '#636655' # Tab - TODO # set tabbar-fg @@ -58,25 +58,25 @@ set notification-warning-bg '#936521' # set tabbar-focus-bg # Status bar -set statusbar-fg '#e9e3df' -set statusbar-bg '#17100c' +set statusbar-fg '#c7c7bf' +set statusbar-bg '#090c09' # Highlighting parts of the document (e.g. show search results) -set highlight-color '#9F6F5C' -set highlight-active-color '#9F6F5C' +set highlight-color '#8A6938' +set highlight-active-color '#8A6938' # Represent light/dark colors in recoloring mode set recolor-lightcolor rgba(0,0,0,0) -set recolor-darkcolor '#e9e3df' +set recolor-darkcolor '#c7c7bf' # 'Loading...' text -set render-loading-fg '#e9e3df' -set render-loading-bg '#17100c' +set render-loading-fg '#c7c7bf' +set render-loading-bg '#090c09' # Index mode -set index-fg '#e9e3df' -set index-bg '#17100c' +set index-fg '#c7c7bf' +set index-bg '#090c09' # Selected element in index mode -set index-active-fg '#17100c' -set index-active-bg '#e9e3df' -\ No newline at end of file +set index-active-fg '#090c09' +set index-active-bg '#c7c7bf' +\ No newline at end of file diff --git a/.local/bin/bar/monitor.sh b/.local/bin/bar/monitor.sh @@ -53,13 +53,13 @@ main() { # bar usage case ${BLOCK_BUTTON} in - 4) set_brightness + 25 ;; - 5) set_brightness - 25 ;; + 4) set_brightness + 25 & ;; + 5) set_brightness - 25 & ;; esac # modify monitor brightness based on args # ${1} = +/- and ${2} = percentage - [ "${*}" ] && set_brightness "${1}" "${2}" + [ "${*}" ] && set_brightness "${1}" "${2}" & } main "${@}" diff --git a/.local/bin/bar/pkgs.sh b/.local/bin/bar/pkgs.sh @@ -144,7 +144,7 @@ bar() { } open() { - ${TERMINAL} -c "${TERMINAL}" -e pkgs.sh upgrade_pkgs + "${TERMINAL}" -c "${TERMINAL}" -e pkgs.sh upgrade_pkgs get_pkgs & } diff --git a/.local/bin/bar/rss.sh b/.local/bin/bar/rss.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# rss + +ICON='' +GET_ICON='' +TMP='/tmp/get-rss' + +bar() { + # is reloading + [ -f "${TMP}" ] && cat "${TMP}" && return + + # a decent way of finding out if prog is open without pgrep + # TODO: implement this in other scripts where ps -ef is used + if ps -ef | grep "${RSS_READER}" | tr -s ' ' | cut -f8- -d ' ' | grep -qx "${RSS_READER}"; then + printf '%s\n' "${ICON}" + else + # print unread articles + unread="$(newsboat -x print-unread | awk '{print $1}')" + printf '%s\n' "${ICON} ${unread}" + fi +} + +get_rss() { + printf '%s\n' "${GET_ICON}" > "${TMP}" + newsboat -x reload + # delay to ensure reload icon always shows + sleep 1 + rm -f "${TMP}" +} + +open() { "${TERMINAL}" -c "${RSS_READER}" -e "${RSS_READER}" ; } + +main() { + # called from bar + [ ${#} -eq 0 ] && bar + + # bar usage + case ${BLOCK_BUTTON} in + 1) open ;; + 2) get_rss ;; + esac + + while getopts 'go' opt; do + case "${opt}" in + # get rss if called with g flag + g) get_rss ;; + # open rss if o flag used + o) open ;; + *) return ;; + esac + done +} + +main "${@}" diff --git a/.local/bin/bar/torr.sh b/.local/bin/bar/torr.sh @@ -0,0 +1,91 @@ +#!/bin/sh +# +# torr + +ICON='' +TORRS="${XDG_CACHE_HOME:-${HOME}/.cache}/dots/bar/torrs" + +add() { + err && return 1 + + # add with transmission-remote, don't care about rpc output + # actual magnet link or file is ${2}; ${1} is -a flag + if transmission-remote -a "${2}" >/dev/null; then + # get added torrent name in nice format + # most recent torrent will be at bottom of list + torr="$(transmission-remote -l 2>/dev/null | tail -2 | head -1 | tr -s ' ')" + torr="${torr%% }" + torr="${torr## }" + torr="$(printf '%s\n' "${torr}" | cut -d ' ' -f9- | tr '+' ' ')" + + herbe "Added ${torr}" & + else + herbe 'Error adding torrent' & + return 1 + fi +} + +bar() { + daemon_not_running && [ -f "${TORRS}" ] && printf '%s\n' "${ICON} $(cat "${TORRS}")" && return + + [ -n "${TR_TORRENT_NAME}" ] && herbe "${TR_TORRENT_NAME} downloaded" + + torrs="$(transmission-remote -l 2>/dev/null | head -n -1 | tail -n +2)" + + unfinished="$(printf '%s\n' "${torrs}" | awk '{print $2}' | grep -v '100%' | grep -c '.')" + + printf '%s\n' "${unfinished}" > "${TORRS}" + + printf '%s\n' "${ICON} ${unfinished}" +} + +err() { + if daemon_not_running; then + herbe 'Torrent daemon is not active' & + return 0 + else + return 1 + fi +} + +open() { + err && return 1 + "${TERMINAL}" -c "${TORRENT_CLIENT}" -e "${TORRENT_CLIENT}" +} + +rmdone() { + daemon_not_running && printf '%s\n' 'Torrent daemon is not active' && return 1 + transmission-remote -l 2>/dev/null | awk '$2 == "100%" { system("transmission-remote -t "$1" -r >/dev/null") }' +} + +# torrent daemon must be running for program to work +daemon_not_running() { + tid="$(ps -ef | grep -i '\<transmission-daemon\>' | grep -iv '\<grep\>' | awk '{ printf "%s", $2 }')" + + if [ -n "${tid}" ]; then + return 1 + else + return 0 + fi +} + +main() { + [ ${#} -eq 0 ] && bar + + case ${BLOCK_BUTTON} in 1) open ;; esac + + while getopts 'aor' opt; do + case "${opt}" in + # add torrent + # argument should be torrent file or magnet file + a) add "${@}" ;; + # open torrent client + o) open ;; + # remove all completed torrents + r) rmdone ;; + *) return ;; + esac + done +} + +main "${@}" diff --git a/.local/bin/bar/vol.sh b/.local/bin/bar/vol.sh @@ -9,17 +9,18 @@ VOLUME_OFF_ICON='' VOLUME_MUTED_ICON='' get_scontrol() { - # Prefer Master but use PCM if not available - if amixer scontrols | grep -iq 'Master'; then scontrol='Master' - elif amixer scontrols | grep -iq 'PCM'; then scontrol='PCM' - fi + # use PCM, which affects audio data played by software + amixer scontrols | grep -iq 'PCM' && scontrol='PCM' } get_vol() { vol=$(amixer get "${scontrol}" -M | awk '{ for (i = 1; i<=NF; i++) { if ( $i ~ /\[[0-9][0-9]*%\]/ ) { print $i } } }' | head -n 1 | tr -d '[:punct:]') ; } toggle() { - [ "${scontrol}" = 'Master' ] && amixer set "${scontrol}" toggle - [ "${scontrol}" = 'PCM' ] && amixer set 'IEC958,5' toggle + amixer set 'Master' toggle + + is_muted && msg='Volume muted' || msg='Volume unmuted' + + env HERBE_ID=/0 herbe "${msg}" & } # set volume linearly @@ -29,18 +30,21 @@ set_vol() { env HERBE_ID=/0 herbe "Volume: ${vol}%" & } +is_muted() { + if amixer get 'Master' | sed 5q | grep -iq '\[off\]'; then + return 0 + fi + + return 1 +} + open() { "${TERMINAL}" -c "${MIXER}" -e "${MIXER}" ; } bar() { get_vol # check if muted - if [ "${scontrol}" = 'Master' ] || [ "${scontrol}" = 'PCM' ]; then - if amixer get "${scontrol}" | sed 5q | grep -iq '\[off\]' || \ - amixer get 'IEC958,5' | sed 4q | grep -iq '\[off\]'; then - printf '%s\n' "${VOLUME_MUTED_ICON} ${vol}%" && return - fi - fi + is_muted && printf '%s\n' "${VOLUME_MUTED_ICON} ${vol}%" && return # volume 0 is off, 1-33 is low, 34-66 is med, 67-100 is high case ${vol} in @@ -59,10 +63,10 @@ main() { # bar usage case ${BLOCK_BUTTON} in - 1) open ;; - 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 'ot' opt; do diff --git a/.local/bin/hosts.sh b/.local/bin/hosts.sh @@ -2,22 +2,21 @@ # # hosts -HOSTS_ENABLED_DIR='/etc/' -HOSTS_DISABLED_DIR="${HOME}/.local/share/" +HOSTS_DIR="${HOME}/.local/share/" -enable() { doas mv -v "${HOSTS_DISABLED_DIR}hosts" "${HOSTS_ENABLED_DIR}" && env HERBE_ID=/0 herbe 'Hosts enabled' & } +enable() { mv "${HOSTS_DIR}hosts.bak" "${HOSTS_DIR}hosts" && env HERBE_ID=/0 herbe 'Hosts enabled' & } -disable() { doas mv -v "${HOSTS_ENABLED_DIR}hosts" "${HOSTS_DISABLED_DIR}" && env HERBE_ID=/0 herbe 'Hosts disabled' & } +disable() { mv "${HOSTS_DIR}hosts" "${HOSTS_DIR}hosts.bak" && env HERBE_ID=/0 herbe 'Hosts disabled' & } main() { # in each of the following cases we want to sleep to prevent xcb unknown sequence number error # disable by moving hosts to xdg share directory - [ -f "${HOSTS_ENABLED_DIR}/hosts" ] && disable && sleep 1 && return 0 + [ -f "${HOSTS_DIR}/hosts" ] && disable && sleep 1 && return 0 # enable by moving hosts to /etc/ # shellcheck disable=SC3044 - [ -f "${HOSTS_DISABLED_DIR}/hosts" ] && enable && sleep 1 && return 0 + [ -f "${HOSTS_DIR}/hosts.bak" ] && enable && sleep 1 && return 0 } main "${@}" diff --git a/.local/bin/links.sh b/.local/bin/links.sh @@ -0,0 +1,84 @@ +#!/bin/sh +# +# links +# very similar to open.sh +# TODO: integrate this script with open.sh if i can get tee figured out + +# from Objective-C regexp given on urlregex.com +URL_REGEXP="(http|https)://((\\w)*|([0-9]*)|([-|_])*)+([\\.|/]((\\w)*|([0-9]*)|([-|_])*))+" + +main() { + match="$(printf '%s\n' "${@}" | grep -E "${URL_REGEXP}")" + + #shellcheck disable=SC2198 + if [ "${@}" = "${match}" ]; then + case "${@}" in + # audio + *.flac \ + | *.m4a \ + | *.mp3 \ + | *.ogg \ + | *.opus \ + | *.wav) + mpv --no-video "${@}" + ;; + + # gif + *.gif) + mpv --loop "${@}" + ;; + + # img + *.bmp \ + | *.dib \ + | *.ff \ + | *.ico \ + | *.iff \ + | *.jfi \ + | *.jfif \ + | *.jif \ + | *.jpe \ + | *.jpeg \ + | *.jpg \ + | *.lbm \ + | *.png \ + | *.pnm \ + | *.tga \ + | *.tif \ + | *.tiff \ + | *.webp \ + | *.xpm) + "${IMG_VIEWER}" "${@}" + ;; + + # vid + *.avi \ + | *.mkv \ + | *.mp4 \ + | *.webm \ + | *youtube.com* \ + | *youtu.be*) + mpv "${@}" + ;; + + # torr + *.torrent) + "${HOME}/.local/bin/bar/torr.sh" -a "${@}" + ;; + + # web/vector + *.htm \ + | *.html \ + | *.php \ + | *.svg \ + | *.xhtml \ + | *) + "${BROWSER}" "${@}" + ;; + esac + else + return 1 + fi +} + +main "${@}" diff --git a/.local/bin/menu.sh b/.local/bin/menu.sh @@ -10,7 +10,9 @@ main() {  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 Reader "${HOME}/.local/bin/bar/rss.sh" -o  YouTube "${TERMINAL}" -c "${YOUTUBE_CLIENT}" -e "${YOUTUBE_CLIENT}" +  Torrent Client "${HOME}/.local/bin/bar/torr.sh" -o  Image Editor "${IMAGE_EDITOR}"  Tools  Terminal "${TERMINAL}" diff --git a/.local/bin/open.sh b/.local/bin/open.sh @@ -70,6 +70,11 @@ main() { "${BROWSER}" "${opt}" ;; + # torrent + *.torrent) + "${HOME}/.local/bin/bar/torr.sh" -a "${opt}" + ;; + # everything else *) exec "${EDITOR:-vi}" "${opt}" </dev/tty diff --git a/.local/bin/thumb.sh b/.local/bin/thumb.sh @@ -0,0 +1,18 @@ +#!/bin/sh +# +# thumb + +main() { + youtube-dl -i --add-metadata \ + -f bestaudio/best -x \ + --embed-thumbnail \ + --convert-thumbnails png \ + --exec-before-download "ffmpeg -i %(thumbnails.-1.filepath)q -vf crop=\"'if(gt(ih,iw),iw,ih)':'if(gt(iw,ih),ih,iw)'\" _%(thumbnails.-1.filepath)q" \ + --exec-before-download "rm %(thumbnails.-1.filepath)q" \ + --exec-before-download "mv _%(thumbnails.-1.filepath)q %(thumbnails.-1.filepath)q" \ + -o "%(playlist_index)s-%(title)s.%(ext)s" \ + -k \ + "${@}" +} + +main "${@}" diff --git a/.local/bin/vultr.sh b/.local/bin/vultr.sh @@ -27,7 +27,7 @@ set -- ${snapshot_ids} oldest_snapshot_id="${1}" # Vultr only allows eleven(?) snapshots at this moment -SNAPSHOT_LIMIT=11 +SNAPSHOT_LIMIT=1 snapshot_count=$(printf '%s\n' "${snapshot_ids}" | wc -w) main() { diff --git a/.local/share/applications/torr.desktop b/.local/share/applications/torr.desktop @@ -0,0 +1,2 @@ +[Desktop Entry] +Exec=/home/mc/.local/bin/bar/torr.sh -a %U diff --git a/.local/share/wp b/.local/share/wp @@ -1 +1 @@ -/home/mc/pix/wp/dream-of-arcadia.jpg -\ No newline at end of file +/home/mc/pix/wp/morning-in-a-pine-forest.jpg +\ No newline at end of file