This commit is contained in:
2025-05-03 22:50:43 -07:00
parent de3a618acc
commit fbe79f77a6
229 changed files with 17049 additions and 0 deletions

1
.config/rofi/scripts/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
env

View File

@@ -0,0 +1,35 @@
#!/usr/bin/env python3
from subprocess import Popen
from sys import exit as sysexit
from pyperclip import paste
def notify(title, message, icon=None):
"""Use dunstify to send notifications"""
if icon:
Popen(["dunstify", title, message, "-i", icon])
else:
Popen(["dunstify", title, message])
if __name__ == "__main__":
url = paste()
if not url:
sysexit(1)
if not url.startswith("https://www.youtube.com/"):
notify(
"ERROR",
"URL is not from YouTube",
"/usr/share/icons/Dracula/scalable/apps/YouTube-youtube.com.svg",
)
sysexit(1)
with Popen(["/usr/bin/mpv", url]) as proc:
notify(
"rofi-mpv",
"Playing video",
"/usr/share/icons/Dracula/scalable/apps/YouTube-youtube.com.svg",
)
proc.wait()
if proc.returncode != 0:
sysexit(1)

View File

@@ -0,0 +1,60 @@
#!/usr/bin/env python
from pathlib import Path
from subprocess import Popen
from sys import exit as sysexit
from rofi import Rofi
CMD = ["feh", "--bg-scale"]
WALLPAPERS = {
"Maisan": Path("~/nextcloud/pictures/sauce/MYSanGun.png").expanduser().as_posix()
+ ","
+ Path("~/nextcloud/pictures/sauce/MYSanGun-Inverted.png").expanduser().as_posix(),
"Arch Logo (Purple)": Path(
"~/Pictures/wallpapers/Arch Linux (Text Purple).png"
).expanduser(),
"Arch Logo (Blue)": Path("~/Pictures/wallpapers/Arch Linux (Text Blue).png"),
"Arch Pacman": Path("~/Pictures/wallpapers/ArchPacman.png").expanduser(),
"Bash Hello World": Path("~/Pictures/wallpapers/Bash Hello World.png"),
"Bash rm -rf": Path("~/Pictures/wallpapers/Bash rm -rf 1.png").expanduser(),
"C++ Hello World": Path("~/Pictures/wallpapers/C++ Hello World.png").expanduser(),
"C Hello World": Path("~/Pictures/wallpapers/C Hello World.png").expanduser(),
"Python Hello World": Path(
"~/Pictures/wallpapers/Python Hello World.png"
).expanduser(),
"Jujutsu Kaisen": Path("~/Pictures/wallpapers/Jujutsu Kaisen 1.png").expanduser(),
"My Hero Academia": Path(
"~/Pictures/wallpapers/My Hero Academia 2.png"
).expanduser(),
"NASA Japan": Path("~/Pictures/wallpapers/NASA-Japan.png").expanduser(),
"Sasuke Seal": Path("~/Pictures/wallpapers/Sasuke Seal (Red).png").expanduser(),
"Import Rice": Path("~/Pictures/wallpapers/Import Rice Unixporn 1.png")
.expanduser()
.expanduser()
.as_posix()
+ ","
+ Path("~/Pictures/wallpapers/Import Rice Unixporn 2.png").expanduser().as_posix(),
}
if __name__ == "__main__":
rofi = Rofi(
config_file="~/Projects/Scripts/aniwrapper/themes/aniwrapper-dracula.rasi",
theme_str="configuration {dpi: 144;} window {width: 45%;} listview {columns: 3; lines: 5;}",
rofi_args=["-i"],
)
idx = rofi.select("Choose a wallpaper", sorted(WALLPAPERS.keys()))[0]
wallpaper = WALLPAPERS[list(sorted(WALLPAPERS.keys()))[idx]]
if isinstance(wallpaper, str) and "," in wallpaper:
wallpaper = wallpaper.split(",")
else:
wallpaper = [wallpaper]
print("wallpaper: {}".format(wallpaper))
if wallpaper is None or wallpaper == "":
sysexit(1)
cmd = CMD + wallpaper
print("cmd: {}".format(cmd))
with Popen(cmd) as proc:
proc.wait()

View File

@@ -0,0 +1 @@
#!/bin/sh

View File

@@ -0,0 +1,40 @@
#!/usr/bin/env python3
"""Edit the chosen config file"""
from subprocess import Popen
from rofi import Rofi
CMD = "kitty nvim {}"
CONFIGS = (
"~/.config/rofi/config.rasi",
"~/.config/nvim/init.vim",
"~/.config/rofi/scripts/rofi-open.py",
"~/.config/rofi/scripts/rofi-edit-config.py",
"~/.config/rofi/scripts/rofi-background.py",
"~/.config/sxhkd/sxhkdrc",
"~/.config/awesome/rc.lua",
"~/.config/awesome/bindings/keybindings.lua",
"~/.config/awesome/autorun.sh",
"~/.config/ranger/rc.conf",
"~/.config/ranger/rifle.conf",
"~/.config/ranger/scope.sh",
"~/.config/picom/picom.conf",
"~/.config/compfy/compfy.conf",
"~/.config/kitty/kitty.conf",
"~/.config/mpv/mpv.conf",
)
if __name__ == "__main__":
rofi = Rofi(
config_file="~/Projects/Scripts/aniwrapper/themes/aniwrapper-nord2.rasi",
theme_str="configuration {dpi: 144;} window {width: 55%;} listview {columns: 3; lines: 7;}",
)
chosen, _ = rofi.select("Edit config", CONFIGS)
print("Chosen: {}".format(chosen))
print("Config: {}".format(CONFIGS[chosen]))
print(CMD.format(CONFIGS[chosen]))
if chosen != -1:
with Popen(CMD.format(CONFIGS[chosen]), shell=True) as proc:
proc.wait()

View File

@@ -0,0 +1,47 @@
#!/usr/bin/env python3
from pathlib import Path
from subprocess import PIPE, Popen
from sys import exit as sysexit
from rofi import Rofi
CFG_FILE = "~/.config/rofi/aniwrapper-dracula.rasi"
def send_notification(title, message):
Popen(["notify-send", title, message])
if __name__ == "__main__":
cfg = Path(CFG_FILE).expanduser()
if not cfg.exists():
print("Config file not found:", cfg)
sysexit(1)
# make sure rofi cfg file is valid
rofi = Rofi(
config_file="",
theme_str="window { width: 35%; height: 10%; anchor: north; location: north;}",
)
url = rofi.text_entry("Enter YouTube URL:")
# Make sure the URL is valid
if not url.startswith("https://www.youtube.com/watch?v="):
print("Invalid URL")
sysexit(1)
# Send video to metube using ~/.bin/metube
with Popen(
["/home/sudacode/.bin/metube", f"{url}"],
stdout=PIPE,
stderr=PIPE,
) as proc:
res = proc.communicate()
if proc.returncode != 0:
send_notification("Metube Upload Failed", res[1].decode("utf-8"))
print(res[1].decode("utf-8"))
sysexit(1)
print(res[0].decode("utf-8"))
send_notification("Metube Upload Successful", res[0].decode("utf-8"))
sysexit(0)

View File

@@ -0,0 +1,33 @@
#!/usr/bin/env python3
from subprocess import Popen
from sys import exit as sysexit
import pyperclip
from rofi import Rofi
def notify(title, message, icon=None):
"""Use dunstify to send notifications"""
if icon:
Popen(["dunstify", title, message, "-i", icon])
else:
Popen(["dunstify", title, message])
def main():
"""Send video to MPV"""
rofi = Rofi(
lines=1, width="35%", config_file="~/.config//rofi//aniwrapper-dracula.rasi"
)
url = rofi.text_entry("Enter video URL")
with Popen(["/usr/bin/mpv", url]) as proc:
notify("rofi-mpv", "Playing video", "video-x-generic")
proc.wait()
if proc.returncode != 0:
sysexit(1)
sysexit(0)
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,36 @@
#!/usr/bin/env bash
[ $# -gt 0 ] && ROFI_CONFIG="$1" || ROFI_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/rofi/config.rasi"
choice=$(rofi -dmenu -config "$ROFI_CONFIG" -sep '|' -i -l 2 -p "Enter choice:" <<< "1. Pihole Mode|2. Normal Mode|3. Work Mode|4. Quit")
[ ! "$choice" ] && exit 1
selection=$(awk '{print $1}' <<< "$choice")
case "$selection" in
1.)
systemctl --user start end-work-wallpaper.service
systemctl --user start end-work-network.service
;;
2.)
systemctl --user start end-work-wallpaper.service
systemctl --user start start-work-network.service
/home/sudacode/Work/scripts/vpn n
;;
3.)
systemctl --user start start-work-wallpaper.service
systemctl --user start start-work-network.service
/home/sudacode/Work/scripts/vpn c
;;
4.)
exit 0
;;
*)
exit 1
;;
esac
# choice=$(rofi -dmenu -config "$ROFI_CONFIG" -i -l 6 -p "Choose Network" < <(nmcli c | awk '!/^(br|virbr|docker)/' | tail -n +2))
# [ ! "$choice" ] && exit 1
# name=$(awk '{ print $1; }' <<< "$choice")
# if nmcli c show --active | grep -q "$name"; then
# nmcli c down "$name" &> /dev/null &
# else
# nmcli c up "$name" &> /dev/null &
# fi

124
.config/rofi/scripts/rofi-open.py Executable file
View File

@@ -0,0 +1,124 @@
#!/usr/bin/env python3
from subprocess import Popen
from sys import argv
from sys import exit as sysexit
from rofi import Rofi
# BROWSER = "qutebrowser"
# BROWSER = "microsoft-edge-beta"
# BROWSER = "google-chrome-stable"
BROWSER = "firefox"
OPEN_TYPES = ["window", "tab"]
OPTIONS = [
"Anilist - https://anilist.co/home",
"Apprise - http://thebox:8888/",
"Audiobookshelf - https://audiobookshelf.suda.codes",
"Authentik - http://thebox:9000",
"Calendar - https://nextcloud.suda.codes/apps/calendar",
"Capital One - https://myaccounts.capitalone.com/accountSummary",
"Chase Bank - https://secure03ea.chase.com/web/auth/dashboard#/dashboard/overviewAccounts/overview/singleDeposit",
"ChatGPT - https://chat.openai.com/chat",
"CloudBeaver - https://cloudbeaver.suda.codes",
"Cloudflare - https://dash.cloudflare.com/",
"CoinMarketCap - https://coinmarketcap.com/watchlist/",
"Dashy - http://thebox:4000",
"Deemix - http://thebox:3358",
"F1TV - https://f1tv.suda.codes",
"Fidelity - https://login.fidelity.com/ftgw/Fas/Fidelity/RtlCust/Login/Init?AuthRedUrl=https://oltx.fidelity.com/ftgw/fbc/oftop/portfolio#summary",
"Firefly3 - https://firefly.suda.codes",
"Gitea - https://gitea.suda.codes",
"Github - https://github.com",
"Ghostfolio - http://thebox:3334",
"Grafana - http://thebox:3333",
"Grafana (sudacode) - https://grafana.sudacode.com/d/1lcjN0bik3/nginx-logs-and-geo-map?orgId=1&refresh=10s",
"Grafana (suda.codes) - http://thebox:3333/d/1lcjN0bik3/nginx-logs-and-geo-map?orgId=1&refresh=1m",
"Grafana (Loki) - http://thebox:3333/explore?schemaVersion=1&panes=%7B%22rtz%22%3A%7B%22datasource%22%3A%22bdvgbaoxphu68c%22%2C%22queries%22%3A%5B%7B%22refId%22%3A%22A%22%2C%22expr%22%3A%22%22%2C%22queryType%22%3A%22range%22%2C%22datasource%22%3A%7B%22type%22%3A%22loki%22%2C%22uid%22%3A%22bdvgbaoxphu68c%22%7D%7D%5D%2C%22range%22%3A%7B%22from%22%3A%22now-1h%22%2C%22to%22%3A%22now%22%7D%7D%7D&orgId=1",
"Homepage - https://homepage.suda.codes",
"HomeAssistant - http://thebox:8123",
"Icloud - https://www.icloud.com/",
"Interactive Brokers - https://ndcdyn.interactivebrokers.com/sso/Login?RL=1&locale=en_US",
"Jackett - http://thebox:9117",
"Jellyseerr - http://thebox:5055",
"Jellyfin - http://thebox-ts:8096",
"Jellyfin (YouTube) - http://thebox-ts:8097",
"Jellyfin (Vue) - http://thebox-ts:8098",
"Kanboard - https://kanboard.suda.codes",
"Komga - http://thebox:3359",
"Lidarr - http://thebox:3357",
"Linkding - http://thebox:3341",
"Lychee - https://lychee.sudacode.com",
"Medusa - https://medusa.suda.codes",
"Metamask - https://portfolio.metamask.io/",
"MeTube - https://metube.suda.codes",
"Netdata - https://netdata.suda.codes",
"Navidrome - http://thebox:3346",
"Nextcloud - https://nextcloud.suda.codes",
"Nzbhydra - http://thebox:5076",
"OpenBooks - https://openbooks.suda.codes",
"Pihole - http://pi5/admin",
"qBittorrent - https://qbit.suda.codes",
"Paperless - https://paperless.suda.codes",
"Photoprism - http://thebox:2342",
"Portainer - http://thebox:10003",
"Prometheus - https://prometheus.suda.codes",
"Pterodactyl - https://gameserver.suda.codes",
"Radarr - https://radarr.suda.codes",
"Reddit (Anime) - https://www.reddit.com/r/anime/",
"Reddit (Selfhosted) - https://www.reddit.com/r/selfhosted/",
"Robinhood - https://robinhood.com",
"Sabnzbd - https://sabnzbd.suda.codes",
"Sonarr - https://sonarr.suda.codes",
"Sonarr Anime - http://thebox:6969",
"Skinport - https://skinport.com/",
"Steamfolio - https://steamfolio.com/CustomPortfolio",
"Sudacode - https://sudacode.com",
"Tailscale - https://login.tailscale.com/admin/machines",
"Tanoshi - http://thebox:3356",
"Tranga - http://thebox:9555",
"Tdarr - http://thebox:8265/",
"TD Ameritrade - https://invest.ameritrade.com",
"ThinkOrSwim - https://trade.thinkorswim.com",
"Umami - https://umami.sudacode.com",
"Vaultwarden - https://vault.suda.codes",
"Wallabag - https://wallabag.suda.codes",
"Youtube - https://youtube.com",
]
if __name__ == "__main__":
if len(argv) < 2:
print("Usage: rofi-open.py <window_type>")
sysexit(1)
open_type = argv[1].strip().lower()
if open_type not in OPEN_TYPES:
print("Invalid open type: {}".format(open_type))
print("Valid open types: {}".format(", ".join(OPEN_TYPES)))
sysexit(1)
try:
r = Rofi(
config_file="~/.config/rofi/aniwrapper-dracula.rasi",
theme_str="configuration {dpi: 144;} window {width: 75%;} listview {columns: 2; lines: 10;}",
)
except Exception as e:
print(e)
sysexit(1)
index, key = r.select("Select link to open", OPTIONS, rofi_args=["-i"])
if index < 0 or index >= len(OPTIONS):
print("Invalid index:", index)
sysexit(1)
url = OPTIONS[index].split("-")
if isinstance(url, list) and len(url) > 2:
url = "-".join(url[1:]).strip()
else:
url = url[1].strip()
print("Opening:", url)
"""Open a URL in browser: <BROWSER>."""
if open_type == "tab":
with Popen([BROWSER, url]) as proc:
proc.wait()
else:
with Popen([BROWSER, "--new-window", url]) as proc:
proc.wait()
# with Popen([BROWSER, "--target", open_type, url]) as proc:

View File

@@ -0,0 +1,30 @@
#!/usr/bin/env bash
arg="$1"
# if arg is add, add a new password
# if arg is edit, edit an existing password
# if arg is delete, delete an existing password
case "$arg" in
add)
name="$(rofi -dmenu -l 0 -config ~/.config/aniwrapper/themes/aniwrapper-dracula.rasi -theme-str 'window {width: 35%;}' -p 'SAVED NAME:')"
username="$(rofi -dmenu -l 0 -config ~/.config/aniwrapper/themes/aniwrapper-dracula.rasi -theme-str 'window {width: 35%;}' -p 'USERNAME:')"
printf "%s %s\n" "$name" "$username"
if [[ -z "$name" || -z "$username" ]]; then
printf "%s\n" "Name and username cannot be empty"
exit 1
fi
rbw add "$name" "$username"
;;
edit)
exit 1
;;
delete)
exit 1
;;
*)
printf "%s\n" "Not implemented"
exit 1
;;
esac

View File

View File

@@ -0,0 +1,42 @@
#!/usr/bin/env bash
BASE_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/picom"
HIGH_TRANSPARENCY=picom-hightransparency.conf
NO_TRANSPARENCY=picom-notransparency.conf
ARGS=(
"1. High Transparency"
"2. No Transparency"
"3. No Picom"
"4. Quit"
)
CHOICE=$(printf "%s\n" "${ARGS[@]}" | rofi -theme-str 'window {width: 45%;}' -config ~/.config/rofi/aniwrapper-dracula.rasi -dmenu -l 5 -i -p "Picom Options")
SELECTION=$(awk '{print $1}' <<< "$CHOICE")
conf=""
case "$SELECTION" in
1.)
conf="$BASE_DIR/$HIGH_TRANSPARENCY"
;;
2.)
conf="$BASE_DIR/$NO_TRANSPARENCY"
;;
3.)
killall -q picom
exit $?
;;
4.)
exit 0
;;
*)
exit 1
;;
esac
[ -z "$conf" ] && conf="$BASE_DIR/picom.conf"
if pgrep 'picom' > /dev/null; then
killall -q picom && sleep 0.1
fi
picom --config="$conf" > /dev/null 2>&1 &

View File

@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -Eeuo pipefail
# Script to run a bash command from a rofi prompt
THEME_STR="
window {
width: 35%;
height: 10%;
anchor: north;
location: north;
}"
# generates a span mesg for rofi given
# input: message: str
generate_span() {
msg1="$1"
msg2="$2"
span="<span foreground='#ecbe7b' style='normal' size='small'>$msg1</span>"
span2="<span foreground='dodgerblue' style='italic' size='small'>$msg2</span>"
printf "%s: %s\n" "$span" "$span2"
}
# Get the command to run
cmd="$(rofi -dmenu -l 0 -p 'Run:' -theme-str "$THEME_STR")"
# Check if command is sudo
if [[ "$cmd" == "sudo"* ]]; then
# Prompt for confirmation
confirm="$(rofi -dmenu -l 0 -p 'Confirm (Y/N)' \
-theme-str "$THEME_STR" -mesg "$(generate_span "CMD" "$cmd")" || true)"
# If not confirmed, exit
if ! [[ "$confirm" == "Y" || "$confirm" == "y" ]]; then
exit 0
fi
fi
if [[ "$#" -gt 0 ]] && [[ "$1" == "-v" || "$1" == "--verbose" ]]; then
# Send command to dunstify
dunstify "Running command: $cmd"
fi
# Run the command
eval "$cmd"

View File

@@ -0,0 +1,75 @@
#!/usr/bin/env python3
import logging
from pathlib import Path
from subprocess import Popen
from sys import argv
from sys import exit as sysexit
from rofi import Rofi
DEFAULT = Path.home().expanduser() / "Videos" / "sauce"
logger = logging.getLogger("rofi-syncfin")
logger.setLevel(logging.DEBUG)
sh = logging.StreamHandler()
sh.setFormatter(
logging.Formatter("%(asctime)s | %(name)s | %(levelname)s | %(message)s")
)
logger.addHandler(sh)
def notification(title: str, message: str) -> None:
"""Sends a notification."""
Popen(["dunstify", title, message])
def run_syncfin(pth: Path | str) -> None:
"""Runs syncfin in the given path."""
pth = Path(pth)
if not pth.exists() or not pth.is_dir():
notification("Syncfin:", f"Path {pth} does not exist.")
logger.error("Invalid path: %s", pth)
sysexit(1)
with Popen(["/home/sudacode/.bin/syncfin", pth]) as proc:
ret = proc.wait()
if ret != 0:
notification("Syncfin:", f"Syncfin failed with exit code {ret}.")
logger.error("syncfin returned non-zero exit code: %s", ret)
sysexit(1)
def get_dirs(in_pth: Path | str) -> list[Path]:
"""Returns a list of directories in the given path."""
path = Path(in_pth)
return [x for x in path.iterdir() if x.is_dir()]
if __name__ == "__main__":
rofi = Rofi(
rofi_args=[
"-dmenu",
"-i",
"-config",
"/home/sudacode/.config/aniwrapper/themes/aniwrapper-nord2.rasi",
"-dpi",
"144",
],
theme_str="window { width: 85%; } listview { lines: 10; }",
)
logger.debug("Starting rofi-syncfin.py")
logger.debug("HOME: %s", DEFAULT)
dirs = get_dirs(DEFAULT)
dirs = [x.name for x in dirs]
choice, status = rofi.select("Select a directory", dirs)
if status == -1:
notification("rofi-syncfin", "Failed")
sysexit(1)
else:
logger.debug("Selected dir: %s", choice)
logger.info("Running syncfin on %s", dirs[choice])
pth = str(DEFAULT / dirs[choice])
logger.debug("Path: %s", pth)
notification("rofi-syncfin:", f"Syncing {dirs[choice]}")
run_syncfin(pth)
notification("rofi-syncfin", f"Finished syncing {dirs[choice]}")

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env python3
"""Sends the search query to a new tab in the browser"""
from subprocess import Popen
from sys import exit as sysexit
from rofi import Rofi
BROWSER = "google-chrome-stable"
if __name__ == "__main__":
rofi = Rofi(
config_file="~/Projects/Scripts/aniwrapper/themes/aniwrapper-nord2.rasi",
theme_str="configuration {dpi: 144;} window {width: 45%;} listview {columns: 1; lines: 1;}",
)
query = rofi.text_entry("Search Youtube", rofi_args=["-i"])
if query is None or query == "":
sysexit(1)
url = "https://www.youtube.com/results?search_query={}".format(query)
with Popen([BROWSER, url]) as proc:
proc.wait()