This commit is contained in:
kokopi-dev
2026-04-04 23:55:05 +09:00
commit 04ab0cd4e9
9 changed files with 93 additions and 0 deletions

6
README.md Normal file
View File

@@ -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

1
git/README.md Normal file
View File

@@ -0,0 +1 @@
- git-token: helps modify the remote in current git dir to add user:token, works with github and gitea

30
git/git-token Executable file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Simple script to inject token:name into existing git remote URL
# Usage: git-token <n> <token>
[ $# -ne 2 ] && { echo "Usage: git-token <username> <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"

1
misc/README.md Normal file
View File

@@ -0,0 +1 @@
- enablefkeys: enables the fkey row for the lofree 84 keyboard

2
misc/enablefkeys Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/bash
echo 2 | sudo tee /sys/module/hid_apple/parameters/fnmode

1
music/README.md Normal file
View File

@@ -0,0 +1 @@
playlist.sh: runs mpv with a folder of music as a playlist

12
music/playlist.sh Executable file
View File

@@ -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 "$@"

1
updaters/README.md Normal file
View File

@@ -0,0 +1 @@
- update-discord.sh: helps update discord on linux with the give .tar.gz file

39
updaters/update-discord.sh Executable file
View File

@@ -0,0 +1,39 @@
#!/bin/bash
if [ -z "$1" ]; then
echo "Usage: $0 <string_to_check>"
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