From bb6ae22a0e084d60476cd44f8866ffdff33f529b Mon Sep 17 00:00:00 2001 From: lelgenio Date: Sun, 6 Jun 2021 17:02:47 -0300 Subject: [PATCH] scripts: add missing scripts and some new ones --- config.yaml | 2 +- dotfiles/dav/vdirsyncer/config | 4 +- dotfiles/fish/wm.fish | 4 +- .../share/applications/any-browser.desktop | 11 +++ dotfiles/neomutt/mbsyncrc | 2 +- dotfiles/neomutt/neomuttrc | 4 +- dotfiles/scripts/_mutt_get-mail | 2 +- dotfiles/scripts/_pam-gpg-strap | 2 +- dotfiles/scripts/any-browser | 10 +++ dotfiles/scripts/cdexec | 5 ++ dotfiles/scripts/forecast | 2 +- dotfiles/scripts/imgrs | 16 ++++ dotfiles/scripts/memegen | 88 +++++++++++++++++++ dotfiles/scripts/webcam | 2 +- dotfiles/sway/visual | 12 +-- dotfiles/waybar/config | 2 +- funcs.py | 2 +- 17 files changed, 151 insertions(+), 19 deletions(-) create mode 100644 dotfiles/mime/.local/share/applications/any-browser.desktop create mode 100755 dotfiles/scripts/any-browser create mode 100755 dotfiles/scripts/cdexec create mode 100755 dotfiles/scripts/imgrs create mode 100755 dotfiles/scripts/memegen diff --git a/config.yaml b/config.yaml index b819880..3e842cb 100644 --- a/config.yaml +++ b/config.yaml @@ -255,7 +255,7 @@ actions: pam_gpg: _pam-gpg-strap make_theme: _make_theme install_meta: install_meta - filter_backgrounds: _filter_backgrounds + filter_backgrounds: _backgrouds_filter ############################################################### dotfiles: # Just a bunch of paths and action mappings diff --git a/dotfiles/dav/vdirsyncer/config b/dotfiles/dav/vdirsyncer/config index 9f7c5b8..3aa3dab 100644 --- a/dotfiles/dav/vdirsyncer/config +++ b/dotfiles/dav/vdirsyncer/config @@ -46,7 +46,7 @@ fileext = ".vcf" type = "carddav" url = "https://cloud.{{@@ mail.personal.mail @@}}/remote.php/dav/addressbooks/users/{{@@ mail.personal.user @@}}/contacts/" username = "{{@@ mail.personal.user @@}}@{{@@ mail.personal.mail @@}}" -password.fetch = [ "command", "_get-pass", "{{@@ mail.personal.mail @@}}" ] +password.fetch = [ "command", "_pass_get", "{{@@ mail.personal.mail @@}}" ] # CALDAV [pair calendar] @@ -66,4 +66,4 @@ fileext = ".ics" type = "caldav" url = "https://cloud.{{@@ mail.personal.mail @@}}/remote.php/dav/calendars/{{@@ mail.personal.user @@}}/personal/" username = "{{@@ mail.personal.user @@}}@{{@@ mail.personal.mail @@}}" -password.fetch = [ "command", "_get-pass", "{{@@ mail.personal.mail @@}}" ] +password.fetch = [ "command", "_pass_get", "{{@@ mail.personal.mail @@}}" ] diff --git a/dotfiles/fish/wm.fish b/dotfiles/fish/wm.fish index bf7e731..6c9f4d2 100644 --- a/dotfiles/fish/wm.fish +++ b/dotfiles/fish/wm.fish @@ -35,12 +35,12 @@ function esway set -x XDG_CURRENT_DESKTOP sway # this should not be necessary, but whatever - pidof sway || exec sway + pidof sway &> /dev/null || exec sway end if test "$XDG_VTNR" = 1 - and test -z "$DISPLAY" + and test -z "$DISPLAY$WAYLAND_DISPLAY" esway &| tee .swaylog # ei3 &> .i3log diff --git a/dotfiles/mime/.local/share/applications/any-browser.desktop b/dotfiles/mime/.local/share/applications/any-browser.desktop new file mode 100644 index 0000000..3a306f6 --- /dev/null +++ b/dotfiles/mime/.local/share/applications/any-browser.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=Any Browser +Comment=A list of web browsers to try out +Icon=qutebrowser +Type=Application +Categories=Network;WebBrowser; +Exec=any-browser %u +Terminal=false +StartupNotify=true +MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/qute; +Keywords=Browser diff --git a/dotfiles/neomutt/mbsyncrc b/dotfiles/neomutt/mbsyncrc index 70ce3ad..6747507 100644 --- a/dotfiles/neomutt/mbsyncrc +++ b/dotfiles/neomutt/mbsyncrc @@ -4,7 +4,7 @@ IMAPStore {{@@ name @@}}-remote Host {{@@ info.mail @@}} Port 993 User {{@@ info.user @@}}@{{@@ info.mail @@}} -PassCmd "_get-pass {{@@ info.mail @@}}" +PassCmd "_pass_get {{@@ info.mail @@}}" SSLType IMAPS CertificateFile /etc/ssl/certs/ca-certificates.crt diff --git a/dotfiles/neomutt/neomuttrc b/dotfiles/neomutt/neomuttrc index af1bee2..d7521eb 100644 --- a/dotfiles/neomutt/neomuttrc +++ b/dotfiles/neomutt/neomuttrc @@ -19,7 +19,7 @@ set ssl_force_tls = yes {%@@ for name, info in mail.items() | reverse @@%} set my_source_command = \ - "_get-mutt-mail '{{@@ name @@}}' '{{@@ info.user @@}}' '{{@@ info.mail @@}}' |" + "_mutt_get-mail '{{@@ name @@}}' '{{@@ info.user @@}}' '{{@@ info.mail @@}}' |" folder-hook "$my_mailroot/{{@@ name @@}}/" \ source "\"$my_source_command\"" @@ -28,7 +28,7 @@ set my_source_command = \ {%@@ for name, info in mail.items() @@%} set my_source_command = \ - "_get-mutt-mail '{{@@ name @@}}' '{{@@ info.user @@}}' '{{@@ info.mail @@}}' |" + "_mutt_get-mail '{{@@ name @@}}' '{{@@ info.user @@}}' '{{@@ info.mail @@}}' |" macro index,pager "source \"$my_source_command\"!" {%@@ endfor @@%} diff --git a/dotfiles/scripts/_mutt_get-mail b/dotfiles/scripts/_mutt_get-mail index 4632137..f41e178 100755 --- a/dotfiles/scripts/_mutt_get-mail +++ b/dotfiles/scripts/_mutt_get-mail @@ -3,7 +3,7 @@ my_path="$1" my_user="$2" my_host="$3" -my_pass=`_get-pass "$my_host"` +my_pass=`_pass_get "$my_host"` cat < /dev/null < /dev/null & disown diff --git a/dotfiles/scripts/cdexec b/dotfiles/scripts/cdexec new file mode 100755 index 0000000..d4c33cc --- /dev/null +++ b/dotfiles/scripts/cdexec @@ -0,0 +1,5 @@ +#!/bin/sh + +cd "$1" +shift +exec $@ diff --git a/dotfiles/scripts/forecast b/dotfiles/scripts/forecast index f001d56..4789e77 100755 --- a/dotfiles/scripts/forecast +++ b/dotfiles/scripts/forecast @@ -10,7 +10,7 @@ owm(){ REGI=$(echo $INFO | jq -r '.region') COUN=$(echo $INFO | jq -r '.country') QUERY="$CITY, $REGI, $COUN" - APPID=`_get-pass OpenWeatherMapAPPID` + APPID=`_pass_get OpenWeatherMapAPPID` #{%@@ if False @@%}# notify-send "Get a free appid" xdg-open openweathermap.org & diff --git a/dotfiles/scripts/imgrs b/dotfiles/scripts/imgrs new file mode 100755 index 0000000..356072e --- /dev/null +++ b/dotfiles/scripts/imgrs @@ -0,0 +1,16 @@ +#!/bin/sh + + +set -x + +FILE="$1" + +SCALE="$2" +test -z "$SCALE" && + SCALE=`echo | wdmenu -p 'Scale'` + +OUTPUT="$3" +test -z "$OUTPUT" && + OUTPUT="${FILE}.resized.png" + +magick convert "$FILE" -scale "${SCALE}%" "$OUTPUT" diff --git a/dotfiles/scripts/memegen b/dotfiles/scripts/memegen new file mode 100755 index 0000000..5036120 --- /dev/null +++ b/dotfiles/scripts/memegen @@ -0,0 +1,88 @@ +#!/bin/fish + +set fish_trace 1 + +set progname (status basename) + +function warning + set_color yellow + echo "[$progname]" $argv >&2 + set_color --default +end + +function error + set_color brred + echo "[$progname]" $argv >&2 + set_color --default + exit 1 +end + +argparse --name="$progname" \ + 'i/input=' \ + 'o/output=' \ + 't/top=' \ + 'b/bottom=' \ + 's/scale=' \ + 'open' \ + 'f/force' \ + -- $argv + +set input "$_flag_input" +set output "$_flag_output" +set top "$_flag_top" +set bottom "$_flag_bottom" +set scale "$_flag_scale" +set force "$_flag_force" + +test -f "$input" +or error "No input file provided" + + +if test -z "$top""$bottom" + warning "No top or bottom text provided" + + test -n "$top" + or set top (echo | wdmenu -p 'Top text: ') + test -n "$bottom" + or set bottom (echo | wdmenu -p 'Bottom text: ') +end + +set original_name (basename "$input" | + string replace -r '\.\w+$' '') +set meme_text (string join - $top $bottom) + +test -n "$output" +or set output "$meme_text-$original_name.png" + +if test -f "$output" + and not set -q force + error "Output file exists" +end + +if set -q scale + set resized (mktemp -t memegen-XXXXX.png) + command magick convert "$input" -resize "$scale""%" "$resized" +else + set resized "$input" +end + +set size (magick identify -format "%[fx:w]x%[fx:h]" "$resized") + +command magick convert "$resized" \ + -gravity north \ + \( -size "$size" xc:none -font Impact -pointsize 50 -stroke black -strokewidth 7 -annotate 0 "$top" -blur 0x1 \) -composite \ + -font Impact -pointsize 50 -fill white -stroke none -annotate 0 "$top" \ + -gravity south \ + \( -size "$size" xc:none -font Impact -pointsize 50 -stroke black -strokewidth 7 -annotate 0 "$bottom" -blur 0x1 \) \ + -font Impact -pointsize 50 -fill white -stroke none -annotate 0 "$bottom" -composite \ + $argv "$output" + +if test "$input" != "$resized" + command rm "$resized" +end + +if set -q _flag_open + command xdg-open "$output" +end + +# vim: ft=fish diff --git a/dotfiles/scripts/webcam b/dotfiles/scripts/webcam index a075f42..232f338 100755 --- a/dotfiles/scripts/webcam +++ b/dotfiles/scripts/webcam @@ -1,3 +1,3 @@ #!/bin/sh -mpv av://v4l2:/dev/video0 --profile=low-latency --untimed & +mpv av://v4l2:/dev/video0 --profile=low-latency --untimed $@ & diff --git a/dotfiles/sway/visual b/dotfiles/sway/visual index 257bd2a..dfd1721 100644 --- a/dotfiles/sway/visual +++ b/dotfiles/sway/visual @@ -80,14 +80,16 @@ gaps inner 5px # Themes ############################################################### -set $gnome-schema org.gnome.desktop.interface +set $gnome_schema org.gnome.desktop.interface +set $no_desplay env DISPLAY="" WAYLAND_DISPLAY="" + exec_always { # In case of errors, kvantummanager opens a window # this is retarded - kvantummanager --set '{{@@ kvantum_theme @@}}' - gsettings set $gnome-schema gtk-theme '{{@@ gtk_theme @@}}' - gsettings set $gnome-schema icon-theme '{{@@ icon_theme @@}}' - gsettings set $gnome-schema cursor-theme '{{@@ cursor_theme @@}}' + $no_desplay kvantummanager --set '{{@@ kvantum_theme @@}}' + gsettings set $gnome_schema gtk-theme '{{@@ gtk_theme @@}}' + gsettings set $gnome_schema icon-theme '{{@@ icon_theme @@}}' + gsettings set $gnome_schema cursor-theme '{{@@ cursor_theme @@}}' } seat * xcursor_theme "{{@@ cursor_theme @@}}" "{{@@ cursor_size @@}}" diff --git a/dotfiles/waybar/config b/dotfiles/waybar/config index bbe113c..8491e28 100644 --- a/dotfiles/waybar/config +++ b/dotfiles/waybar/config @@ -174,7 +174,7 @@ "tooltip":false }, "custom/layout":{ - "exec":"_get-sway-layout", + "exec":"_sway_get-layout", "interval": 1, "tooltip":false }, diff --git a/funcs.py b/funcs.py index 627650d..129a65b 100644 --- a/funcs.py +++ b/funcs.py @@ -21,7 +21,7 @@ def rclone_obscure(pass_name): def sh(*args): return check_output(args).decode().strip() - return sh("rclone", "obscure", sh("_get-pass", pass_name)) + return sh("rclone", "obscure", sh("_pass_get", pass_name)) ####################################################################