From 04ab0cd4e94940ba31f0db53202609b3801906e6 Mon Sep 17 00:00:00 2001 From: kokopi-dev Date: Sat, 4 Apr 2026 23:55:05 +0900 Subject: [PATCH] init --- README.md | 6 ++++++ git/README.md | 1 + git/git-token | 30 +++++++++++++++++++++++++++++ misc/README.md | 1 + misc/enablefkeys | 2 ++ music/README.md | 1 + music/playlist.sh | 12 ++++++++++++ updaters/README.md | 1 + updaters/update-discord.sh | 39 ++++++++++++++++++++++++++++++++++++++ 9 files changed, 93 insertions(+) create mode 100644 README.md create mode 100644 git/README.md create mode 100755 git/git-token create mode 100644 misc/README.md create mode 100755 misc/enablefkeys create mode 100644 music/README.md create mode 100755 music/playlist.sh create mode 100644 updaters/README.md create mode 100755 updaters/update-discord.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..60442d9 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ +# Main Repo is self-hosted on [Gitea](https://git.kokopi.dev/kokopi/scripts-collection) +- This is a mirror + +# Personal Scripts Collection + +Collection of scripts I use frequently diff --git a/git/README.md b/git/README.md new file mode 100644 index 0000000..a761d2a --- /dev/null +++ b/git/README.md @@ -0,0 +1 @@ +- git-token: helps modify the remote in current git dir to add user:token, works with github and gitea diff --git a/git/git-token b/git/git-token new file mode 100755 index 0000000..9a84f43 --- /dev/null +++ b/git/git-token @@ -0,0 +1,30 @@ +#!/bin/bash + +# Simple script to inject token:name into existing git remote URL +# Usage: git-token + +[ $# -ne 2 ] && { echo "Usage: git-token "; exit 1; } + +NAME="$1" +TOKEN="$2" + +REMOTE=$(git remote get-url origin 2>/dev/null) || { echo "No origin remote found"; exit 1; } + +# if ssh convert, else normal +if [[ $REMOTE =~ ^git@([^:]+):(.+)$ ]]; then + # SSH format: git@host:path -> https://token:name@host/path + HOST="${BASH_REMATCH[1]}" + PATH="${BASH_REMATCH[2]}" + NEW_URL="https://${NAME}:${TOKEN}@${HOST}/${PATH}" +elif [[ $REMOTE =~ ^https://(.+)$ ]]; then + # HTTPS format: https://rest -> https://token:name@rest + NEW_URL="https://${NAME}:${TOKEN}@${BASH_REMATCH[1]}" +else + echo "Unsupported remote format: $REMOTE" + exit 1 +fi + +# Set new remote +git remote set-url origin "$NEW_URL" + +echo "Remote updated: $NEW_URL" diff --git a/misc/README.md b/misc/README.md new file mode 100644 index 0000000..4e1f6a8 --- /dev/null +++ b/misc/README.md @@ -0,0 +1 @@ +- enablefkeys: enables the fkey row for the lofree 84 keyboard diff --git a/misc/enablefkeys b/misc/enablefkeys new file mode 100755 index 0000000..e9b3aca --- /dev/null +++ b/misc/enablefkeys @@ -0,0 +1,2 @@ +#!/bin/bash +echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode diff --git a/music/README.md b/music/README.md new file mode 100644 index 0000000..00d4e24 --- /dev/null +++ b/music/README.md @@ -0,0 +1 @@ +playlist.sh: runs mpv with a folder of music as a playlist diff --git a/music/playlist.sh b/music/playlist.sh new file mode 100755 index 0000000..a017af6 --- /dev/null +++ b/music/playlist.sh @@ -0,0 +1,12 @@ +#!/bin/bash +if ! command -v mpv &> /dev/null; then + echo "mpv is not installed" + exit 1 +fi + +echo "space = play/pause" +echo "volume up/down = 9|0" +echo "<,> = back,next" +echo "q = quit" +echo "left/right = skip seconds" +mpv --input-ipc-server=/tmp/mpvsocket --shuffle --loop-playlist=inf "$@" diff --git a/updaters/README.md b/updaters/README.md new file mode 100644 index 0000000..500b192 --- /dev/null +++ b/updaters/README.md @@ -0,0 +1 @@ +- update-discord.sh: helps update discord on linux with the give .tar.gz file diff --git a/updaters/update-discord.sh b/updaters/update-discord.sh new file mode 100755 index 0000000..a202529 --- /dev/null +++ b/updaters/update-discord.sh @@ -0,0 +1,39 @@ +#!/bin/bash +if [ -z "$1" ]; then + echo "Usage: $0 " + echo "Example: $0 discord-0.0.20.tar.gz" + exit 1 +fi + +func_validate_filename() { + # Convert to lowercase for case-insensitive matching + local lower_input=$(echo "$1" | tr '[:upper:]' '[:lower:]') + + # Check if both "discord" and ".deb" are present + if [[ "$lower_input" == *"discord"* ]] && [[ "$lower_input" == *".tar.gz"* ]]; then + echo "✓ Updated Discord with file: '$1'" + return 0 + else + echo "✗ No match: '$1' does not contain both 'discord' and '.tar.gz'" + + # Provide specific feedback + if [[ "$lower_input" != *"discord"* ]]; then + echo " - Missing 'discord' ✗" + fi + + if [[ "$lower_input" != *".deb"* ]]; then + echo " - Missing '.deb' ✗" + fi + + return 1 + fi +} + +if func_validate_filename "$1"; then + sudo tar -xzf "$1" + sudo rm -rf /opt/discord + sudo mv Discord /opt/discord + sudo ln -sf /opt/discord/Discord /usr/bin/discord +fi + +#TODO check for .desktop file and create if not exists