From b9e00afded90f03ac18f75aa7dfc8e7f3e146348 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Tue, 3 Jan 2023 18:36:25 -0500 Subject: Added some scripts --- .local/bin/add2rss | 14 ++++++++++---- .local/bin/getUnicode | 12 ++++++++++++ .local/bin/jdm | 12 ++++++++++++ .local/bin/keys | 9 +++++++++ .local/bin/linkhandler | 26 ++++++++++++++++++++++++++ .local/bin/rebootPrompt | 3 +++ .local/bin/setWall | 6 ++++++ .local/bin/shutdownPrompt | 3 +++ .local/bin/volume | 7 +++++++ .local/bin/weather | 10 ++++++++++ 10 files changed, 98 insertions(+), 4 deletions(-) create mode 100755 .local/bin/getUnicode create mode 100755 .local/bin/jdm create mode 100755 .local/bin/keys create mode 100755 .local/bin/linkhandler create mode 100755 .local/bin/rebootPrompt create mode 100755 .local/bin/setWall create mode 100755 .local/bin/shutdownPrompt create mode 100755 .local/bin/volume create mode 100755 .local/bin/weather (limited to '.local/bin') diff --git a/.local/bin/add2rss b/.local/bin/add2rss index cf9ea73..ab29362 100755 --- a/.local/bin/add2rss +++ b/.local/bin/add2rss @@ -9,8 +9,14 @@ elif test ! -t 0; then URL=$(cat < /dev/stdin) else - echo "add2rss: No Input" - exit + URL=$(xclip -o clipboard) + if test -n "$URL"; + then + notify-send "add2rss: copied $URL from clipboard" + else + notify-send "add2rss: no input" + exit + fi fi if test -n "$2"; @@ -20,9 +26,9 @@ fi if test -n "$(grep $URL $RSSFILE)"; then - echo "add2rss: You already added this feed" + notify-send "add2rss: You already added this feed" else echo "$URL" >> $RSSFILE - echo "add2rss: Added" + notify-send "add2rss: Added" fi diff --git a/.local/bin/getUnicode b/.local/bin/getUnicode new file mode 100755 index 0000000..13d7971 --- /dev/null +++ b/.local/bin/getUnicode @@ -0,0 +1,12 @@ +#!/bin/sh + +char=$(cut -d ';' -f1 ~/.local/share/unicode | dmenu -i -l 30 | sed "s/ .*//") + +[ -z "$char" ] && exit + +if [ -n "$1" ]; then + xdotool type "$char" +else + echo "$char" | tr -d '\n' | xclip -selection clipboard + notify-send "'$char' copied to clipboard." & +fi diff --git a/.local/bin/jdm b/.local/bin/jdm new file mode 100755 index 0000000..d035b6e --- /dev/null +++ b/.local/bin/jdm @@ -0,0 +1,12 @@ +#!/bin/sh +declare -i count=1 # used as a reference throughout the script +for desktop in $XDG_DATA_HOME/xsessions/*.desktop # looks at all the desktop files in /usr/share/xsessions +do + name[$count]=$(grep "Name" $desktop | sed "s/Name=/$count /g") # grabs the name and adds it to an array + program[$count]=$(grep "Exec" $desktop | sed "s/Exec=//g") # grabs the path of the executable and adds it to an array + count=$((count+1)) +done +name[$count]="$count TTY" # adds an option for TTY +select=$(dialog --title "Jacob's Display Manager" --menu "Select a WM:" 0 0 0 ${name[*]} 3>&1 1>&2 2>&3 3>&-) # creates the menu box +[ "$select" != "$count" ] && [ "$select" != "0" ] && export wm=${program[$select]} && startx # startx if TTY is not selected +clear && cat /etc/motd # clears the ncurses prompt after executing and cat the message of the day file diff --git a/.local/bin/keys b/.local/bin/keys new file mode 100755 index 0000000..9d86b51 --- /dev/null +++ b/.local/bin/keys @@ -0,0 +1,9 @@ +#!/bin/sh +#Increase key speed +xset r rate 300 50 +#Map caps lock to super +setxkbmap -option caps:super -variant altgr-intl +#Make caps escape when pressed once +killall xcape 2>/dev/null ; xcape -e 'Super_L=Escape' +#Map the menu button next to RSuper to super +xmodmap -e 'keycode 135 = Super_R' diff --git a/.local/bin/linkhandler b/.local/bin/linkhandler new file mode 100755 index 0000000..c13a462 --- /dev/null +++ b/.local/bin/linkhandler @@ -0,0 +1,26 @@ +#!/bin/sh + +# Feed script a url or file location. +# If an image, it will view in sxiv, +# if a video or gif, it will view in mpv +# if a music file or pdf, it will download, +# otherwise it opens link in browser. + +if [ -z "$1" ]; then + url="$(xclip -o)" +else + url="$1" +fi + +case "$url" in + *mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtube.com/shorts*|*youtu.be*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*|*odysee.com*) + notify-send "linkhandler: launching $url in mpv" && setsid -f mpv -quiet "$url" >/dev/null 2>&1 ;; + *png|*jpg|*jpe|*jpeg|*gif) + curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && sxiv -a "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;; + *pdf|*cbz|*cbr) + curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && zathura "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;; + *mp3|*flac|*opus|*mp3?source*) + qndl "$url" 'curl -LO' >/dev/null 2>&1 ;; + *) + [ -f "$url" ] && setsid -f "$TERMINAL" -e "$EDITOR" "$url" >/dev/null 2>&1 || setsid -f "$BROWSER" "$url" >/dev/null 2>&1 +esac diff --git a/.local/bin/rebootPrompt b/.local/bin/rebootPrompt new file mode 100755 index 0000000..4c3c361 --- /dev/null +++ b/.local/bin/rebootPrompt @@ -0,0 +1,3 @@ +#!/bin/sh + +prompt 'Reboot?' 'sudo reboot' diff --git a/.local/bin/setWall b/.local/bin/setWall new file mode 100755 index 0000000..2e63a0a --- /dev/null +++ b/.local/bin/setWall @@ -0,0 +1,6 @@ +#!/bin/sh + +[ -f "$1" ] && cp "$1" ~/.config/wall.png +[ -d "$1" ] && cp "$(find "$1" -name "*.jpg" -o -name "*.png" -o -name "*.jpeg" -type f | shuf -n 1)" ~/.config/wall.png +xwallpaper --zoom ~/.config/wall.png + diff --git a/.local/bin/shutdownPrompt b/.local/bin/shutdownPrompt new file mode 100755 index 0000000..1be046d --- /dev/null +++ b/.local/bin/shutdownPrompt @@ -0,0 +1,3 @@ +#!/bin/sh + +prompt 'Shutdown?' 'sudo shutdown -h now' diff --git a/.local/bin/volume b/.local/bin/volume new file mode 100755 index 0000000..ba26561 --- /dev/null +++ b/.local/bin/volume @@ -0,0 +1,7 @@ +#!/bin/sh + +vol="$(pamixer --get-volume-human)" + +[ "$vol" == "muted" ] && label="🔇" || label="🔊 $vol" + +echo "$label" diff --git a/.local/bin/weather b/.local/bin/weather new file mode 100755 index 0000000..000ba1b --- /dev/null +++ b/.local/bin/weather @@ -0,0 +1,10 @@ +#!/bin/sh + +getforecast() { ping -q -c 1 1.1.1.1 >/dev/null || exit 1 +curl -sf "wttr.in/Ocean+City" > "$HOME/.cache/weatherreport" || exit 1 ;} + +showweather() { printf "%s" "$(sed '16q;d' "$HOME/.cache/weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/☔ /g" | tr -d '\n')" +sed '13q;d' "$HOME/.cache/weatherreport" | grep -o "m\\(-+\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ❄️",$1 "°","🌞",$2 "°"}' ;} + +[ "$(stat -c %y "$HOME/.cache/weatherreport" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] && getforecast +showweather -- cgit v1.2.3