Add scripts

This commit is contained in:
Thraix
2026-07-15 17:24:10 +02:00
parent 8e28f60c91
commit b6e779c324
9 changed files with 245 additions and 0 deletions
+1
View File
@@ -5,3 +5,4 @@ hyprland ~/.config/hypr
kitty ~/.config/kitty kitty ~/.config/kitty
zshrc ~/.zshrc zshrc ~/.zshrc
clang_format ~/.clang-format clang_format ~/.clang-format
scripts ~/Scripts
+103
View File
@@ -0,0 +1,103 @@
#!/usr/bin/env bash
### CONFIG ###
# Name of the virtual sink
SINK_NAME="discord_sink"
# Name of your real output device (auto-detected later)
REAL_OUTPUT=""
################
set -e
echo "=== Discord App-Audio Routing Script ==="
echo "This will route ONLY one chosen application's audio to Discord."
echo
SINK_INPUTS=$(pactl list short sink-inputs | awk '{print $1}')
if [[ -z "$SINK_INPUTS" ]]; then
echo "No audio streams detected. Make sure the target app is playing audio!"
exit 1
fi
i=1
declare -A ID_MAP
for ID in $SINK_INPUTS; do
CLIENT_ID=$(pactl list short sink-inputs | awk -v id="$ID" '$1 == id {print $3}')
CLIENT_NAME=$(pactl list short clients | awk -v cid="$CLIENT_ID" '$1 == cid {print $3}')
# Remove quotes around client names, if any
CLIENT_NAME=${CLIENT_NAME//\"/}
echo "$i) $CLIENT_NAME (sink-input $ID)"
ID_MAP[$i]=$ID
i=$((i+1))
done
echo
read -p "Select the number of the app to route to Discord: " CHOICE
echo
TARGET_ID=${ID_MAP[$CHOICE]}
if [[ -z "$TARGET_ID" ]]; then
echo "Invalid choice."
exit 1
fi
echo $TARGET_ID
# --- Detect real output device ---
echo "[*] Detecting your real output device..."
REAL_OUTPUT=$(pactl list short sinks | grep -E "RUNNING|IDLE" | head -n1 | awk '{print $2}')
if [[ -z "$REAL_OUTPUT" ]]; then
echo "Could not automatically detect real output device! Exiting."
exit 1
fi
echo " -> Real output device: $REAL_OUTPUT"
echo
# --- Create virtual sink ---
echo "[*] Creating virtual sink '$SINK_NAME'..."
pactl load-module module-null-sink sink_name=$SINK_NAME sink_properties=device.description="Discord_Share_Audio" >/dev/null
# Virtual monitor name
MONITOR="${SINK_NAME}.monitor"
# --- Make virtual sink default ---
echo "[*] Setting virtual sink as default output..."
pactl set-default-sink $SINK_NAME
# --- Create loopback so you can hear things ---
echo "[*] Creating loopback so you hear the audio normally..."
LOOPBACK_ID=$(pactl load-module module-loopback source=$MONITOR sink=$REAL_OUTPUT latency_msec=1)
echo " -> Loopback module: $LOOPBACK_ID"
echo
echo "[*] Routing selected app (${TARGET_ID}) to $SINK_NAME..."
pactl move-sink-input "$TARGET_ID" "$SINK_NAME"
echo
echo "==========================================================="
echo "✔ Routing complete."
echo "Start Discord screen share now — it will capture ONLY this app."
echo
echo "When you're done, press ENTER to restore normal audio."
echo "==========================================================="
read -p ""
# --- Cleanup ---
echo "[*] Restoring your real default output..."
pactl set-default-sink $REAL_OUTPUT
echo "[*] Removing loopback..."
pactl unload-module "$LOOPBACK_ID"
echo "[*] Removing virtual sink..."
pactl unload-module module-null-sink
echo "✔ Done. Audio restored."
+34
View File
@@ -0,0 +1,34 @@
SINK_INPUTS=$(pactl list short sink-inputs | awk '{print $1}')
if [[ -z "$SINK_INPUTS" ]]; then
echo "No audio streams detected. Make sure the target app is playing audio!"
exit 1
fi
i=1
declare -A ID_MAP
for ID in $SINK_INPUTS; do
CLIENT_ID=$(pactl list short sink-inputs | awk -v id="$ID" '$1 == id {print $3}')
CLIENT_NAME=$(pactl list short clients | awk -v cid="$CLIENT_ID" '$1 == cid {print $3}')
# Remove quotes around client names, if any
CLIENT_NAME=${CLIENT_NAME//\"/}
echo "$i) $CLIENT_NAME (sink-input $ID)"
ID_MAP[$i]=$ID
i=$((i+1))
done
echo
read -p "Select the number of the app to route to Discord: " CHOICE
echo
TARGET_ID=${ID_MAP[$CHOICE]}
if [[ -z "$TARGET_ID" ]]; then
echo "Invalid choice."
exit 1
fi
echo $TARGET_ID
+1
View File
@@ -0,0 +1 @@
kill -9 $(ps ax | grep -i jagex | awk -F ' ' '{print $1}')
+37
View File
@@ -0,0 +1,37 @@
#!/usr/bin/sh
uptime="$(uptime -p | sed -e 's/up //g')"
shutdown='⏻ Shutdown'
reboot=' Reboot'
lock=' Lock'
suspend='󰒲 Suspend'
logout='󰈆 Logout'
hibernate=' Hibernate'
rofi_cmd() {
echo -e "$lock\n$suspend\n$logout\n$hibernate\n$shutdown\n$reboot" |
rofi -dmenu -mesg "Uptime: $uptime" -theme ~/.config/rofi/power.rasi
}
chosen="$(rofi_cmd)"
case ${chosen} in
$shutdown)
systemctl poweroff
;;
$reboot)
systemctl reboot
;;
$lock)
hyprlock
;;
$suspend)
systemctl suspend
;;
$logout)
hyprctl dispatch exit
;;
$hibernate)
systemctl hibernate
;;
esac
+8
View File
@@ -0,0 +1,8 @@
#!/bin/sh
if wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | grep "1.00" >> /dev/null; then
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 0
paplay ~/Music/mute.wav
else
wpctl set-volume @DEFAULT_AUDIO_SOURCE@ 1
paplay ~/Music/unmute.wav
fi
+56
View File
@@ -0,0 +1,56 @@
#/bin/sh
list_of_sinks_to_toggle=("alsa_output.usb-HP__Inc_HyperX_Cloud_Alpha_Wireless_00000001-00.analog-stereo"
"bluez_output.90_F2_60_64_1E_12.1")
get_current_sink() {
pactl get-default-sink
}
is_bluetooth_speaker_connected() {
pactl list sinks | grep "Name:" | awk -F ' ' '{print $2}' | grep --color=never "bluez_output.90_F2_60_64_1E_12.1"
}
pre_change_command() {
if [ $1 == "bluez_output.90_F2_60_64_1E_12.1" ]
then
if [ -z $(is_bluetooth_speaker_connected) ]
then
notify-send "Speaker Toggler" "Connecting bluetooth speakers"
bluetoothctl connect 90:F2:60:64:1E:12 > /dev/null 2>&1
status=$?
if [ $? -ne 0 ]
then
notify-send "Speaker Toggler" "Could not connect bluetooth speaker\nMaybe it is not turned on?"
exit 1
fi
while [ -z $(is_bluetooth_speaker_connected) ]
do
sleep 0.05
done
fi
fi
}
current_sink=$(get_current_sink)
index=-1;
for i in "${!list_of_sinks_to_toggle[@]}"
do
if [ "${list_of_sinks_to_toggle[$i]}" == "$current_sink" ]
then
index=$i
fi
done
if [ $index == -1 ]
then
echo "err: current sink not found in cycle"
fi
next_index=$(((index + 1) % ${#list_of_sinks_to_toggle[@]} ))
next_sink=${list_of_sinks_to_toggle[$next_index]}
pre_change_command $next_sink
pactl set-default-sink $next_sink
+1
View File
@@ -0,0 +1 @@
curl -fSsL https://raw.githubusercontent.com/USA-RedDragon/jagex-launcher-linux-flatpak/main/install.sh | bash
+4
View File
@@ -0,0 +1,4 @@
for s in $(hyprctl monitors | grep Monitor | awk -F ' ' '{print $2}'); do
hyprctl hyprpaper wallpaper "$s,$1"
echo "$s,$1"
done