diff --git a/scripts/romote b/scripts/romote new file mode 100755 index 0000000..9fae4d0 --- /dev/null +++ b/scripts/romote @@ -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) diff --git a/scripts/yt b/scripts/yt new file mode 100755 index 0000000..5b1eced --- /dev/null +++ b/scripts/yt @@ -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" diff --git a/scripts/yt_music b/scripts/yt_music new file mode 100755 index 0000000..328a355 --- /dev/null +++ b/scripts/yt_music @@ -0,0 +1,2 @@ +#!/bin/bash +format=ba yt "$@" diff --git a/sway/config b/sway/config index acf605d..1abeeb0 100644 --- a/sway/config +++ b/sway/config @@ -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