From b3744af0ae35408904cbc20e84c1590026fcfe72 Mon Sep 17 00:00:00 2001 From: Nikotile Date: Tue, 28 May 2024 03:25:55 +0900 Subject: [PATCH] First commit --- .gitignore | 1 + Makefile | 10 ++++++++++ README.md | 1 + screenpick | 6 ++++++ screenshot | 9 +++++++++ subsonic-download | 42 ++++++++++++++++++++++++++++++++++++++++++ subsonic-stream | 42 ++++++++++++++++++++++++++++++++++++++++++ surfmenu | 11 +++++++++++ vim-gpg | 14 ++++++++++++++ 9 files changed, 136 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 README.md create mode 100755 screenpick create mode 100755 screenshot create mode 100755 subsonic-download create mode 100755 subsonic-stream create mode 100755 surfmenu create mode 100755 vim-gpg diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..65e3ba2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +test/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..65d3e59 --- /dev/null +++ b/Makefile @@ -0,0 +1,10 @@ +SCRIPTS = $(shell file * | grep "shell script" | cut -d ":" -f1) +DIR = $(HOME)/.local/bin + +.PHONY: install +install: + cp $(SCRIPTS) $(DIR) + +.PHONY: uninstall +uninstall: + $(foreach s, $(SCRIPTS),rm $(DIR)/$(s);) diff --git a/README.md b/README.md new file mode 100644 index 0000000..b8f88fd --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Because I want something specific or just for the good kek diff --git a/screenpick b/screenpick new file mode 100755 index 0000000..756377d --- /dev/null +++ b/screenpick @@ -0,0 +1,6 @@ +#!/bin/sh + +# Screenshot a selection of screen + +import png:- | xclip -selection clipboard -t image/png && + notify-send "Screenshot copied to clipboard" diff --git a/screenshot b/screenshot new file mode 100755 index 0000000..57ae14c --- /dev/null +++ b/screenshot @@ -0,0 +1,9 @@ +#!/bin/sh + +FILENAME="screen_$(date +%Y%m%d_%H%m%S).png" +DIR="$HOME/pictures/screenshots" + +[ -z "$DIR" ] && mkdir -p "$DIR" + +import -window root "$DIR/$FILENAME" | xclip -selection clipboard -t image/png && + notify-send --icon="$DIR/$FILENAME" "Screenshot taken" diff --git a/subsonic-download b/subsonic-download new file mode 100755 index 0000000..2589cd5 --- /dev/null +++ b/subsonic-download @@ -0,0 +1,42 @@ +#!/bin/sh + +# Return a stream URL from a Subsonic server + +#SUBSONIC_SERVER="https://example.com" +#SUBSONIC_USER="user" +#SUBSONIC_PASSWORD="password" + +tmp=$(mktemp -p /tmp/) + +printf "Enter your query\n-> " +read -r query + +curl -sG --data-urlencode "query=$query" \ + "$SUBSONIC_SERVER/rest/search3?u=$SUBSONIC_USER&p=$SUBSONIC_PASSWORD&v=1.16.1&c=bash&f=json" | + jq -s '[.[] | ."subsonic-response".searchResult3.song[] | {id:.id, title:.title, artist:.artist}] | [limit(5;.[])]' > "$tmp" + +[ -z "$(cat "$tmp")" ] && printf "\n\e[1;31m[!] \e[107;mNo result\n\n" && rm "$tmp" && exit 1 + +length=$(( "$(jq '. | length' "$tmp")" - 1)) +i=0 +printf "\n" +while [ "$i" -le "$length" ]; do + title=$(jq -s '.[] | .['"$i"'].title' "$tmp" | sed 's/\"//g') + artist=$(jq -s '.[] | .['"$i"'].artist' "$tmp" | sed 's/\"//g') + printf "\e[1;32m[%s] \e[107;m%s by %s\n" $(("$i"+1)) "$title" "$artist" + i=$((i + 1)) +done + +printf "\nSelect track number\n-> " && read -r number +number=$(( "$number" - 1 )) + +title=$(jq -r '.['"$number"'].title' "$tmp") +artist=$(jq -r '.['"$number"'].artist' "$tmp") +id=$(jq -r '.['$number'].id' "$tmp") + +url="$SUBSONIC_SERVER/rest/download?u=$SUBSONIC_USER&p=$SUBSONIC_PASSWORD&v=1.16.1&c=curl&f=json&id=$id" + +printf "%s" "$url" | xclip -sel c +printf "Copying the URL for \e[1;32m%s \e[107;mby %s to clipboard.\n" "$title" "$artist" + +rm "$tmp" diff --git a/subsonic-stream b/subsonic-stream new file mode 100755 index 0000000..b2e001d --- /dev/null +++ b/subsonic-stream @@ -0,0 +1,42 @@ +#!/bin/sh + +# Return a stream URL from a Subsonic server + +#SUBSONIC_SERVER="https://example.lol" +#SUBSONIC_USER="user" +#SUBSONIC_PASSWORD="password" + +tmp=$(mktemp -p /tmp/) + +printf "Enter your query\n-> " +read -r query + +curl -sG --data-urlencode "query=$query" \ + "$SUBSONIC_SERVER/rest/search3?u=$SUBSONIC_USER&p=$SUBSONIC_PASSWORD&v=1.16.1&c=bash&f=json" | + jq -s '[.[] | ."subsonic-response".searchResult3.song[] | {id:.id, title:.title, artist:.artist}] | [limit(5;.[])]' > "$tmp" + +[ -z "$(cat "$tmp")" ] && printf "\n\e[1;31m[!] \e[107;mNo result\n\n" && rm "$tmp" && exit 1 + +length=$(( "$(jq '. | length' "$tmp")" - 1)) +i=0 +printf "\n" +while [ "$i" -le "$length" ]; do + title=$(jq -s '.[] | .['"$i"'].title' "$tmp" | sed 's/\"//g') + artist=$(jq -s '.[] | .['"$i"'].artist' "$tmp" | sed 's/\"//g') + printf "\e[1;32m[%s] \e[107;m%s by %s\n" $(("$i"+1)) "$title" "$artist" + i=$((i + 1)) +done + +printf "\nSelect track number\n-> " && read -r number +number=$(( "$number" - 1 )) + +title=$(jq -r '.['"$number"'].title' "$tmp") +artist=$(jq -r '.['"$number"'].artist' "$tmp") +id=$(jq -r '.['$number'].id' "$tmp") + +url="$SUBSONIC_SERVER/rest/stream?u=$SUBSONIC_USER&p=$SUBSONIC_PASSWORD&v=1.16.1&c=curl&f=json&id=$id" + +printf "%s" "$url" | xclip -sel c +printf "Copying the URL for \e[1;32m%s \e[107;mby %s to clipboard.\n" "$title" "$artist" + +rm "$tmp" diff --git a/surfmenu b/surfmenu new file mode 100755 index 0000000..a025dde --- /dev/null +++ b/surfmenu @@ -0,0 +1,11 @@ +#!/bin/sh + +BOOKMARK_FILE_URL="https://example.com/bookmarks" + +[ ! -f "$XDG_DATA_HOME/bookmarks" ] && curl "$BOOKMARK_FILE_URL" > "$XDG_DATA_HOME"/bookmarks + +url="$(dmenu -l 5 -nb "#d2d971" -nf "#570580" -sb "#36121f" -sf "#bab6b8" < "$XDG_DATA_HOME"/bookmarks | grep -o "[a-z].*")" + +[ -z "$url" ] && exit + +surf "$url" diff --git a/vim-gpg b/vim-gpg new file mode 100755 index 0000000..0e84c56 --- /dev/null +++ b/vim-gpg @@ -0,0 +1,14 @@ +#!/bin/sh + +# Write in editor and encrypt with gpg + +printf "Enter recepient:\n-> " ; read -r RECEPIENT + +[ -z "$EDITOR" ] && EDITOR=vim + +tmp=$(mktemp -p /tmp/) +$EDITOR "$tmp" + +gpg -e --sign --armor --no-version -r "$RECEPIENT" < "$tmp" + +rm "$tmp"