From b7c8f7234f29efbe6d86382775c125560660436a Mon Sep 17 00:00:00 2001 From: coast Date: Tue, 22 Jul 2025 11:21:55 +0330 Subject: [PATCH] suicide --- config/nvim-root/init.lua | 168 +++++++++++++++++++++++++ local/bin/brwmenu | 182 +++++++++++++--------------- local/{radio-kill => bin/killradio} | 0 local/brwmenu | 100 --------------- local/radio | 77 ------------ 5 files changed, 254 insertions(+), 273 deletions(-) create mode 100644 config/nvim-root/init.lua rename local/{radio-kill => bin/killradio} (100%) delete mode 100755 local/brwmenu delete mode 100755 local/radio diff --git a/config/nvim-root/init.lua b/config/nvim-root/init.lua new file mode 100644 index 0000000..1d60c81 --- /dev/null +++ b/config/nvim-root/init.lua @@ -0,0 +1,168 @@ +vim.cmd [[ + set nocompatible + filetype plugin indent on + syntax enable + call plug#begin('~/.local/share/nvim/plugged') + Plug 'tpope/vim-sensible' + Plug 'junegunn/fzf.vim' + Plug 'tpope/vim-surround' + Plug 'tpope/vim-commentary' + Plug 'jiangmiao/auto-pairs' + Plug 'tpope/vim-repeat' + Plug 'mattn/emmet-vim' + Plug 'norcalli/nvim-colorizer.lua' + call plug#end() +]] + +vim.opt.clipboard = "unnamedplus" +vim.opt.updatetime = 300 +vim.opt.timeoutlen = 500 +vim.opt.signcolumn = "yes" +vim.opt.completeopt = { "menuone", "noinsert", "noselect" } +vim.opt.encoding = "utf-8" +vim.opt.number = true +vim.opt.relativenumber = true +vim.opt.numberwidth = 4 +vim.opt.tabstop = 4 +vim.opt.shiftwidth = 4 +vim.opt.expandtab = true +vim.opt.smartindent = true +vim.opt.incsearch = true +vim.opt.hlsearch = true +vim.opt.ignorecase = true +vim.opt.smartcase = true +vim.opt.wrap = true +vim.opt.mouse = "a" +vim.opt.scrolloff = 5 +vim.opt.cursorline = true +vim.opt.showmode = false +vim.opt.shortmess:append("I") +vim.opt.autoindent = true +vim.opt.termguicolors = true +vim.opt.list = true +vim.opt.undodir = vim.fn.stdpath("cache") .. "/undo" +vim.opt.undofile = true +vim.opt.wrapscan = true +vim.opt.shortmess:append("c") +vim.opt.autoread = true +vim.opt.cmdheight = 1 +vim.opt.belloff = "all" +vim.opt.laststatus = 2 +vim.opt.scrolljump = 3 +vim.opt.hidden = true +vim.opt.splitbelow = true +vim.opt.splitright = true +vim.opt.backup = false +vim.opt.writebackup = false +vim.opt.lazyredraw = true +vim.opt.smoothscroll = true + +vim.api.nvim_set_hl(0, "Normal", { fg = "#a6536f", bg = "NONE", ctermfg = 132, ctermbg = "NONE" }) +vim.api.nvim_set_hl(0, "NormalNC", { fg = "#bb6c82", bg = "NONE", ctermfg = 168, ctermbg = "NONE" }) +vim.api.nvim_set_hl(0, "LineNr", { fg = "#743c5e", bg = "NONE", ctermfg = 132, ctermbg = "NONE" }) +vim.api.nvim_set_hl(0, "CursorLine", { bg = "#3f1f32", fg = "NONE", blend = 30 }) +vim.api.nvim_set_hl(0, "VertSplit", { fg = "#3f1f32", bg = "NONE", ctermfg = 237, ctermbg = "NONE" }) + +vim.api.nvim_set_hl(0, "StatusLine", { + fg = "#a6536f", + bg = "#2a1c2e", + ctermfg = 132, + ctermbg = 235, +}) + +vim.api.nvim_set_hl(0, "StatusLineMode", { + fg = "#f7d8e5", + bg = "#5e2f4c", + bold = true, + ctermfg = 224, + ctermbg = 131, +}) + +vim.api.nvim_set_hl(0, "Visual", { bg = "#5a2c3a", fg = "NONE", ctermbg = 52, ctermfg = "NONE" }) +vim.api.nvim_set_hl(0, "VisualNOS", { bg = "#5a2c3a", fg = "NONE", ctermbg = 52, ctermfg = "NONE" }) +vim.api.nvim_set_hl(0, "VisualSB", { bg = "#5a2c3a", fg = "NONE", ctermbg = 52, ctermfg = "NONE" }) +vim.api.nvim_set_hl(0, "Search", { fg = "#b0576f", bg = "#1c1533", ctermfg = 131, ctermbg = 234 }) +vim.api.nvim_set_hl(0, "IncSearch", { fg = "#f5a3ba", bg = "#1c1533", ctermfg = 218, ctermbg = 234 }) +vim.api.nvim_set_hl(0, "Pmenu", { fg = "#b0576f", bg = "NONE", ctermfg = 131, ctermbg = "NONE" }) +vim.api.nvim_set_hl(0, "PmenuSel", { fg = "#000000", bg = "#b0576f", ctermfg = 0, ctermbg = 131 }) +vim.api.nvim_set_hl(0, "WildMenu", { fg = "#b0576f", bg = "NONE", ctermfg = 131, ctermbg = "NONE" }) +vim.api.nvim_set_hl(0, "Folded", { fg = "#c18299", bg = "NONE", ctermfg = 174, ctermbg = "NONE" }) +vim.api.nvim_set_hl(0, "SignColumn", { fg = "#f0b6c8", bg = "NONE", ctermfg = 224, ctermbg = "NONE" }) + +local mode_names = { + n = "ROOT NRM", + i = "ROOT INS", + v = "ROOT VSL", + V = "ROOT VLI", + [""] = "ROOT VBL", + R = "ROOT RPL", + c = "ROOT CMD", +} + +function _G.ModeName() + return mode_names[vim.fn.mode()] or "UNK" +end + +vim.opt.statusline = table.concat { + "%#StatusLineMode# ", + "%{v:lua.ModeName()} ", + "%#StatusLine# ", + "%f %m %r ", + "%=", + "Ln:%l/%L ", + "Col:%c ", + "[%p%%]", +} + +vim.g.mapleader = " " +local map = vim.keymap.set +map("n", "w", ":w") +map("n", "q", ":q") +map("n", "h", ":nohlsearch", { silent = true }) +map("n", "n", ":set relativenumber!") +map("n", "", "h") +map("n", "", "j") +map("n", "", "k") +map("n", "", "l") +map("n", "v", ":Ex") +map("", "j", "gj") +map("", "k", "gk") + +vim.keymap.set({ "n", "v" }, "cd", vim.cmd.Ex) + +vim.keymap.set({ "n", "v" }, "d", '"_d', { desc = "Delete without yanking" }) +vim.keymap.set("n", "bn", ":bnext", { desc = "Next buffer" }) +vim.keymap.set("n", "bp", ":bprevious", { desc = "Previous buffer" }) + +vim.keymap.set("n", "", "h", { desc = "Move to left window" }) +vim.keymap.set("n", "", "j", { desc = "Move to bottom window" }) +vim.keymap.set("n", "", "k", { desc = "Move to top window" }) +vim.keymap.set("n", "", "l", { desc = "Move to right window" }) + +local modes_to_disable = { "n", "v", "x", "s", "c" } +local arrows = { "", "", "", "" } + +for _, mode in ipairs(modes_to_disable) do + for _, key in ipairs(arrows) do + vim.keymap.set(mode, key, "", { silent = true }) + end +end + +vim.keymap.set("n", "sv", ":vsplit", { desc = "Split window vertically" }) +vim.keymap.set("n", "sh", ":split", { desc = "Split window horizontally" }) +vim.keymap.set("n", "", ":resize +2", { desc = "Increase window height" }) +vim.keymap.set("n", "", ":resize -2", { desc = "Decrease window height" }) +vim.keymap.set("n", "", ":vertical resize -2", { desc = "Decrease window width" }) +vim.keymap.set("n", "", ":vertical resize +2", { desc = "Increase window width" }) + +vim.keymap.set("n", "", ":m .+1==", { desc = "Move line down" }) +vim.keymap.set("n", "", ":m .-2==", { desc = "Move line up" }) +vim.keymap.set("v", "", ":m '>+1gv=gv", { desc = "Move selection down" }) +vim.keymap.set("v", "", ":m '<-2gv=gv", { desc = "Move selection up" }) + +require('colorizer').setup { + '*', + css = { names = true }, + html = { names = true }, +} + diff --git a/local/bin/brwmenu b/local/bin/brwmenu index 895b113..3c11864 100755 --- a/local/bin/brwmenu +++ b/local/bin/brwmenu @@ -1,99 +1,89 @@ -#!/bin/sh -#inspired by 'firemenu' by on github -# BRWMENU: -set -e -DMENU_OPTS="-i -fn DepartureMono:size=10 -nb #151515 -nf #bbbbbb -sb #884757 -sf #eeeeee" -BROWSER="mullvad-browser-bin" -SWALLOW="" -NOTIFIER="notify-send" -for cmd in dmenu "$BROWSER"; do - if ! command -v "$cmd" >/dev/null 2>&1; then - echo "Error: Required command '$cmd' not found" >&2 - exit 1 - fi -done -CHOICES="Startpage\nURL\nIncognito URL\nYouTube\nGithub\nCodeberg\ncoasteen.github.io\nIPLeak\nSafebooru\nWikipedia" -PROMPT="Where to?" -open_url() { - if [ -z "$1" ]; then - $NOTIFIER "Error" "No URL specified" 2>/dev/null || echo "Error: No URL specified" >&2 - exit 1 - fi +#!/usr/bin/env python3 +import subprocess +import sys +import shutil +import urllib.parse - if ! $SWALLOW $BROWSER "$1" >/dev/null 2>&1; then - $NOTIFIER "Error" "Failed to open browser with URL: $1" 2>/dev/null || \ - echo "Error: Failed to open browser with URL: $1" >&2 - exit 1 - fi -} -get_input() { - prompt="$1" - prefix="$2" - input=$(printf '' | dmenu $DMENU_OPTS -p "$prompt" 2>/dev/null) +DMENU_OPTS = ["-i", "-fn", "DepartureMono:size=10", "-nb", "#151515", "-nf", "#bbbbbb", "-sb", "#2a1f4d", "-sf", "#eeeeee"] +BROWSER = "mullvad-browser-bin" +NOTIFIER = "notify-send" - if [ -z "$input" ]; then - $NOTIFIER "Error" "No input provided" 2>/dev/null || echo "Error: No input provided" >&2 - exit 1 - fi +CHOICES = [ + "Startpage", "URL", "Incognito URL", "YouTube", "Github", "Codeberg", + "coasteen.github.io", "IPLeak", "Safebooru", "Wikipedia" +] - input=$(printf "%s" "$input" | sed 's/ /%20/g') - echo "${prefix}${input}" -} -CHOICE=$(printf "$CHOICES" | dmenu $DMENU_OPTS -p "$PROMPT" 2>/dev/null) -case "$CHOICE" in - Github) - url=$(get_input "Username & repo:" "https://github.com/") - open_url "$url" - ;; - Codeberg) - url=$(get_input "Username & repo:" "https://codeberg.org/") - open_url "$url" - ;; - IPLeak) - open_url "https://ipleak.net" - ;; - Startpage) - query=$(get_input "Search Startpage:" "") - open_url "https://www.startpage.com/do/search?q=" - ;; - Wikipedia) - query=$(get_input "Search Wikipedia:" "") - open_url "https://en.wikipedia.org/wiki/Special:Search?search=$query" - ;; - URL) - url=$(get_input "Enter URL:" "") - case "$url" in - http://*|https://*) ;; - *) url="https://$url" ;; - esac - open_url "$url" - ;; - Incognito\ URL) - url=$(get_input "Enter incognito URL:" "") - case "$url" in - http://*|https://*) ;; - *) url="https://$url" ;; - esac - if ! $SWALLOW brave-bin --incognito "$url" >/dev/null 2>&1; then - $NOTIFIER "Error" "Failed to open incognito window" 2>/dev/null || \ - echo "Error: Failed to open incognito window" >&2 - exit 1 - fi - ;; - YouTube) - query=$(get_input "Search YouTube:" "") - open_url "https://youtube.com/results?search_query=$query" - ;; - Safebooru) - query=$(get_input "Search Safebooru:" "") - open_url "https://safebooru.org/index.php?page=post&s=list&tags=$query" - ;; - coasteen.github.io) - open_url "https://coasteen.github.io/www/" - ;; - *) - $NOTIFIER "Error" "Invalid selection: $CHOICE" 2>/dev/null || \ - echo "Error: Invalid selection: $CHOICE" >&2 - exit 1 - ;; -esac +def notify(title, message): + subprocess.run([NOTIFIER, title, message], stderr=subprocess.DEVNULL) + +def run_dmenu(prompt, options=None): + cmd = ["dmenu", *DMENU_OPTS, "-p", prompt] + stdin = None + if options: + stdin = "\n".join(options) + proc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, text=True) + out, _ = proc.communicate(stdin) + return out.strip() + +def get_input(prompt, prefix=""): + text = run_dmenu(prompt) + if not text: + notify("Error", "No input provided") + sys.exit(1) + return prefix + urllib.parse.quote_plus(text) + +def open_url(url): + try: + subprocess.Popen([BROWSER, url]) + except: + notify("Error", f"Failed to open browser: {url}") + sys.exit(1) + +def main(): + choice = run_dmenu("Where to?", CHOICES) + if not choice: + notify("Error", "No selection made") + sys.exit(1) + + if choice == "Github": + open_url(get_input("Username & repo:", "https://github.com/")) + elif choice == "Codeberg": + open_url(get_input("Username & repo:", "https://codeberg.org/")) + elif choice == "IPLeak": + open_url("https://ipleak.net") + elif choice == "Startpage": + open_url("https://www.startpage.com/do/search?q=" + get_input("Search Startpage:")) + elif choice == "Wikipedia": + open_url("https://en.wikipedia.org/wiki/Special:Search?search=" + get_input("Search Wikipedia:")) + elif choice == "URL": + url = run_dmenu("Enter URL:") + if not url: + notify("Error", "No URL entered") + sys.exit(1) + if not url.startswith("http"): + url = "https://" + url + open_url(url) + elif choice == "Incognito URL": + url = run_dmenu("Enter incognito URL:") + if not url: + notify("Error", "No URL entered") + sys.exit(1) + if not url.startswith("http"): + url = "https://" + url + subprocess.Popen(["brave-bin", "--incognito", url]) + elif choice == "YouTube": + open_url("https://youtube.com/results?search_query=" + get_input("Search YouTube:")) + elif choice == "Safebooru": + open_url("https://safebooru.org/index.php?page=post&s=list&tags=" + get_input("Search Safebooru:")) + elif choice == "coasteen.github.io": + open_url("https://coasteen.github.io/www/") + else: + notify("Error", f"Invalid selection: {choice}") + sys.exit(1) + +if __name__ == "__main__": + for cmd in ["dmenu", BROWSER]: + if shutil.which(cmd) is None: + print(f"Error: Required command '{cmd}' not found", file=sys.stderr) + sys.exit(1) + main() diff --git a/local/radio-kill b/local/bin/killradio similarity index 100% rename from local/radio-kill rename to local/bin/killradio diff --git a/local/brwmenu b/local/brwmenu deleted file mode 100755 index 3020a1a..0000000 --- a/local/brwmenu +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/sh -#inspired by 'firemenu' by on github -# BRWMENU: -set -e -DMENU_OPTS="-i -fn monospace:size=12 -nb #151515 -nf #bbbbbb -sb #663300 -sf #eeeeee" -BROWSER="brave-bin" -SWALLOW="" -NOTIFIER="notify-send" -for cmd in dmenu "$BROWSER"; do - if ! command -v "$cmd" >/dev/null 2>&1; then - echo "Error: Required command '$cmd' not found" >&2 - exit 1 - fi -done -CHOICES="YouTube\nSafebooru\nWikipedia\nGithub\nCodeberg\nIPLeak\nQwant\nDuckDuckGo\nURL\nIncognito URL" -PROMPT="Where to?" -open_url() { - if [ -z "$1" ]; then - $NOTIFIER "Error" "No URL specified" 2>/dev/null || echo "Error: No URL specified" >&2 - exit 1 - fi - - if ! $SWALLOW $BROWSER "$1" >/dev/null 2>&1; then - $NOTIFIER "Error" "Failed to open browser with URL: $1" 2>/dev/null || \ - echo "Error: Failed to open browser with URL: $1" >&2 - exit 1 - fi -} -get_input() { - prompt="$1" - prefix="$2" - input=$(printf '' | dmenu $DMENU_OPTS -p "$prompt" 2>/dev/null) - - if [ -z "$input" ]; then - $NOTIFIER "Error" "No input provided" 2>/dev/null || echo "Error: No input provided" >&2 - exit 1 - fi - - input=$(printf "%s" "$input" | sed 's/ /%20/g') - echo "${prefix}${input}" -} -CHOICE=$(printf "$CHOICES" | dmenu $DMENU_OPTS -p "$PROMPT" 2>/dev/null) -case "$CHOICE" in - Github) - url=$(get_input "Username & repo:" "https://github.com/") - open_url "$url" - ;; - Codeberg) - url=$(get_input "Username & repo:" "https://codeberg.org/") - open_url "$url" - ;; - IPLeak) - open_url "https://ipleak.net" - ;; - Qwant) - query=$(get_input "Search Qwant:" "") - open_url "https://qwant.com/search?q=$query" - ;; - DuckDuckGo) - query=$(get_input "Search DuckDuckGo:" "") - open_url "https://duckduckgo.com/?q=$query" - ;; - Wikipedia) - query=$(get_input "Search Wikipedia:" "") - open_url "https://en.wikipedia.org/wiki/Special:Search?search=$query" - ;; - URL) - url=$(get_input "Enter URL:" "") - case "$url" in - http://*|https://*) ;; - *) url="https://$url" ;; - esac - open_url "$url" - ;; - Incognito\ URL) - url=$(get_input "Enter incognito URL:" "") - case "$url" in - http://*|https://*) ;; - *) url="https://$url" ;; - esac - if ! $SWALLOW brave-bin --incognito "$url" >/dev/null 2>&1; then - $NOTIFIER "Error" "Failed to open incognito window" 2>/dev/null || \ - echo "Error: Failed to open incognito window" >&2 - exit 1 - fi - ;; - YouTube) - query=$(get_input "Search YouTube:" "") - open_url "https://youtube.com/results?search_query=$query" - ;; - Safebooru) - query=$(get_input "Search Safebooru:" "") - open_url "https://safebooru.org/index.php?page=post&s=list&tags=$query" - ;; - *) - $NOTIFIER "Error" "Invalid selection: $CHOICE" 2>/dev/null || \ - echo "Error: Invalid selection: $CHOICE" >&2 - exit 1 - ;; -esac diff --git a/local/radio b/local/radio deleted file mode 100755 index a697329..0000000 --- a/local/radio +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python3 -import os -import subprocess -import time -from pathlib import Path -import threading -import json -import tempfile -import urllib.request -import websocket -import signal - -URL = "https://radio.animebits.moe/stream/stream128.ogg" -CONF = Path.home() / ".config" / "radiorc" -PID = Path.home() / ".config" / "radio-pid" - -with open(CONF) as f: - VOL = f.read().strip() - -def notify(title, image_url=None): - icon_path = None - if image_url: - try: - tmp = tempfile.NamedTemporaryFile(delete=False, suffix=".png") - urllib.request.urlretrieve(image_url, tmp.name) - icon_path = tmp.name - except: - icon_path = None - args = ["notify-send", title] - if icon_path: - args += ["-i", icon_path] - subprocess.run(args) - -def ws_listener(): - def on_message(ws, message): - data = json.loads(message) - if "data" in data and "title" in data["data"]: - title = data["data"]["title"] - image = data["data"].get("album_cover") - notify(title, image) - - def on_error(ws, error): pass - def on_close(ws, close_status_code, close_msg): - time.sleep(1) - run_ws() - def on_open(ws): pass - - def run_ws(): - ws = websocket.WebSocketApp( - "wss://radio.animebits.moe/api/events/basic", - on_message=on_message, - on_error=on_error, - on_close=on_close, - on_open=on_open, - ) - ws.run_forever() - - run_ws() - -threading.Thread(target=ws_listener, daemon=True).start() - -while True: - try: - print("Playing now...") - subprocess.run(["notify-send", "Playing now..."]) - proc = subprocess.Popen(["mpv", "--no-video", f"--volume={VOL}", URL], preexec_fn=os.setsid) - with open(PID, "w") as f: - f.write(str(os.getpgid(proc.pid))) - proc.wait() - except KeyboardInterrupt: - subprocess.run(["notify-send", "Stopping now..."]) - print("\nStopping now...") - break - except Exception as e: - print(f"Something broke... trying again... Error: {e}") - time.sleep(2) -