aboutsummaryrefslogtreecommitdiff
path: root/usb-device-remove.sh
blob: 55189d5d9d6aa7be70fac29add60047cf25c0b55 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash

export XAUTHORITY=/home/philip/.Xauthority
export DISPLAY=:0
export DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"

busname="/dev/$1";
devpath=$2;

deviceDetails=$(lsusb -D ${busname} 2>/dev/null | head -n 1)
deviceName=$(cut -d " " -f4- <<< ${deviceDetails})
deviceID=$(cut -d " " -f3 <<< ${deviceDetails})

case "$deviceID" in
  "1b3f:2019")
     pactl set-default-source rnnoise_source
     dunstify -t 2000 -a "Microphone" -u low -i media-removable-symbolic \
       -h string:x-dunst-stack-tag:usb-microphone "USB Microphone removed"
  ;;
  "04e8:4001")
     # Samsung Electronics Co., Ltd PSSD T7
     dunstify -t 2000 -a "SSD" -u low -i media-removable-symbolic \
       -h string:x-dunst-stack-tag:usb-ssd "USB SSD disconnected"        
  ;;
  "8087:0024")
     # Intel Corp. Integrated Rate Matching Hub
     # internal hub, do nothing
  ;;
  *)
     dunstify -u normal -t 1000 -r 9000 -i media-removable-symbolic \
       -h string:x-dunst-stack-tag:usb-device "Removed $deviceDetails"
  ;;
esac