From 9581bcc17487867c1794302b2c1c78cf62aad28a Mon Sep 17 00:00:00 2001 From: cheesus_crust Date: Tue, 14 Feb 2023 21:22:28 +0300 Subject: [PATCH] lets --- README.md | 1 + fedilives/owncast.sh | 13 ++++++++++ fedilives/peertube.sh | 59 ++++++++++++++++++++++++++++++++++++++++++ for_bigg/rtcdate.sh | 14 ++++++++++ for_bigg/ytmpdplay.sh | 31 ++++++++++++++++++++++ for_smol/bat.sh | 23 ++++++++++++++++ for_smol/bt.sh | 14 ++++++++++ for_smol/musicctrl.sh | 14 ++++++++++ for_smol/ytmpdplay.sh | 13 ++++++++++ for_smollest/sender.sh | 9 +++++++ 10 files changed, 191 insertions(+) create mode 100644 README.md create mode 100755 fedilives/owncast.sh create mode 100644 fedilives/peertube.sh create mode 100755 for_bigg/rtcdate.sh create mode 100755 for_bigg/ytmpdplay.sh create mode 100755 for_smol/bat.sh create mode 100644 for_smol/bt.sh create mode 100644 for_smol/musicctrl.sh create mode 100755 for_smol/ytmpdplay.sh create mode 100644 for_smollest/sender.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..e20d124 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +0/ diff --git a/fedilives/owncast.sh b/fedilives/owncast.sh new file mode 100755 index 0000000..1c11fba --- /dev/null +++ b/fedilives/owncast.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +: "${1?How to use: $0 OWNCAST_LINK }" + +url="$1" +link=$(echo "$url" | sed 's#https://##' | sed 's#/##' ) +echo + +xdg-open https://"$link"/embed/chat/readwrite & + +mpv https://"$link" & + +exit 0 diff --git a/fedilives/peertube.sh b/fedilives/peertube.sh new file mode 100644 index 0000000..a565b47 --- /dev/null +++ b/fedilives/peertube.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +: "${1?How to use: $0 PT_VIDEO_LINK}" + +link="$1" + +### Get HTML + +wget "$link" -O /tmp/videohtml + +### Variables + +videolink=$( grep "meta property" /tmp/videohtml | grep "og:video:url" \ + | sed 's/.*href="//' | sed 's#" />##') +chatver=$( grep 'peertube-plugin-livechat' /tmp/videohtml | grep 'version'\ + | sed 's#.*npmName..:..peertube-plugin-livechat.....name..:..livechat.....version..:..##' \ + | sed 's#.....description.....PeerTube plugin livechat: offers a way.*##' ) +instance=$(echo "$videolink" | sed 's#https://##' | sed 's#/videos/watch/.*##') +videoid=$(echo $videolink | sed 's#.*videos/watch/##') + +### Delete html + +rm /tmp/videohtml + +### Functions + +function live() +{ + xdg-open https://"$instance"/plugins/livechat/"$chatver"/router/webchat/room/"$videoid" & + mpv https://"$instance"/static/streaming-playlists/hls/"$videoid"/0.m3u8 & + exit 0 +} + +function nolive() +{ + mpv --ytdl-format=best "$videolink" + exit 0 +} + +### Choose + +echo +echo "Is it live? (Y/n)" +read -r is_live +echo + +case "$is_live" in +"" | "y") +live +;; +"n") +nolive +;; +* ) +echo "Ты, блять, дурак что ли? Белым по чёрному написано y или n" +;; +esac + +exit 0 diff --git a/for_bigg/rtcdate.sh b/for_bigg/rtcdate.sh new file mode 100755 index 0000000..ed94461 --- /dev/null +++ b/for_bigg/rtcdate.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +midnight=$(TZ=Europe/Moscow date +"%p") +# echo $midnight + +if [[ $midnight = "PM" ]] +then + # echo "PM" + rtcdate=$(TZ='Europe/Moscow' date --date='08:15 tomorrow' +"%Y%m%d%H%M%S") +else + # echo "AM" + rtcdate=$(TZ='Europe/Moscow' date --date='08:15' +"%Y%m%d%H%M%S") +fi +echo "$rtcdate" diff --git a/for_bigg/ytmpdplay.sh b/for_bigg/ytmpdplay.sh new file mode 100755 index 0000000..3a966a7 --- /dev/null +++ b/for_bigg/ytmpdplay.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +: "${1?How to use: $0 YT_VIDEO_LINK}" + +yt_link="$1" +play_link=$(yt-dlp -g "$yt_link" | sed '1d') + + +echo "Clear playlist? (N/y)" +read -r clearplay + +case "$clearplay" in +"y") +mpc clear 1>/dev/null +echo "Playlist cleared" +mpc add "$play_link" 1>/dev/null +mpc play 1>/dev/null +echo "Playing" +exit 0 +;; +"n") +echo "Adding" +;; +"") +echo "Adding" +;; +esac + +mpc add "$play_link" 1>/dev/null + +exit 0 diff --git a/for_smol/bat.sh b/for_smol/bat.sh new file mode 100755 index 0000000..bee94ab --- /dev/null +++ b/for_smol/bat.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +state=$(acpi -a) +# echo "$state" +if [[ "$state" = "Adapter 0: on-line" ]] +then + echo "Charging" + exit 0 +fi +bat=$(acpi -b | cut -b 25-27 | sed 's/%//') +echo "$bat %" +if [[ "$bat" = 100 ]] +then + echo "Full" + exit 0 +fi + +if [[ "$bat" -lt 20 ]] +then + echo "Suspending" + systemctl suspend + exit 0 +fi diff --git a/for_smol/bt.sh b/for_smol/bt.sh new file mode 100644 index 0000000..be95b21 --- /dev/null +++ b/for_smol/bt.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +power=$(bluetoothctl show | grep Powered) +echo "$power" +if [[ "$power" = " Powered: no" ]] +then + bluetoothctl power on + sleep 1 + bluetoothctl connect 68:D6:ED:28:EB:D9 + exit +else + bluetoothctl power off + exit +fi diff --git a/for_smol/musicctrl.sh b/for_smol/musicctrl.sh new file mode 100644 index 0000000..d0936ea --- /dev/null +++ b/for_smol/musicctrl.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +playerstatus=$(playerctl status) +echo "$playerstatus" +if [[ "$playerstatus" = "Playing" ]] +then + playerctl -a stop + exit 0 +fi +if [[ "$playerstatus" = "Stopped" ]] +then + playerctl play + exit 0 +fi diff --git a/for_smol/ytmpdplay.sh b/for_smol/ytmpdplay.sh new file mode 100755 index 0000000..f906e57 --- /dev/null +++ b/for_smol/ytmpdplay.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +: "${1?How to use: $0 YT_VIDEO_LINK}" + +yt_link="$1" + +play_link=$(yt-dlp -g "$yt_link" | sed '1d') + +mpc clear 1>/dev/null +mpc add "$play_link" 1>/dev/null +mpc play 1>/dev/null + +exit 0 diff --git a/for_smollest/sender.sh b/for_smollest/sender.sh new file mode 100644 index 0000000..2075ed3 --- /dev/null +++ b/for_smollest/sender.sh @@ -0,0 +1,9 @@ +# #!/data/data/com.termux/files/usr/bin/env bash + +host="$(grep 'Host ' .ssh/config | sed 's/Host //g' )" +echo "Sends message to $host " +echo +echo "Type message: " +read -r message + +ssh "$host" notify-send -u critical "MESSAGE" " '$message' "