summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xdock.sh7
-rwxr-xr-xundock.sh14
-rwxr-xr-xurl_handler.sh90
3 files changed, 10 insertions, 101 deletions
diff --git a/dock.sh b/dock.sh
index c6e9915..5e248d8 100755
--- a/dock.sh
+++ b/dock.sh
@@ -1,4 +1,5 @@
#!/bin/sh
-xrandr --output DP-3 --off --output DP-2 --auto --primary
-doas sysctl hw.acpi.lid_switch_state=NONE
-killall xautolock
+/bin/sleep 3
+/usr/local/bin/xrandr --output DP-3 --off --output DP-2 --auto --primary
+/sbin/sysctl hw.acpi.lid_switch_state=NONE
+/usr/local/bin/xautolock -disable
diff --git a/undock.sh b/undock.sh
index 1f84470..f4f9ec7 100755
--- a/undock.sh
+++ b/undock.sh
@@ -1,11 +1,5 @@
#!/bin/sh
-xrandr --output DP-3 --auto --primary --output DP-2 --off
-doas sysctl hw.acpi.lid_switch_state=S3
-killall xautolock
-xautolock \
- -killtime 10 \
- -killer "sleep 0.5; doas acpiconf -s3" \
- -notify 10 \
- -time 10 \
- -locker "i3lock -n -f -c 002b36 ; sleep 0.2" \
- -notifier "notify-send -t=10000 '10 seconds to lock...'" &
+/bin/sleep 3
+/usr/local/bin/xrandr --output DP-3 --auto --primary --output DP-2 --off
+/sbin/sysctl hw.acpi.lid_switch_state=S3
+/usr/local/bin/xautolock -enable
diff --git a/url_handler.sh b/url_handler.sh
index 55d225c..bbf383f 100755
--- a/url_handler.sh
+++ b/url_handler.sh
@@ -1,100 +1,14 @@
#!/bin/sh
-# Everything I would ever need to do with a URL.
-
-DOWNLOAD_DIR=$HOME/downloads
# Prompt for a URL or search term
get_url() {
dmenu -p "URL or search"
}
-# Action for YouTube URLs
-get_action() {
- action=$(dmenu -p "YouTube action" << EOF
-1. watch
-2. video download
-3. audio download
-EOF
- )
- echo "$action" | cut -d'.' -f1
-}
-
-
-# Get title, description, and duration of YouTube URL
-toast_info() {
- info=$(youtube-dl --get-title --get-description --get-duration "$1")
- title=$(echo "$info" | head -n 1)
- description=$(echo "$info" | sed '1d;$d')
- duration=$(echo "$info" | tail -n 1)
- notify-send "($duration) $title" "$description"
-}
-
-
-## Download video
-video_download() {
- mkdir -p "$DOWNLOAD_DIR"
- youtube-dl \
- -q \
- --add-metadata \
- -o "$DOWNLOAD_DIR/%(title)s_%(id)s.%(ext)s" \
- "$1" && notify-send "Video download done." &
- notify-send "Downloading video:"
-}
-
-
-## Download audio
-audio_download() {
- mkdir -p "$DOWNLOAD_DIR"
- youtube-dl \
- -q \
- --add-metadata \
- -o "$DOWNLOAD_DIR/%(title)s_%(id)s.%(ext)s" \
- -x \
- --audio-format flac \
- --audio-quality 0 \
- "$1" && notify-send "Audio download done." &
- notify-send "Downloading audio:"
-}
-
-
-## Play video
-play() {
- URL="${1#http?://}"
- mpv --no-terminal --geometry=25%-10-40 --title="Streaming from YouTube" "ytdl://$URL" &
- notify-send "Playing:"
-}
-
-# Handle YouTube URLs
-handle_youtube() {
- URL=$1
- toast_info "$URL" &
-
- case "$(get_action)" in
- 1)
- play "$URL"
- ;;
- 2)
- video_download "$URL"
- ;;
- 3)
- audio_download "$URL"
- esac
-}
-
-# Main
URL=$1
-[ -n "$URL" ] || URL=$(xclip -o)
+[ -n "$URL" ] || URL=$(xclip -selection clipboard -o)
[ -n "$URL" ] || URL=$(get_url)
[ -n "$URL" ] || exit
echo "$URL"
-case $URL in
- *youtube.com*) handle_youtube "$URL" ;;
- *youtu.be*) handle_youtube "$URL" ;;
- ytsearch:*) handle_youtube "$URL" ;;
- mailto*) mutt "$URL" ;;
- http?*) $BROWSER "$URL" ;;
- *)
- $BROWSER --search "$URL"
-esac
-
+xdg-open $URL