diff --git a/configs b/configs index c6ce035..013be22 100644 --- a/configs +++ b/configs @@ -5,3 +5,4 @@ hyprland ~/.config/hypr kitty ~/.config/kitty zshrc ~/.zshrc clang_format ~/.clang-format +scripts ~/Scripts diff --git a/scripts/discord_app_audio.sh b/scripts/discord_app_audio.sh new file mode 100755 index 0000000..436426e --- /dev/null +++ b/scripts/discord_app_audio.sh @@ -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." diff --git a/scripts/get_target.sh b/scripts/get_target.sh new file mode 100755 index 0000000..ff5f3ae --- /dev/null +++ b/scripts/get_target.sh @@ -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 diff --git a/scripts/kill_rs.sh b/scripts/kill_rs.sh new file mode 100755 index 0000000..a2e9d00 --- /dev/null +++ b/scripts/kill_rs.sh @@ -0,0 +1 @@ +kill -9 $(ps ax | grep -i jagex | awk -F ' ' '{print $1}') diff --git a/scripts/rofi_power.sh b/scripts/rofi_power.sh new file mode 100755 index 0000000..790714a --- /dev/null +++ b/scripts/rofi_power.sh @@ -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 diff --git a/scripts/toggle_mic.sh b/scripts/toggle_mic.sh new file mode 100755 index 0000000..be02a81 --- /dev/null +++ b/scripts/toggle_mic.sh @@ -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 diff --git a/scripts/toggle_speaker.sh b/scripts/toggle_speaker.sh new file mode 100755 index 0000000..2a7b6c0 --- /dev/null +++ b/scripts/toggle_speaker.sh @@ -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 diff --git a/scripts/update_rs.sh b/scripts/update_rs.sh new file mode 100755 index 0000000..286c408 --- /dev/null +++ b/scripts/update_rs.sh @@ -0,0 +1 @@ +curl -fSsL https://raw.githubusercontent.com/USA-RedDragon/jagex-launcher-linux-flatpak/main/install.sh | bash diff --git a/scripts/update_wallpaper.sh b/scripts/update_wallpaper.sh new file mode 100755 index 0000000..1f6de83 --- /dev/null +++ b/scripts/update_wallpaper.sh @@ -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