scripts

Utilitity scripts
git clone git://gtms.dev/scripts.git
Log | Files | Refs

commit 47ce6eca3ae06960884be1630ec00d1e680e75fb
parent 5c62dfc64f48426196f024a004cd566da310bdc2
Author: Tomas Nemec <nemi@skaut.cz>
Date:   Fri,  6 Aug 2021 15:47:52 +0200

cleanup

Diffstat:
Ddpgwdev | 38--------------------------------------
Ddpgwr | 37-------------------------------------
Dnewmails.sh | 18------------------
Dnewrss | 55-------------------------------------------------------
Dsfcut | 20--------------------
Msfd | 10++++++++--
Dsfeedmr | 4----
7 files changed, 8 insertions(+), 174 deletions(-)

diff --git a/dpgwdev b/dpgwdev @@ -1,38 +0,0 @@ -#!/bin/lua - -local ui = 'pub get && pub run build_runner serve web:8081 | track_run dart ui' -local ui_sass = 'sass --no-source-map --style compressed --load-path web/mdc --watch .' -local dw = 'pub get && pub run build_runner serve web:8082 | track_run dart dw' -local dw_sass = 'sass --no-source-map --style compressed --load-path web/mdc --watch .' -local digi = 'pub get && pub run build_runner serve web:8083 | track_run dart digi' -local digi_sass = 'sass --no-source-map --style compressed --load-path web/mdc --watch .' -local dpgw = 'mvn compile && mvn exec:java -Dexec.mainClass=org.medoro.dpgw.DPGWMain' -local dg = '~/dev/medoro/dpgw' - -os.execute(string.format('tmux new -s medoro -c %s -n %s -d', dg .. '/dpgw', 'dpgw')) -os.execute(string.format('tmux send-keys -t %s "%s" enter', 'dpgw', dpgw)) - -for _, a in ipairs(arg) do - if a == 'ui' then - print 'ui+sass' - os.execute(string.format('tmux neww -t %s: -n %s -c %s -d', 'medoro', 'ui', dg .. '/ui')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'ui', ui)) - os.execute(string.format('tmux neww -t %s: -n %s -c %s -d', 'medoro', 'ui_sass', dg .. '/ui')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'ui_sass', ui_sass)) - os.execute(string.format('tmux join-pane -t %s -s %s -t %s', 'medoro', 'ui_sass', 'ui')) - elseif a == 'dw' then - print 'dw+sass' - os.execute(string.format('tmux neww -t %s: -n %s -c %s -d', 'medoro', 'dw', dg .. '/dw')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'dw', dw)) - os.execute(string.format('tmux neww -t %s: -n %s -c %s -d', 'medoro', 'dw_sass', dg .. '/dw')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'dw_sass', dw_sass)) - os.execute(string.format('tmux join-pane -t %s -s %s -t %s', 'medoro', 'dw_sass', 'dw')) - elseif a == 'digi' then - print 'digi+sass' - os.execute(string.format('tmux neww -t %s: -n %s -c %s -d', 'medoro', 'digi', dg .. '/digi')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'digi', digi)) - os.execute(string.format('tmux neww -t %s: -n %s -c %s -d', 'medoro', 'digi_sass', dg .. '/digi')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'digi_sass', digi_sass)) - os.execute(string.format('tmux join-pane -t %s -s %s -t %s', 'medoro', 'digi_sass', 'digi')) - end -end diff --git a/dpgwr b/dpgwr @@ -1,37 +0,0 @@ -#!/bin/lua - -local ui = 'pub get && pub run build_runner serve web:8081 | track_run dart ui' -local ui_sass = 'sass --no-source-map --style compressed --load-path web/mdc --watch .' -local dw = 'pub get && pub run build_runner serve web:8082 | track_run dart dw' -local dw_sass = 'sass --no-source-map --style compressed --load-path web/mdc --watch .' -local digi = 'pub get && pub run build_runner serve web:8083 | track_run dart digi' -local digi_sass = 'sass --no-source-map --style compressed --load-path web/mdc --watch .' -local dpgw = 'mvn compile && mvn exec:java -Dexec.mainClass=org.medoro.dpgw.DPGWMain' - -for _, a in ipairs(arg) do - if a == 'ui' then - print 'ui+sass' - os.execute(string.format('tmux send-keys -t %s "^c"', 'medoro:ui.0')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'medoro:ui.0', ui)) - -- sass - os.execute(string.format('tmux send-keys -t %s "^c"', 'medoro:ui.1')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'medoro:ui.1', ui_sass)) - elseif a == 'dw' then - print 'dw+sass' - os.execute(string.format('tmux send-keys -t %s "^c"', 'medoro:dw.0')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'medoro:dw.0', dw)) - -- sass - os.execute(string.format('tmux send-keys -t %s "^c"', 'medoro:dw.1')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'medoro:dw.1', dw_sass)) - elseif a == 'digi' then - print 'digi+sass' - os.execute(string.format('tmux send-keys -t %s "^c"', 'medoro:digi.0')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'medoro:digi.0', digi)) - -- sass - os.execute(string.format('tmux send-keys -t %s "^c"', 'medoro:digi.1')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'medoro:digi.1', digi_sass)) - elseif a == 'dpgw' then - os.execute(string.format('tmux send-keys -t %s "^c"', 'medoro:dpgw')) - os.execute(string.format('tmux send-keys -t %s "%s" enter', 'medoro:dpgw', dpgw)) - end -end diff --git a/newmails.sh b/newmails.sh @@ -1,18 +0,0 @@ -#!/bin/sh -accounts="nemi medoro pruty" - -newmails() { - acc="$(echo $account)" - new=$(find "$HOME/.mail/$acc/INBOX/new/" -type f 2> /dev/null) - newcount=$(echo "$new" | sed '/^\s*$/d' | wc -l) -} - -out='' -for account in $accounts; do - newmails - if [ $(echo $newcount) -gt 0 ]; then - out="$out $account:$newcount" - fi -done - -echo $out diff --git a/newrss b/newrss @@ -1,55 +0,0 @@ -#!/bin/lua - -local filename = os.getenv("XDG_CACHE_HOME") .. "/newsboat" - -local action = arg[1] - --- cachefile -local cache_file = io.open(filename) -if cache_file == nil then - os.execute("touch " .. filename) - cache_file = io.open(filename) -end -local cache = cache_file:read("*a") -local unread_cache, diff_cache = cache:match("(%d+) (%d+)") -- last unread -unread_cache = tonumber(unread_cache) or 0 -diff_cache = tonumber(diff_cache) or 0 -cache_file:close() - --- get actual unread (no fetching) -local function get_unread() - local handle = io.popen("newsboat -x print-unread") - local unread_raw = handle:read() or unread_cache - handle:close() - return tonumber(string.match(unread_raw, "(%d+)")) -- actual unread -end - --- print data out -local function fmt(format) - if format == "polybar" then - io.write(string.format("RSS %d-%d", unread_cache, diff_cache, '\n')) - else - io.write(unread_cache, " ", diff_cache, "\n") - end -end - --- update cache file with actual unread (not fetching) -local function update_cache() - local unread = get_unread() - local diff = unread - unread_cache - if diff < 1 then - diff = 0 - end - io.open(filename, "w+"):write(unread, " ", diff):close() -end - --- handle -if action == "reload" then - os.execute("newsboat -x reload") - update_cache() -elseif action == "update" then - update_cache() - fmt(arg[2]) -else - fmt(action) -end diff --git a/sfcut b/sfcut @@ -1,20 +0,0 @@ -#!/bin/sh - -# TODO(tms) 23.05.2021: DIRECTORY - -feed="$1" -newfeed="$feed.new" - -if test -z $feed; then - echo "feed must be set" >&2 - exit 1 -fi - -awk -F '\t' -v "old=$(($(date +'%s') - 604800))" 'int($1) > old' < $feed > $newfeed - -bakfeed="$2" -if test -n "$bakfeed"; then - mv $feed $bakfeed -fi - -mv $newfeed $feed diff --git a/sfd b/sfd @@ -1,5 +1,11 @@ #!/bin/sh -url=$(sfeed_plain "$HOME/.sfeed/feeds/"* | dmenu -l 35 -i | \ +luncher="$BROWSER" +if command -v sfopen >/dev/null +then + luncher="sfopen" +fi + +url=$(sfeed_plain "$CACHE/sfeed/feeds/"* | dmenu -l 35 -i | \ sed -n 's@^.* \([a-zA-Z]*://\)\(.*\)$@\1\2@p') -test -n "${url}" && $BROWSER "${url}" +test -n "${url}" && $luncher "${url}" diff --git a/sfeedmr b/sfeedmr @@ -1,4 +0,0 @@ -#!/bin/sh - -feeds=$CACHE/sfeed/feeds/n_* -sfeed_plain $feeds | sed -n 's@^.* \([a-zA-Z]*://\)\(.*\)$@\1\2@p' | SFEED_URL_FILE=$CONFIG/sfeed/archive sfeed_markread read