From 7d08cb7344066c5274e1c39b456a55314d3c7aa0 Mon Sep 17 00:00:00 2001 From: arindy Date: Sun, 17 May 2026 12:59:45 +0200 Subject: [PATCH] adds keybind help and fixes scripts --- .config/MangoHud/MangoHud.conf | 2 +- .config/hypr/conf/keybinds.lua | 129 +++++++++++++++++---------------- .config/hypr/conf/windows.lua | 8 ++ .config/hypr/shared.lua | 11 +-- .local/bin/anime | 113 +++++++++++++++++++++++++---- .local/bin/keybinds | 115 +++++++++++++++++++++++++++++ .local/bin/start_vivaldi | 2 +- 7 files changed, 297 insertions(+), 83 deletions(-) create mode 100755 .local/bin/keybinds diff --git a/.config/MangoHud/MangoHud.conf b/.config/MangoHud/MangoHud.conf index 8660d7c..85d0ad5 100644 --- a/.config/MangoHud/MangoHud.conf +++ b/.config/MangoHud/MangoHud.conf @@ -47,4 +47,4 @@ output_folder=/home/arindy/.local/share/goverlay log_duration=30 log_interval=100 toggle_logging=Shift_L+F2 -blacklist=zenity,protonplus,lsfg-vk-ui,bazzar,gnome-calculator,pamac-manager,lact,ghb,bitwig-studio,ptyxis,yumex +blacklist=zenity,protonplus,lsfg-vk-ui,bazzar,gnome-calculator,pamac-manager,lact,ghb,bitwig-studio,ptyxis,yumex,mpv diff --git a/.config/hypr/conf/keybinds.lua b/.config/hypr/conf/keybinds.lua index e73cec8..276bca8 100644 --- a/.config/hypr/conf/keybinds.lua +++ b/.config/hypr/conf/keybinds.lua @@ -8,75 +8,78 @@ local mainMod = "SUPER" -- Example binds, see https://wiki.hypr.land/Configuring/Binds/ for more -hl.bind(mainMod .. " + T", hl.dsp.exec_cmd(TERMINAL, {float = true, size = {1920, 1080}})) -hl.bind(mainMod .. " + C", hl.dsp.window.close()) -hl.bind(mainMod .. " + E", hl.dsp.exec_cmd(FILEMANAGER)) -hl.bind(mainMod .. " + Q", hl.dsp.exec_cmd(BROWSER)) -hl.bind(mainMod .. " + V", hl.dsp.window.float({ action = "toggle" })) -hl.bind(mainMod .. " + space", hl.dsp.exec_cmd(MENU)) -hl.bind(mainMod .. " + P", hl.dsp.window.pseudo()) -hl.bind(mainMod .. " + F11", hl.dsp.window.fullscreen("")) -hl.bind(mainMod .. " + J", hl.dsp.layout("togglesplit")) -hl.bind(mainMod .. " + L", hl.dsp.exec_cmd("hyprlock")) --- Move focus with mainMod + arrow keys -hl.bind(mainMod .. " + left", hl.dsp.focus({ direction = "left" })) -hl.bind(mainMod .. " + right", hl.dsp.focus({ direction = "right" })) -hl.bind(mainMod .. " + up", hl.dsp.focus({ direction = "up" })) -hl.bind(mainMod .. " + down", hl.dsp.focus({ direction = "down" })) +-- KeyBinds +-- Open +hl.bind(mainMod .. " + T", hl.dsp.exec_cmd(TERMINAL, {float = true, size = {1920, 1080}})) -- Open Terminal +hl.bind(mainMod .. " + E", hl.dsp.exec_cmd(FILEMANAGER)) -- Open File Manager +hl.bind(mainMod .. " + Q", hl.dsp.exec_cmd(BROWSER)) -- Open Browser +hl.bind(mainMod .. " + space", hl.dsp.exec_cmd(MENU)) -- Open Menu -hl.bind(mainMod .. " + SHIFT + left", hl.dsp.window.move({ workspace = "e+1" })) -hl.bind(mainMod .. " + SHIFT + right", hl.dsp.window.move({ workspace = "e-1" })) -hl.bind(mainMod .. " + SHIFT + up", hl.dsp.window.move({ workspace = 2 })) -hl.bind(mainMod .. " + SHIFT + down", hl.dsp.window.move({ workspace = 4 })) +-- Windows +hl.bind(mainMod .. " + C", hl.dsp.window.close()) -- Close Window +hl.bind(mainMod .. " + V", hl.dsp.window.float({ action = "toggle" })) -- Toggle Float +hl.bind(mainMod .. " + P", hl.dsp.window.pseudo()) -- Toggle Pseudo +hl.bind(mainMod .. " + F11", hl.dsp.window.fullscreen("")) -- Toggle Fullscreen +hl.bind(mainMod .. " + J", hl.dsp.layout("togglesplit")) -- Toggle Split -hl.bind(mainMod .. " + CTRL + left", hl.dsp.window.resize({x = -100, y = 0, relative = true})) -hl.bind(mainMod .. " + CTRL + right", hl.dsp.window.resize({x = 100, y = 0, relative = true})) -hl.bind(mainMod .. " + CTRL + up", hl.dsp.window.resize({x = 0, y = 100, relative = true})) -hl.bind(mainMod .. " + CTRL + down", hl.dsp.window.resize({x = 0, y = -100, relative = true})) +hl.bind(mainMod .. " + left", hl.dsp.focus({ direction = "left" })) -- Focus Left +hl.bind(mainMod .. " + right", hl.dsp.focus({ direction = "right" })) -- Focus Right +hl.bind(mainMod .. " + up", hl.dsp.focus({ direction = "up" })) -- Focus Up +hl.bind(mainMod .. " + down", hl.dsp.focus({ direction = "down" })) -- Focus Down --- Switch workspaces with mainMod + [0-9] -hl.bind(mainMod .. " + 1", hl.dsp.focus({ workspace = 1 })) -hl.bind(mainMod .. " + 2", hl.dsp.focus({ workspace = 2 })) -hl.bind(mainMod .. " + 3", hl.dsp.focus({ workspace = 3 })) -hl.bind(mainMod .. " + 4", hl.dsp.focus({ workspace = 4 })) -hl.bind(mainMod .. " + 5", hl.dsp.focus({ workspace = 5 })) -hl.bind(mainMod .. " + 6", hl.dsp.focus({ workspace = 6 })) -hl.bind(mainMod .. " + 7", hl.dsp.focus({ workspace = 7 })) -hl.bind(mainMod .. " + 8", hl.dsp.focus({ workspace = 8 })) -hl.bind(mainMod .. " + 9", hl.dsp.focus({ workspace = 9 })) -hl.bind(mainMod .. " + 0", hl.dsp.focus({ workspace = 10 })) +hl.bind(mainMod .. " + SHIFT + left", hl.dsp.window.move({ workspace = "e+1" })) -- Move Left +hl.bind(mainMod .. " + SHIFT + right", hl.dsp.window.move({ workspace = "e-1" })) -- Move Right +hl.bind(mainMod .. " + SHIFT + up", hl.dsp.window.move({ workspace = 2 })) -- Move Up +hl.bind(mainMod .. " + SHIFT + down", hl.dsp.window.move({ workspace = 4 })) -- Move Down --- Move active window to a workspace with mainMod + SHIFT + [0-9] -hl.bind(mainMod .. " + SHIFT + 1", hl.dsp.window.move({ workspace = 1 })) -hl.bind(mainMod .. " + SHIFT + 2", hl.dsp.window.move({ workspace = 2 })) -hl.bind(mainMod .. " + SHIFT + 3", hl.dsp.window.move({ workspace = 3 })) -hl.bind(mainMod .. " + SHIFT + 4", hl.dsp.window.move({ workspace = 4 })) -hl.bind(mainMod .. " + SHIFT + 5", hl.dsp.window.move({ workspace = 5 })) -hl.bind(mainMod .. " + SHIFT + 6", hl.dsp.window.move({ workspace = 6 })) -hl.bind(mainMod .. " + SHIFT + 7", hl.dsp.window.move({ workspace = 7 })) -hl.bind(mainMod .. " + SHIFT + 8", hl.dsp.window.move({ workspace = 8 })) -hl.bind(mainMod .. " + SHIFT + 9", hl.dsp.window.move({ workspace = 9 })) -hl.bind(mainMod .. " + SHIFT + 0", hl.dsp.window.move({ workspace = 10 })) +hl.bind(mainMod .. " + CTRL + left", hl.dsp.window.resize({x = -100, y = 0, relative = true})) -- Resize + horizontal +hl.bind(mainMod .. " + CTRL + right", hl.dsp.window.resize({x = 100, y = 0, relative = true})) -- Resize - horizontal +hl.bind(mainMod .. " + CTRL + up", hl.dsp.window.resize({x = 0, y = 100, relative = true})) -- Resize + vertical +hl.bind(mainMod .. " + CTRL + down", hl.dsp.window.resize({x = 0, y = -100, relative = true})) -- Resize - vertical --- Example special workspace (scratchpad) -hl.bind(mainMod .. " + S", hl.dsp.workspace.toggle_special("magic")) -hl.bind(mainMod .. " + SHIFT + S", hl.dsp.window.move({ workspace = "special:magic" })) +hl.bind("ALT + mouse:272", hl.dsp.window.drag()) -- Move with Mouse +hl.bind("ALT + mouse:273", hl.dsp.window.resize()) -- Resize with Mouse --- Move/resize windows with mainMod + LMB/RMB and dragging -hl.bind("ALT + mouse:272", hl.dsp.window.drag()) -hl.bind("ALT + mouse:273", hl.dsp.window.resize()) +-- Workspaces +hl.bind(mainMod .. " + 1", hl.dsp.focus({ workspace = 1 })) -- Focus Workspace 1 +hl.bind(mainMod .. " + 2", hl.dsp.focus({ workspace = 2 })) -- Focus Workspace 2 +hl.bind(mainMod .. " + 3", hl.dsp.focus({ workspace = 3 })) -- Focus Workspace 3 +hl.bind(mainMod .. " + 4", hl.dsp.focus({ workspace = 4 })) -- Focus Workspace 4 +hl.bind(mainMod .. " + 5", hl.dsp.focus({ workspace = 5 })) -- Focus Workspace 5 +hl.bind(mainMod .. " + 6", hl.dsp.focus({ workspace = 6 })) -- Focus Workspace 6 +hl.bind(mainMod .. " + 7", hl.dsp.focus({ workspace = 7 })) -- Focus Workspace 7 +hl.bind(mainMod .. " + 8", hl.dsp.focus({ workspace = 8 })) -- Focus Workspace 8 +hl.bind(mainMod .. " + 9", hl.dsp.focus({ workspace = 9 })) -- Focus Workspace 9 +hl.bind(mainMod .. " + 0", hl.dsp.focus({ workspace = 10 })) -- Focus Workspace 10 --- Laptop multimedia keys for volume and LCD brightness -hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd(SCRIPT_DIR .. "/volume up"), { locked = true, repeating = true }) -hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd(SCRIPT_DIR .. "/volume down"), { locked = true, repeating = true }) -hl.bind("XF86AudioMute", hl.dsp.exec_cmd(SCRIPT_DIR .. "/volume mute"), { locked = true, repeating = true }) -hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"), { locked = true, repeating = true }) -hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%+"), { locked = true, repeating = true }) -hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%-"), { locked = true, repeating = true }) +hl.bind(mainMod .. " + SHIFT + 1", hl.dsp.window.move({ workspace = 1 })) -- Move to Workspace 1 +hl.bind(mainMod .. " + SHIFT + 2", hl.dsp.window.move({ workspace = 2 })) -- Move to Workspace 2 +hl.bind(mainMod .. " + SHIFT + 3", hl.dsp.window.move({ workspace = 3 })) -- Move to Workspace 3 +hl.bind(mainMod .. " + SHIFT + 4", hl.dsp.window.move({ workspace = 4 })) -- Move to Workspace 4 +hl.bind(mainMod .. " + SHIFT + 5", hl.dsp.window.move({ workspace = 5 })) -- Move to Workspace 5 +hl.bind(mainMod .. " + SHIFT + 6", hl.dsp.window.move({ workspace = 6 })) -- Move to Workspace 6 +hl.bind(mainMod .. " + SHIFT + 7", hl.dsp.window.move({ workspace = 7 })) -- Move to Workspace 7 +hl.bind(mainMod .. " + SHIFT + 8", hl.dsp.window.move({ workspace = 8 })) -- Move to Workspace 8 +hl.bind(mainMod .. " + SHIFT + 9", hl.dsp.window.move({ workspace = 9 })) -- Move to Workspace 9 +hl.bind(mainMod .. " + SHIFT + 0", hl.dsp.window.move({ workspace = 10 })) -- Move to Workspace 10 --- Requires playerctl -hl.bind("XF86AudioNext", hl.dsp.exec_cmd("playerctl next"), { locked = true }) -hl.bind("XF86AudioPause", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) -hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) -hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true }) +hl.bind(mainMod .. " + S", hl.dsp.workspace.toggle_special("magic")) -- Focus Magic Workspace +hl.bind(mainMod .. " + SHIFT + S", hl.dsp.window.move({ workspace = "special:magic" })) -- Move to Magic Workspace + +-- Media Keys +hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd(SCRIPT_DIR .. "/volume up"), { locked = true, repeating = true }) -- Volume Up +hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd(SCRIPT_DIR .. "/volume down"), { locked = true, repeating = true }) -- Volume Down +hl.bind("XF86AudioMute", hl.dsp.exec_cmd(SCRIPT_DIR .. "/volume mute"), { locked = true, repeating = true }) -- Volume Mute +hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"), { locked = true, repeating = true }) -- Mic Mute +hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%+"), { locked = true, repeating = true }) -- Increase Brightness +hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%-"), { locked = true, repeating = true }) -- Decrease Brightness + +hl.bind("XF86AudioNext", hl.dsp.exec_cmd("playerctl next"), { locked = true }) -- Next Song +hl.bind("XF86AudioPause", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) -- Play/Pause +hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true }) -- Play/Pause +hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true }) -- Previous Song + +-- System +hl.bind(mainMod .. " + F1", hl.dsp.exec_cmd("keybinds")) -- Show Keybinds +hl.bind(mainMod .. " + L", hl.dsp.exec_cmd("hyprlock")) -- Lock the System diff --git a/.config/hypr/conf/windows.lua b/.config/hypr/conf/windows.lua index a8e2f16..0faf471 100644 --- a/.config/hypr/conf/windows.lua +++ b/.config/hypr/conf/windows.lua @@ -42,6 +42,14 @@ hl.window_rule({ monitor = RIGHT_MONITOR, }) +hl.window_rule({ + name = "mpv", + match = { + class = "mpv", + }, + fullscreen = true +}) + hl.window_rule({ name = "suppress-maximize-events", match = { diff --git a/.config/hypr/shared.lua b/.config/hypr/shared.lua index 42c2592..bdfb1b7 100644 --- a/.config/hypr/shared.lua +++ b/.config/hypr/shared.lua @@ -3,10 +3,11 @@ BOTTOM_MONITOR="DP-3" RIGHT_MONITOR="DP-2" TOP_MONITOR="DP-1" -TERMINAL = "kitty" -FILEMANAGER = "thunar" -BROWSER = "vivaldi" -MENU = "rofi -show" - SCRIPT_DIR = "~/.local/bin" +TERMINAL = "kitty" +FILEMANAGER = "thunar" +BROWSER = SCRIPT_DIR .. "/start_vivaldi" +MENU = "rofi -show" + + diff --git a/.local/bin/anime b/.local/bin/anime index 212b969..1ef06a7 100755 --- a/.local/bin/anime +++ b/.local/bin/anime @@ -1,17 +1,19 @@ #!/bin/sh -version_number="4.10.4" +version_number="4.14.0" # UI external_menu() { - rofi "$1" -sort -dmenu -i -width 1500 -p "$2" "$3" + [ "$use_external_menu" = "1" ] && rofi "$1" -sort -dmenu -i -width 1500 -p "$2" "$3" + [ "$use_external_menu" = "2" ] && dmenu -l 20 -p "$2" } launcher() { [ "$use_external_menu" = "0" ] && [ -z "$1" ] && set -- "+m" "$2" [ "$use_external_menu" = "0" ] && fzf "$1" --reverse --cycle --prompt "$2" [ "$use_external_menu" = "1" ] && external_menu "$1" "$2" "$external_menu_args" + [ "$use_external_menu" = "2" ] && external_menu "$1" "$2" } nth() { @@ -72,6 +74,8 @@ help_info() { Play dubbed version --rofi Use rofi instead of fzf for the interactive menu + --dmenu + Use dmenu instead of fzf for the interactive menu --skip Use ani-skip to skip the intro of the episode (mpv only) --no-detach @@ -177,9 +181,14 @@ generate_link() { 1) provider_init "wixmp" "/Default :/p" ;; # wixmp(default)(m3u8)(multi) -> (mp4)(multi) 2) provider_init "youtube" "/Yt-mp4 :/p" ;; # youtube(mp4)(single) 3) provider_init "sharepoint" "/S-mp4 :/p" ;; # sharepoint(mp4)(single) + 5) provider_init "filemoon" "/Fm-mp4 :/p" ;; # filemoon(m3u8)(single) *) provider_init "hianime" "/Luf-Mp4 :/p" ;; # hianime(m3u8)(multi) esac - [ -n "$provider_id" ] && get_links "$provider_id" + if [ "$1" = "5" ] && [ -n "$provider_id" ]; then + get_filemoon_links "$provider_id" + else + [ -n "$provider_id" ] && get_links "$provider_id" + fi } select_quality() { @@ -204,16 +213,87 @@ select_quality() { episode=$(printf "%s" "$result" | cut -d'>' -f2) } +decode_tobeparsed() { + tmp="$(mktemp)" + printf '%s' "$1" | base64 -d >"$tmp" + file_size="$(wc -c <"$tmp")" + iv="$(dd if="$tmp" bs=1 skip=1 count=12 2>/dev/null | od -A n -t x1 | tr -d ' \n')" + ctr="${iv}00000002" + ct_len=$((file_size - 13 - 16)) + plain="$(dd if="$tmp" bs=1 skip=13 count="$ct_len" 2>/dev/null | openssl enc -d -aes-256-ctr -K "$allanime_key" -iv "$ctr" -nosalt -nopad 2>/dev/null)" + rm -f "$tmp" + printf '%s' "$plain" | tr '{}' '\n' | sed -nE 's|.*"sourceUrl":"--([^"]*)".*"sourceName":"([^"]*)".*|\2 :\1|p' +} + +b64url_to_hex() { + _len=$(printf '%s' "$1" | wc -c | tr -d ' ') + _mod=$((_len % 4)) + case $_mod in + 2) _pad="==" ;; + 3) _pad="=" ;; + *) _pad="" ;; + esac + printf '%s%s' "$1" "$_pad" | tr -- '-_' '+/' | base64 -d | od -A n -t x1 | tr -d ' \n' +} + +get_filemoon_links() { + response="$(curl -e "$allanime_refr" -s "https://${allanime_base}$1" -A "$agent")" + _fm_json="$(printf '%s' "$response" | tr -d '\n ' | tr ',' '\n')" + iv="$(printf '%s' "$_fm_json" | sed -nE 's|^"iv":"([^"]*)"$|\1|p')" + payload="$(printf '%s' "$_fm_json" | sed -nE 's|^"payload":"([^"]*)"$|\1|p')" + kp1="$(printf '%s' "$_fm_json" | sed -nE 's|^"key_parts":\["([^"]*)"$|\1|p')" + kp2="$(printf '%s' "$_fm_json" | sed -nE 's|^"([A-Za-z0-9_-]+)"\]$|\1|p' | head -1)" + _kp1_hex="$(b64url_to_hex "$kp1")" + _kp2_hex="$(b64url_to_hex "$kp2")" + key_hex="$_kp1_hex$_kp2_hex" + iv_hex="$(b64url_to_hex "$iv")00000002" + tmp="$(mktemp)" + _fm_len=$(printf '%s' "$payload" | wc -c | tr -d ' ') + _fm_mod=$((_fm_len % 4)) + case $_fm_mod in + 2) _fm_pad="==" ;; + 3) _fm_pad="=" ;; + *) _fm_pad="" ;; + esac + printf '%s%s' "$payload" "$_fm_pad" | tr -- '-_' '+/' | base64 -d >"$tmp" + ct_len=$(($(wc -c <"$tmp") - 16)) + plain="$(dd if="$tmp" bs=1 count="$ct_len" 2>/dev/null | openssl enc -d -aes-256-ctr -K "$key_hex" -iv "$iv_hex" -nosalt -nopad 2>/dev/null)" + rm -f "$tmp" + printf '%s' "$plain" | tr '{}[]' '\n' | + sed -nE 's|.*"url":"([^"]*)".*"height":([0-9]+).*|\2 >\1|p;s|.*"height":([0-9]+).*"url":"([^"]*)".*|\1 >\2|p' | + sed 's|\\u0026|\&|g;s|\\u003D|=|g' | sort -rn + printf "\033[1;32m%s\033[0m Links Fetched\n" "Filemoon" 1>&2 +} + # gets embed urls, collects direct links into provider files, selects one with desired quality into $episode get_episode_url() { - # get the embed urls of the selected episode #shellcheck disable=SC2016 episode_embed_gql='query ($showId: String!, $translationType: VaildTranslationTypeEnumType!, $episodeString: String!) { episode( showId: $showId translationType: $translationType episodeString: $episodeString ) { episodeString sourceUrls }}' - resp=$(curl -e "$allanime_refr" -s -G "${allanime_api}/api" --data-urlencode "variables={\"showId\":\"$id\",\"translationType\":\"$mode\",\"episodeString\":\"$ep_no\"}" --data-urlencode "query=$episode_embed_gql" -A "$agent" | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":"--([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p') + query_hash="d405d0edd690624b66baba3068e0edc3ac90f1597d898a1ec8db4e5c43c00fec" + query_vars="{\"showId\":\"$id\",\"translationType\":\"$mode\",\"episodeString\":\"$ep_no\"}" + query_ext="{\"persistedQuery\":{\"version\":1,\"sha256Hash\":\"$query_hash\"}}" + + encoded_vars=$(printf '%s' "$query_vars" | sed 's/"/%22/g; s/:/%3A/g; s/{/%7B/g; s/}/%7D/g; s/,/%2C/g') + encoded_ext=$(printf '%s' "$query_ext" | sed 's/"/%22/g; s/:/%3A/g; s/{/%7B/g; s/}/%7D/g; s/,/%2C/g; s/ /%20/g') + + api_url="${allanime_api}/api?variables=${encoded_vars}&extensions=${encoded_ext}" + + api_resp="$(curl -e "https://youtu-chan.com" -s -A "$agent" -H "Origin: https://youtu-chan.com" "$api_url")" + + if [ -z "$api_resp" ] || ! printf "%s" "$api_resp" | grep -q "tobeparsed"; then + api_resp="$(curl -e "$allanime_refr" -s -H "Content-Type: application/json" -X POST "${allanime_api}/api" --data "{\"variables\":{\"showId\":\"$id\",\"translationType\":\"$mode\",\"episodeString\":\"$ep_no\"},\"query\":\"$episode_embed_gql\"}" -A "$agent")" + fi + + if printf "%s" "$api_resp" | grep -q '"tobeparsed"'; then + blob="$(printf "%s" "$api_resp" | sed -nE 's|.*"tobeparsed":"([^"]*)".*|\1|p')" + resp="$(decode_tobeparsed "$blob")" + else + resp="$(printf "%s" "$api_resp" | tr '{}' '\n' | sed 's|\\u002F|\/|g;s|\\||g' | sed -nE 's|.*sourceUrl":"--([^"]*)".*sourceName":"([^"]*)".*|\2 :\1|p')" + fi # generate links into sequential files cache_dir="$(mktemp -d)" - providers="1 2 3 4" + providers="1 2 3 4 5" for provider in $providers; do generate_link "$provider" >"$cache_dir"/"$provider" & done @@ -234,7 +314,7 @@ search_anime() { #shellcheck disable=SC2016 search_gql='query( $search: SearchInput $limit: Int $page: Int $translationType: VaildTranslationTypeEnumType $countryOrigin: VaildCountryOriginEnumType ) { shows( search: $search limit: $limit page: $page translationType: $translationType countryOrigin: $countryOrigin ) { edges { _id name availableEpisodes __typename } }}' - curl -e "$allanime_refr" -s -G "${allanime_api}/api" --data-urlencode "variables={\"search\":{\"allowAdult\":false,\"allowUnknown\":false,\"query\":\"$1\"},\"limit\":40,\"page\":1,\"translationType\":\"$mode\",\"countryOrigin\":\"ALL\"}" --data-urlencode "query=$search_gql" -A "$agent" | sed 's|Show|\ + curl -e "$allanime_refr" -s -H "Content-Type: application/json" -X POST "${allanime_api}/api" --data "{\"variables\":{\"search\":{\"allowAdult\":false,\"allowUnknown\":false,\"query\":\"$1\"},\"limit\":40,\"page\":1,\"translationType\":\"$mode\",\"countryOrigin\":\"ALL\"},\"query\":\"$search_gql\"}" -A "$agent" | sed 's|Show|\ | g' | sed -nE "s|.*_id\":\"([^\"]*)\",\"name\":\"(.+)\",.*${mode}\":([1-9][^,]*).*|\1 \2 (\3 episodes)|p" | sed 's/\\"//g' } @@ -257,7 +337,7 @@ episodes_list() { #shellcheck disable=SC2016 episodes_list_gql='query ($showId: String!) { show( _id: $showId ) { _id availableEpisodesDetail }}' - curl -e "$allanime_refr" -s -G "${allanime_api}/api" --data-urlencode "variables={\"showId\":\"$*\"}" --data-urlencode "query=$episodes_list_gql" -A "$agent" | sed -nE "s|.*$mode\":\[([0-9.\",]*)\].*|\1|p" | sed 's|,|\ + curl -e "$allanime_refr" -s -H "Content-Type: application/json" -X POST "${allanime_api}/api" --data "{\"variables\":{\"showId\":\"$*\"},\"query\":\"$episodes_list_gql\"}" -A "$agent" | sed -nE "s|.*$mode\":\[([0-9.\",]*)\].*|\1|p" | sed 's|,|\ |g; s|"||g' | sort -n -k 1 } @@ -347,6 +427,7 @@ play_episode() { unset episode update_history [ "$use_external_menu" = "1" ] && wait + [ "$use_external_menu" = "2" ] && wait } play() { @@ -382,7 +463,8 @@ agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefo allanime_refr="https://allmanga.to" allanime_base="allanime.day" allanime_api="https://api.${allanime_base}" -mode="${ANI_CLI_MODE:-dub}" +allanime_key="$(printf '%s' 'Xot36i3lK3:v1' | openssl dgst -sha256 -binary | od -A n -t x1 | tr -d ' \n')" +mode="${ANI_CLI_MODE:-sub}" download_dir="${ANI_CLI_DOWNLOAD_DIR:-.}" log_episode="${ANI_CLI_LOG:-1}" quality="${ANI_CLI_QUALITY:-best}" @@ -399,9 +481,9 @@ exit_after_play="${ANI_CLI_EXIT_AFTER_PLAY:-0}" use_external_menu="${ANI_CLI_EXTERNAL_MENU:-0}" external_menu_normal_window="${ANI_CLI_EXTERNAL_MENU_NORMAL_WINDOW:-0}" skip_intro="${ANI_CLI_SKIP_INTRO:-0}" -# shellcheck disable=SC2154 -skip_title="$ANI_CLI_SKIP_TITLE" -[ -t 0 ] || use_external_menu=1 +skip_title="${ANI_CLI_SKIP_TITLE:-}" +[ -t 0 ] || (command -v dmenu && use_external_menu=2) +[ -t 0 ] || (command -v rofi && use_external_menu=1) hist_dir="${ANI_CLI_HIST_DIR:-${XDG_STATE_HOME:-$HOME/.local/state}/ani-cli}" [ ! -d "$hist_dir" ] && mkdir -p "$hist_dir" histfile="$hist_dir/ani-hsts" @@ -466,6 +548,7 @@ while [ $# -gt 0 ]; do --no-detach) no_detach=1 ;; --exit-after-play) exit_after_play=1 && no_detach=1 ;; --rofi) use_external_menu=1 ;; + --dmenu) use_external_menu=2 ;; --skip) skip_intro=1 ;; --skip-title) [ $# -lt 2 ] && die "missing argument!" @@ -483,6 +566,10 @@ done [ "$external_menu_normal_window" = "1" ] && external_menu_args="-normal-window" printf "\33[2K\r\033[1;34mChecking dependencies...\033[0m\n" dep_ch "curl" "sed" "grep" || true +case "$(uname -o 2>/dev/null)" in + *ndroid*) command -v openssl >/dev/null || die 'Program "openssl" not found. On Termux, install with: pkg install openssl-tool' ;; + *) dep_ch "openssl" || true ;; +esac [ "$skip_intro" = 1 ] && (dep_ch "ani-skip" || true) dep_ch "fzf" || true case "$player_function" in @@ -576,4 +663,4 @@ done # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -# Project repository: https://github.com/pystardust/ani-cli \ No newline at end of file +# Project repository: https://github.com/pystardust/ani-cli diff --git a/.local/bin/keybinds b/.local/bin/keybinds new file mode 100755 index 0000000..f763e0b --- /dev/null +++ b/.local/bin/keybinds @@ -0,0 +1,115 @@ +#!/usr/bin/env bash + +set -euo pipefail + +file="${1:-$HOME/.config/hypr/conf/keybinds.lua}" + +awk ' +function trim(s) { + sub(/^[[:space:]]+/, "", s) + sub(/[[:space:]]+$/, "", s) + return s +} + +function escape_markup(s) { + gsub(/&/, "\\&", s) + gsub(//, "\\>", s) + return s +} + +function print_group_header(name) { + if (printed_any_group) { + print "" + } + + pretty_group = escape_markup(name) + printf "%s\n", pretty_group + printed_any_group = 1 +} + +function parse_first_arg(s, depth, in_string, out, i, c, prev) { + depth = 0 + in_string = 0 + out = "" + + for (i = 1; i <= length(s); i++) { + c = substr(s, i, 1) + prev = (i > 1 ? substr(s, i - 1, 1) : "") + + if (c == "\"" && prev != "\\") { + in_string = !in_string + } + + if (!in_string) { + if (c == "(") depth++ + else if (c == ")") depth-- + else if (c == "," && depth == 0) break + } + + out = out c + } + + return trim(out) +} + +BEGIN { + in_keybinds = 0 + group = "" + last_group = "" + mainMod = "mainMod" + printed_any_group = 0 +} + +{ + line = $0 + + if (match(line, /^[[:space:]]*local[[:space:]]+mainMod[[:space:]]*=[[:space:]]*"[^"]+"/)) { + tmp = line + sub(/^[^"]*"/, "", tmp) + sub(/".*$/, "", tmp) + mainMod = tmp + } + + if (line ~ /^[[:space:]]*--[[:space:]]*KeyBinds[[:space:]]*$/) { + in_keybinds = 1 + next + } + + if (!in_keybinds) + next + + if (line ~ /^[[:space:]]*--[[:space:]]*[^-].*$/) { + group = line + sub(/^[[:space:]]*--[[:space:]]*/, "", group) + group = trim(group) + next + } + + if (line ~ /hl\.bind[[:space:]]*\(/ && line ~ /--/) { + if (group != last_group) { + print_group_header(group) + last_group = group + } + + desc = line + sub(/^.*--[[:space:]]*/, "", desc) + desc = trim(desc) + + bind = line + sub(/^[[:space:]]*hl\.bind[[:space:]]*\(/, "", bind) + + key = parse_first_arg(bind) + + gsub(/[[:space:]]*\.\.[[:space:]]*/, "", key) + gsub(/"/, "", key) + gsub(/mainMod/, mainMod, key) + key = trim(key) + + pretty_key = escape_markup(key) + pretty_desc = escape_markup(desc) + + printf " %s — %s\n", pretty_key, pretty_desc + } +} +' "$file" | rofi -dmenu -markup-rows -i -p "Keybinds" >/dev/null diff --git a/.local/bin/start_vivaldi b/.local/bin/start_vivaldi index 613c58d..8daa047 100755 --- a/.local/bin/start_vivaldi +++ b/.local/bin/start_vivaldi @@ -9,4 +9,4 @@ while ! hyprctl activewindow | grep -q "Vivaldi"; do sleep 0.05 done -hyprctl dispatch sendshortcut CTRL,F11,activewindow +hyprctl dispatch 'hl.dsp.send_shortcut({mods = "CTRL", key = "F11", window = "activewindow"})'