scripts

scripts to make my pc work
Index Commits Files Refs
pactlsetvolume.old (2623B)
   1 #!/bin/bash
   2 
   3 amount_to_increase=$1
   4 current_volume=$(pamixer --get-volume)
   5 is_muted=$(pamixer --get-mute)
   6 
   7 send_notification() {
   8     dunstify -r 13123 -h "int:value:$1" "$2 Volume ($1%)" -t 2000;
   9 }
  10 
  11 get_icon() {
  12     if [ "$current_volume" -gt "50" ]; then
  13         icon="🔊"
  14     elif [ "$current_volume" -eq "0" ]; then
  15         icon="🔇"
  16     elif [ "$current_volume" -lt "25" ]; then
  17         icon="🔈"
  18     else
  19         icon="🔉"
  20     fi
  21 }
  22 
  23 set_volume() {
  24     max_volume=$((100 - $amount_to_increase))
  25 
  26     (($current_volume<=$max_volume)) && $(pactl set-sink-volume @DEFAULT_SINK@ +$amount_to_increase%)
  27 
  28     current_volume=$(pamixer --get-volume)
  29 
  30     # Avoid delay between notification and dwmblocks update
  31     pkill -RTMIN+1 dwmblocks;
  32 }
  33 
  34 if [[ "$is_muted" == "true" ]]; then
  35     if [[ $amount_to_increase == "0" ]]; then
  36         # It's muted and we want to unmute
  37         get_icon $icon
  38         send_notification $current_volume $icon
  39         pactl set-sink-mute @DEFAULT_SINK@ toggle;
  40         # pkill -RTMIN+1 dwmblocks; # Avoid delay between notification and dwmblocks update
  41     else
  42         # It's muted and we want to raise/lower the volume
  43         # pkill -RTMIN+1 dwmblocks;
  44         # send_notification "0" "🔇"
  45         set_volume
  46         get_icon
  47         send_notification $current_volume "🔇"
  48         # pkill -RTMIN+1 dwmblocks; # Avoid delay between notification and dwmblocks update
  49     fi
  50 else
  51     if [[ $amount_to_increase == "0" ]]; then
  52         # It's not muted and we want to mute
  53         get_icon $icon
  54         send_notification $current_volume "🔇"
  55         pactl set-sink-mute @DEFAULT_SINK@ toggle;
  56         # pkill -RTMIN+1 dwmblocks; # Avoid delay between notification and dwmblocks update
  57     else
  58         # It's not muted and we want to raise/lower the volume
  59         # send_notification "0" "🔇"
  60         set_volume
  61         get_icon
  62         send_notification $current_volume $icon
  63     fi
  64 fi
  65 
  66 pkill -RTMIN+1 dwmblocks; # Avoid delay between notification and dwmblocks update
  67 exit
  68 
  69 # if [[ $amount_to_increase == "0" ]]; then
  70 #     if [[ "$is_muted" == "true" ]]; then
  71 #         get_icon $icon
  72 #         # Avoid delay between notification and dwmblocks update
  73 #         pkill -RTMIN+1 dwmblocks;
  74 #         send_notification $current_volume $icon
  75 #         pactl set-sink-mute @DEFAULT_SINK@ toggle;
  76 #     else 
  77 #         # Avoid delay between notification and dwmblocks update
  78 #         pkill -RTMIN+1 dwmblocks;
  79 #         send_notification "0" "🔇"
  80 #         pactl set-sink-mute @DEFAULT_SINK@ toggle;
  81 #     fi
  82 #     exit
  83 # fi
  84 
  85 # max_volume=$((100 - $amount_to_increase))
  86 
  87 # (($current_volume<=$max_volume)) && $(pactl set-sink-volume @DEFAULT_SINK@ +$amount_to_increase%)
  88 
  89 # current_volume=$(pamixer --get-volume)
  90 
  91 # # Avoid delay between notification and dwmblocks update
  92 # pkill -RTMIN+1 dwmblocks;
  93 
  94 # get_icon
  95 # send_notification $current_volume $icon