diff options
| author | krolyxon <me@krolyxon.com> | 2026-09-27 13:56:23 +0530 |
|---|---|---|
| committer | krolyxon <me@krolyxon.com> | 2026-09-27 13:56:23 +0530 |
| commit | 7c0c226ec5db91a090b0acd0487a3612301995ef (patch) | |
| tree | 6f99aa0fe8c926c8641efb84bc2eaf402d46a9d6 /.local | |
| parent | ace9df58c7f7c4f5cf140f9bf17418c5947fcf5f (diff) | |
Diffstat (limited to '.local')
| -rwxr-xr-x | .local/bin/bcn | 57 | ||||
| -rwxr-xr-x | .local/bin/nvidia-run | 9 |
2 files changed, 51 insertions, 15 deletions
diff --git a/.local/bin/bcn b/.local/bin/bcn index b87e2ab..340f6c0 100755 --- a/.local/bin/bcn +++ b/.local/bin/bcn @@ -1,24 +1,51 @@ #!/bin/bash -#bcn, Bluetooth Connect +# bcn, Bluetooth Connect +mapfile -t devices < <(bluetoothctl devices) -device_amount=$(bluetoothctl devices | wc -l) +if [[ ${#devices[@]} -eq 0 ]]; then + notify-send "Bluetooth" "No devices found" + exit 1 +fi -if [[ $device_amount = 1 ]]; then - MAC=$(bluetoothctl devices | awk {'print $2'}) - [ -z $MAC ] && MAC=NoDeviceFound # Prevents accidental disconnect error +if [[ ${#devices[@]} -eq 1 ]]; then + line="${devices[0]}" else - select=$(bluetoothctl devices | awk {'print $3'} | fuzzel --dmenu -l 10 -fn Monospace-15) - MAC=$(bluetoothctl devices | grep $select | awk {'print $2'}) - [ -z $MAC ] && MAC=NoDeviceFound # Prevents accidental disconnect error + names=$(printf '%s\n' "${devices[@]}" | sed 's/^Device [^ ]* //') + + selected=$(printf '%s\n' "$names" | + fuzzel --dmenu -l 10 -fn Monospace-15) + + [[ -z "$selected" ]] && exit 0 + + # Find MAC corresponding to selected full name + for device in "${devices[@]}"; do + name=$(echo "$device" | cut -d' ' -f3-) + + if [[ "$name" == "$selected" ]]; then + line="$device" + break + fi + done fi -connect=$(bluetoothctl info $MAC | grep Connected: | awk '{print $2}') -if [[ $connect = no ]]; then - notify-send "Attempting to connect to $select" - bluetoothctl connect $MAC || notify-send "Failed to Connect" -elif [[ $connect = yes ]]; then - notify-send "Attempting to disconnect $select" - bluetoothctl disconnect $MAC +MAC=$(echo "$line" | awk '{print $2}') +NAME=$(echo "$line" | cut -d' ' -f3-) + +connect=$(bluetoothctl info "$MAC" | + awk '/Connected:/ {print $2}') + +if [[ "$connect" == "no" ]]; then + notify-send "Bluetooth" "Connecting to $NAME..." + + if bluetoothctl connect "$MAC"; then + notify-send "Bluetooth" "Connected to $NAME" + else + notify-send "Bluetooth" "Failed to connect to $NAME" + fi + +elif [[ "$connect" == "yes" ]]; then + notify-send "Bluetooth" "Disconnecting from $NAME..." + bluetoothctl disconnect "$MAC" fi diff --git a/.local/bin/nvidia-run b/.local/bin/nvidia-run new file mode 100755 index 0000000..b5fca63 --- /dev/null +++ b/.local/bin/nvidia-run @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +export __NV_PRIME_RENDER_OFFLOAD=1 +export __GLX_VENDOR_LIBRARY_NAME=nvidia +export __VK_LAYER_NV_optimus=NVIDIA_only +export GBM_BACKEND=nvidia-drm +export LIBVA_DRIVER_NAME=nvidia + +exec "$@" |
