diff options
| -rwxr-xr-x | bt-init.sh | 12 | ||||
| -rwxr-xr-x | btfix.sh | 10 | ||||
| -rwxr-xr-x | btoff.sh | 9 | ||||
| -rwxr-xr-x | bton.sh | 52 | ||||
| -rwxr-xr-x | dwm-status.sh | 31 | ||||
| -rwxr-xr-x | feh | 3 | ||||
| -rwxr-xr-x | thunderbird | 2 | ||||
| -rwxr-xr-x | timer | 68 | ||||
| -rwxr-xr-x | usb-tether.sh | 13 | ||||
| -rwxr-xr-x | zathura | 3 |
10 files changed, 203 insertions, 0 deletions
diff --git a/bt-init.sh b/bt-init.sh new file mode 100755 index 0000000..32993fa --- /dev/null +++ b/bt-init.sh @@ -0,0 +1,12 @@ +#!/bin/sh +# Make Bluetooth adapter ready for use (no root) + +# Unblock in case NetworkManager / airplane mode blocked it +rfkill unblock bluetooth 2>/dev/null + +# Try to power on the adapter +bluetoothctl --timeout 5 power on >/dev/null 2>&1 + +# Optional: if you want to see status in logs: +# bluetoothctl show | awk '/Powered:/ {print "Bluetooth powered:", $2}' + diff --git a/btfix.sh b/btfix.sh new file mode 100755 index 0000000..1d9cfc4 --- /dev/null +++ b/btfix.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Reset Bluetooth adapter (run as root) + +systemctl stop bluetooth.service +modprobe -r btusb +modprobe btusb +systemctl start bluetooth.service +rfkill unblock bluetooth +bluetoothctl power on + diff --git a/btoff.sh b/btoff.sh new file mode 100755 index 0000000..77bd9aa --- /dev/null +++ b/btoff.sh @@ -0,0 +1,9 @@ +#!/bin/sh +MAC="BC:87:FA:A1:15:33" + +# Disconnect the device +bluetoothctl disconnect "$MAC" + +# Optionally power off bluetooth when not needed +bluetoothctl power off + @@ -0,0 +1,52 @@ +#!/bin/sh +# Connect Bose "Earmuffs" and set A2DP + +MAC="BC:87:FA:A1:15:33" +CARD_PATTERN="bluez_card.BC_87_FA_A1_15_33" +SINK_PATTERN="bluez_output.BC_87_FA_A1_15_33" + +echo "Waking up Bluetooth adapter..." + +# 1) Make sure Bluetooth is unblocked and powered on +rfkill unblock bluetooth 2>/dev/null + +bluetoothctl --timeout 5 power on >/dev/null 2>&1 + +# 2) Wait up to 5s until adapter reports Powered: yes +for i in 1 2 3 4 5; do + if bluetoothctl show | awk '/Powered:/ {print $2}' | grep -q yes; then + break + fi + sleep 1 +done + +if ! bluetoothctl show | awk '/Powered:/ {print $2}' | grep -q yes; then + echo "Bluetooth adapter is still not powered. Aborting." + exit 1 +fi + +# 3) Try to connect +echo "Attempting to connect to $MAC ..." +if ! bluetoothctl --timeout 10 connect "$MAC"; then + echo "Connection failed. Make sure the headphones are ON, near the laptop," + echo "and not connected to another device, then run bton.sh again." + exit 1 +fi + +# 4) Give PipeWire a moment to create card/sink +sleep 2 + +# 5) Force A2DP profile if card exists +CARD="$(pactl list short cards | awk -v pat="$CARD_PATTERN" '$2 ~ pat {print $2; exit}')" +if [ -n "$CARD" ]; then + pactl set-card-profile "$CARD" a2dp-sink >/dev/null 2>&1 +fi + +# 6) Set the sink as default if it exists +SINK="$(pactl list short sinks | awk -v pat="$SINK_PATTERN" '$2 ~ pat {print $2; exit}')" +if [ -n "$SINK" ]; then + pactl set-default-sink "$SINK" >/dev/null 2>&1 +fi + +echo "Headphones should now be connected and set as default output." + diff --git a/dwm-status.sh b/dwm-status.sh new file mode 100755 index 0000000..b41dc5c --- /dev/null +++ b/dwm-status.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +while true; do + datetime="$(date '+%a %m-%d %H:%M')" + + # Volume + if command -v pamixer >/dev/null 2>&1; then + vol="$(pamixer --get-volume-human 2>/dev/null)" + elif command -v amixer >/dev/null 2>&1; then + vol="$(amixer get Master | awk -F'[][]' 'END{print $2}')" + else + vol="n/a" + fi + + # Network on/off + if ping -c1 -W1 8.8.8.8 >/dev/null 2>&1; then + net="online" + else + net="offline" + fi + + # VPN (tun0 / wg0 / proton0 – adjust to match your system) + if ip link show tun0 >/dev/null 2>&1 || ip link show wg0 >/dev/null 2>&1 || ip link show proton0 >/dev/null 2>&1; then + vpn="VPN on" + else + vpn="VPN off" + fi + + xsetroot -name "VOL $vol | NET $net | $vpn | $datetime " + sleep 5 +done @@ -0,0 +1,3 @@ +#!/bin/sh +exec firejail /usr/bin/feh "$@" + diff --git a/thunderbird b/thunderbird new file mode 100755 index 0000000..9a764e1 --- /dev/null +++ b/thunderbird @@ -0,0 +1,2 @@ +#!/bin/sh +exec firejail /usr/bin/thunderbird "$@" @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +# timer DURATION [MESSAGE...] +# examples: timer 25m "Pomodoro done" | timer 90s "Break over" + +set -euo pipefail + +dur="${1:-}" +shift || true +msg="${*:-Time is up}" + +if [ -z "$dur" ]; then + echo "usage: timer 25m \"Pomodoro done\" | timer 90s \"Break over\"" + exit 1 +fi + +# Parse duration: Ns or Nm (only) +case "$dur" in + *m) total=$(( ${dur%m} * 60 ));; + *s) total=$(( ${dur%s} ));; + *) echo "Bad duration: $dur (use e.g. 25m or 90s)"; exit 1;; +esac + +# Terminal helpers +cols=$(tput cols 2>/dev/null || echo 80) +barw=$(( cols - 22 )) +[ "$barw" -lt 10 ] && barw=10 + +hide_cursor() { tput civis 2>/dev/null || true; } +show_cursor() { tput cnorm 2>/dev/null || true; } +cleanup() { show_cursor; printf "\n"; } +trap cleanup EXIT INT TERM + +hide_cursor + +# ANSI colors (no external deps) +YELLOW=$'\033[33m' +GREEN=$'\033[32m' +DIM=$'\033[2m' +RESET=$'\033[0m' + +secs="$total" +start_msg="${msg}" + +while [ "$secs" -gt 0 ]; do + mm=$(( secs / 60 )) + ss=$(( secs % 60 )) + + done=$(( total - secs )) + pct=$(( done * 100 / total )) + + fill=$(( barw * done / total )) + empty=$(( barw - fill )) + + # Build progress bar + bar="$(printf "%${fill}s" "" | tr ' ' '=')" + pad="$(printf "%${empty}s" "")" + + printf "\r${YELLOW}T-%02d:%02d${RESET} ${DIM}[${bar}>${pad}]${RESET} %3d%% " \ + "$mm" "$ss" "$pct" + + sleep 1 + secs=$(( secs - 1 )) +done + +printf "\r${GREEN}DONE 00:00 100%%\n" +notify-send "Timer" "$start_msg" +paplay /usr/share/sounds/freedesktop/stereo/complete.oga >/dev/null 2>&1 || true + diff --git a/usb-tether.sh b/usb-tether.sh new file mode 100755 index 0000000..bbe16ed --- /dev/null +++ b/usb-tether.sh @@ -0,0 +1,13 @@ +#!/bin/sh +IFACE=$(ip -br a | grep 'enx' | awk '{print $1}') + +sudo ip link set "$IFACE" up +sudo dhcpcd "$IFACE" + +GATEWAY=$(ip route | grep "$IFACE" | awk '/default/ {print $3}') + +sudo ip route del default +sudo ip route add default via "$GATEWAY" dev "$IFACE" + +echo "USB tethering active on $IFACE" + @@ -0,0 +1,3 @@ +#!/bin/sh +exec firejail /usr/bin/zathura "$@" + |
