Compare commits

...

2 commits

Author SHA1 Message Date
97ebea9a88 add romote, yt, and yt_music scripts 2025-04-21 00:07:11 -04:00
347b8b1d1c better weather 2025-04-21 00:06:44 -04:00
6 changed files with 81 additions and 6 deletions

61
scripts/romote Executable file
View file

@ -0,0 +1,61 @@
#!/usr/bin/python
from blessed import Terminal
from pathlib import Path
import urllib.parse
import httpx
def roku(key):
match key:
case 'INSERT':key='PowerOn'
case 'DELETE':key='PowerOff'
case 'ESCAPE':key='Back'
case 'HOME'|'UP'|'LEFT'|'RIGHT'|'DOWN'|'BACKSPACE':pass
case 'ENTER':key='Select'
case 'PGUP':key='VolumeUp'
case 'PGDOWN':key='VolumeDown'
case 'END':key='VolumeMute'
case '?':key='InstantReplay'
case '/':key='Info'
case '<':key='Rev'
case 'TAB':key='Play'
case '>':key='Fwd'
case _:key=f'Lit_{urllib.parse.quote(key)}'
httpx.post(f"http://{IP}:8060/keypress/{key}")
path = Path("~/.romote").expanduser()
if not path.exists():
path.touch()
with path.open("r") as f:
IPs = [line.strip("\n").split(",") for line in f]
if IPs:
print("\n".join([f"{i+1}. {' - '.join(l)}" for i,l in enumerate(IPs)]))
IP = input("Choose one from the list, or add a new one: ")
IP = IPs[int(IP)-1][0] if int(IP) <= len(IPs) else "192.168.1."+IP
else:
IP = input("Enter the IP you want to use: ")
if len(IP) <= 3:IP = "192.168.1."+IP
if not any(existing[0] == IP for existing in IPs):
with path.open("a") as f:f.write(f"{IP}\n")
t = Terminal()
print(t.clear + IP)
print("Insert/Delete to power on or off")
print("Escape to go back")
print("Home to go home")
print("Arrow keys to navigate")
print("Enter for OK")
print("PageUp/PageDn to control volume")
print("End to mute")
print("? to replay")
print("/ to get info")
print("< to rewind")
print("Tab to play/pause")
print("> to fast-forward")
print("Use other keys to type")
while True:
with t.cbreak():
key = t.inkey()
if key.name:
roku(key.name.split("_")[1])
else:
roku(key)

13
scripts/yt Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
search="https://music.youtube.com/search?q="
if [ -z "$format" ]; then
options="--keep-open=yes"
search="ytsearch"
format="bv[height<=720]+ba/b"
fi
[ "$#" -gt 0 ] && url="$*" || url="$(timeout 0.1 cat)"
[ -z "$url" ] && url="$(wl-paste)"
[ -z "$url" ] && url="https://youtu.be/dQw4w9WgXcQ"
notify-send -t 1000 "$url" & mpv $options --ytdl-raw-options=default-search=$search --ytdl-format="$format" ytdl://"$url" || notify-send -t 3000 "Failed to play youtube video"

2
scripts/yt_music Executable file
View file

@ -0,0 +1,2 @@
#!/bin/bash
format=ba yt "$@"

View file

@ -70,8 +70,8 @@ bindgesture swipe:left workspace next
# Shortcuts
bindsym $mod+Return exec foot
bindsym $mod+d exec wmenu-run
bindsym $mod+y exec 'yt "$(wl-paste)"'
bindsym $mod+p exec foot -T "$(wl-paste)" -e sh -c 'yt_music "$(wl-paste -n)"'
bindsym $mod+y exec '~/.local/bin/yt "$(wl-paste)"'
bindsym $mod+p exec foot -T "$(wl-paste)" -e sh -c '~/.local/bin/yt_music "$(wl-paste -n)"'
bindsym $mod+s exec 'grim -g "$(slurp -d)" - | wl-copy'
bindsym Print exec 'grim - | swayimg -f -'
bindsym Mod4+e exec thunar

View file

@ -27,7 +27,6 @@
},
"custom/weather":{
"interval":600,
"return-type":"json",
"exec":"~/.config/waybar/scripts/wttr.sh"
},
"network#warp":{

View file

@ -1,3 +1,3 @@
wttr=$(curl -s "https://wttr.in/Louisville?m&format=%t")
tooltip=$(curl -s "https://wttr.in/Louisville?m&format=<u>%C</u>:RealFeel+%f:UV+Index+%u:Precip.+%p:Wind+%w"|sed 's/:/\\n/g')
echo -E "{\"text\":\"$wttr\",\"tooltip\":\"$tooltip\"}"
echo "Weather "
curl -s "https://wttr.in/Louisville?m0dQT"|tr '\n' '\r'
printf "Last Updated ";date +%T