From 86bda792526ffbd675afd3e0841cce517187bde6 Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Tue, 19 May 2020 16:55:44 -0400 Subject: added screencasting script, mail block, minor tweaks --- .i3blocks-mail.sh.swp | Bin 12288 -> 0 bytes abraham-porter.sh | 15 +++++++---- dict.sh | 6 ++--- i3blocks-mail.sh | 5 ++++ i3blocks-news.sh | 2 +- i3blocks-packages.sh | 2 +- i3blocks-screencast.sh | 3 +++ oldi3status.sh | 56 --------------------------------------- toggle-screencast.sh | 39 ++++++++++++++++++++++++++++ yt-player.sh | 69 +++++++++++++++++++++++++++++++++++++------------ 10 files changed, 114 insertions(+), 83 deletions(-) delete mode 100644 .i3blocks-mail.sh.swp create mode 100755 i3blocks-mail.sh create mode 100755 i3blocks-screencast.sh delete mode 100755 oldi3status.sh create mode 100755 toggle-screencast.sh diff --git a/.i3blocks-mail.sh.swp b/.i3blocks-mail.sh.swp deleted file mode 100644 index eae9649..0000000 Binary files a/.i3blocks-mail.sh.swp and /dev/null differ diff --git a/abraham-porter.sh b/abraham-porter.sh index ec4ca55..02a6b90 100755 --- a/abraham-porter.sh +++ b/abraham-porter.sh @@ -1,7 +1,8 @@ #!/bin/sh +## Abraham Porter - do things with ports + ## Configuration -dmenu="rofi -dmenu" doas="doas" terminal="alacritty" pager="rofi -location 2 -width -81 -e" @@ -23,14 +24,14 @@ NO_WANT_ANOTHER_PROVIDED=7 get_port() { cwd=$(pwd) cd "$ports_dir" - printf "%s\n" */* | $dmenu -p "Port" + printf "%s\n" */* | dmenu -p "Port" cd "$cwd" } ## Prompt user if they want to run command in a new term wants_term() { - choice=$(printf "no\nyes\n" | $dmenu -p "Do you want to do this in a new terminal?") + choice=$(printf "no\nyes\n" | dmenu -p "Do you want to do this in a new terminal?") [ $choice = "no" ] && return 1 [ $choice = "yes" ] && return 0 exit $NO_WANT_TERM_PROVIDED @@ -39,7 +40,7 @@ wants_term() { ## Gets an action from the user with dmenu get_action() { - action=$($dmenu -p "Abraham Porter" << EOF + action=$(dmenu -p "Abraham Porter" << EOF 1. print pkg-descr 2. set options 3. set options, add to pkglist @@ -87,11 +88,13 @@ handle_poudriere_options_single() { ## Handle running poudriere bulk on a single port handle_poudriere_bulk_single() { port="$1" + notify-send "Poudriere bulk started" "$port" if wants_term; then $terminal -e $doas poudriere bulk -j "$jail" $port else $doas poudriere bulk -j "$jail" $port fi + notify-send "Poudriere bulk finished" "$port" } @@ -103,16 +106,18 @@ handle_poudriere_options_pkglist() { ## Handle running poudriere bulk on pkglist handle_poudriere_bulk_pkglist() { + notify-send "Poudriere bulk started" "(pkglist)" if wants_term; then $terminal -e $doas poudriere bulk -j "$jail" -f "$pkglist" else $doas poudriere bulk -j "$jail" -f "$pkglist" fi + notify-send "Poudriere bulk finished" "(pkglist)" } get_another() { - choice=$($dmenu -p "Do you want another?" << EOF + choice=$(dmenu -p "Do you want another?" << EOF no yes EOF diff --git a/dict.sh b/dict.sh index 53c10df..137011a 100755 --- a/dict.sh +++ b/dict.sh @@ -1,8 +1,8 @@ #!/bin/sh + ## dict.sh - nicely look up words in dictionaries with dictd ## Configuration -dmenu="rofi -dmenu" pager="rofi -location 2 -width -81 -e" @@ -17,13 +17,13 @@ get_dict() { tail -n +2 | \ grep -v "fd" | \ sed 's/^ [a-z0-9-]* *//' | \ - $dmenu -i -p "Dictionary" + dmenu -i -p "Dictionary" } ## Get search term get_search_term() { - term=$(printf "Clipboard\nPrimary selection\n" | $dmenu -i -p "Search term") + term=$(printf "Clipboard\nPrimary selection\n" | dmenu -i -p "Search term") if [ "$term" = "Clipboard" ]; then echo "$(xclip -o -selection clipboard)" elif [ "$term" = "Primary selection" ]; then diff --git a/i3blocks-mail.sh b/i3blocks-mail.sh new file mode 100755 index 0000000..ecc45ff --- /dev/null +++ b/i3blocks-mail.sh @@ -0,0 +1,5 @@ +#!/bin/sh +icon=󰶋 + +unread=$(ls -l ~/.mail/gmail/Inbox/new | wc -l | cut -w -f2) +[ $unread -gt 0 ] && printf "%s%s\n" $icon $unread && notify-send "$unread unread emails" diff --git a/i3blocks-news.sh b/i3blocks-news.sh index c40b486..f5c4eb4 100755 --- a/i3blocks-news.sh +++ b/i3blocks-news.sh @@ -2,4 +2,4 @@ icon=󰎕 unread=$(newsboat -x print-unread | cut -d' ' -f1) -[ $unread -gt 0 ] && printf "$icon%s\n" $unread && notify-send "$unread unread articles in newsboat" +[ $unread -gt 0 ] && printf "$icon%s\n" $unread && notify-send "$unread unread articles" diff --git a/i3blocks-packages.sh b/i3blocks-packages.sh index 3717a01..992fc37 100755 --- a/i3blocks-packages.sh +++ b/i3blocks-packages.sh @@ -2,4 +2,4 @@ icon=󰏖 package_count=$(pkg upgrade -n | tail -1 | cut -s -d':' -f2) -[ $package_count -gt 0 ] && printf "$icon%s\n" $package_count && notify-send "$package_count package upgrades available" +[ $package_count -gt 0 ] && printf "$icon%s\n" $package_count && notify-send "$package_count package upgrade(s) available" diff --git a/i3blocks-screencast.sh b/i3blocks-screencast.sh new file mode 100755 index 0000000..c9b7d21 --- /dev/null +++ b/i3blocks-screencast.sh @@ -0,0 +1,3 @@ +#!/bin/sh +icon=󰻂 +[ -f /tmp/cast.mkv ] && printf "$icon\n" || printf "\n" diff --git a/oldi3status.sh b/oldi3status.sh deleted file mode 100755 index e1cb415..0000000 --- a/oldi3status.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -# Adam's custom i3status script. - -# Configuration variables. -ticker_length=5 # Ticker length in words. - -# Echo the text the ticker should scroll over. No newlines! -init_ticker() { - echo $(fortune | tr -d '\b\r\\' | tr -s '\n\t\v\f' ' ' | tr -s '"' "'") -} - -# Cut up text for ticker tape. -gen_ticker() { - echo $( - echo $text | cut -d' ' -f$word_index-$(( - $word_index + $ticker_length - 1 - )) - ) -} - -# Prints out valid JSON for i3status using given parameters. -printer() { - printf "\"full_text\":\"%s\"," "$1" - printf "\"align\":\"%s\"," "$2" - printf "\"min_width\":%d}," $3 -} - -# Main loop. -i3status | ( - read line && \ - echo "$line" && \ - read line && \ - echo "$line" && \ - read line && \ - echo "$line" && \ - while : -do - # Get i3status line. - read line - - # If ticker text is empty, re-initialize text and word index. Then generate - # ticker text. - [[ -z "$ticker_text" ]] && word_index=1 && text=$(init_ticker) - ticker_text=$(gen_ticker) && ((word_index += 1)) - - # Print i3status header string. - printf ",[{" - - # Print ticker tape JSON. - printer "$ticker_text" "left" 250 - - # Print the rest of the status string. - echo "${line#,\[}" - #printf "%s" $line - -done) diff --git a/toggle-screencast.sh b/toggle-screencast.sh new file mode 100755 index 0000000..dc26d63 --- /dev/null +++ b/toggle-screencast.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +## Config +output_dir=~/videos/screencasts +sound_device=/dev/dsp6 + + +## Start recording +start_recording() { + touch /tmp/cast.mkv + notify-send -t 3000 "Starting screencast." "3...2...1..." + sleep 4 + pkill -76 i3blocks + ffmpeg -video_size 1920x1080 \ + -framerate 50 \ + -thread_queue_size 512 -f x11grab -i :0.0+0,0 \ + -thread_queue_size 512 -f oss -i "$sound_device" \ + -vcodec libx264rgb -crf 0 -preset:v ultrafast \ + -acodec pcm_s16le \ + -af aresample=async=1:first_pts=0 \ + -y \ + /tmp/cast.mkv +} + + +## Stop recording +stop_recording() { + pkill -2 ffmpeg + output_file="$output_dir"/cast_"$(date '+%F-%H-%M-%S')".mkv + mv /tmp/cast.mkv "$output_file" + notify-send "Screencast saved" "$output_file" + pkill -76 i3blocks + exit +} + + +## Main +mkdir -p "$output_dir" +[ -f /tmp/cast.mkv ] && stop_recording || start_recording diff --git a/yt-player.sh b/yt-player.sh index cde337f..a5f21b8 100755 --- a/yt-player.sh +++ b/yt-player.sh @@ -1,21 +1,57 @@ #!/bin/sh -# Do things with a YouTube URL. - -read url -printf "$url" -test -z $url && exit -title="$(youtube-dl -e "$url")" - -choice=$(dmenu -i -p "$title" << EOF -Watch -Listen -Download video -Download audio -EOF -) - -case $choice in +## Do things with a YouTube URL. + +## Config +terminal=alacritty + + +## Notify the title and description of the URL +notify_info() { + url="$1" + info=$(youtube-dl --get-title --get-description --get-duration "$url") + title=$(echo "$info" | head -n 1) + description=$(echo "$info" | sed '1d;$d') + duration=$(echo "$info" | tail -n 1) + notify-send "$title : $duration" "$description" +} + + +## Main +notify_info "$1" && exit +option="$1" +case $option in + '-c') + url="$(xclip -o -selection clipboard)" + [ -z "$url" ] && exit $NO_URL_IN_CLIPBOARD + ;; + '-p') + url="$(xclip -o)" + [ -z "$url" ] && exit $NO_URL_IN_PRIMARY + ;; + '-u') + url="$2" + [ -z "$url" ] && exit $NO_URL_IN_SECOND_ARG + ;; + '-a') + $terminal -e mpv --no-video "$url" + ;; + '-da') + youtube-dl -x --audio-format flac --audio-quality 0 "$url" + ;; + '-v') + mpv --no-terminal "$url" + ;; + '-dv') + youtube-dl --add-metadata "$url" + ;; + *) + exit + ;; +esac + + +case $choice in "Watch") mpv "$url" --no-terminal & ;; @@ -31,4 +67,3 @@ case $choice in *) exit esac - -- cgit v1.2.3