title: My shell script is doing things in reverse
body: <p>i'm new here and i'm a little older. I decided to start learning shell script because i love Linux and it gives me a reason to automate a lot of tasks at home. And i want to learn programming to maybe change jobs one day.</p>
  
  <p>Anyway, i did a script to raise, lower and mute my volume and send a notification. But when i mute, it shows the volume and when it's unmuted (the sound is playing) it shows "mute" on the notification. It's doing things in reverse.</p>
  
  <p>Here is the code: <a href="https://pastebin.com/mdKbC2CT" rel="nofollow noreferrer">link</a></p>
  
  <pre><code>#!/bin/bash
  # Manage volume and send notify with dunst
  
  msgId="777" # unique ID for dunstify to replace the notification
  getvol=$(amixer get Master | grep % | cut -d '[' -f 2 | cut -d ']' -f 1)   # get vol %
  muted=$(amixer get Master | grep % | cut -d '[' -f 4 | cut -d ']' -f 1 )   # check if on/off
  
  function notification {
      dunstify -u low -r $msgId "$getvol"
  }
  
  case $1 in
      up)
          amixer sset Master 3%+  &gt; /dev/null
          notification
      ;;
      down)
          amixer sset Master 3%- &gt; /dev/null
          notification
      ;;
      mute)
          amixer sset Master toggle &gt; /dev/null
          if [ $muted == "off" ]; then
               dunstify -u low -r $msgId "Mute"
          else
               notification
          fi
      ;;
  esac
  </code></pre>
  
  <p>It works like this:</p>
  
  <p>./vol.sh up</p>
  
  <p>./vol.sh down</p>
  
  <p>./vol.sh mute (here is where the problem is)</p>
  
  <p>I could just change if [ $muted == "off" ] to if [ $muted == "on" ], but it doesn't make sense to me.</p>
  
  <p>PS: to be clear, when it shows off in <em>amixer get Master</em> it means the sound is off and not that the muted state is off.</p>
  
  <p>Thanks! Feel free to give me other tips too.</p>