Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Never again forget about your open mic! #98

Closed
cig0 opened this issue Apr 5, 2015 · 7 comments
Closed

Never again forget about your open mic! #98

cig0 opened this issue Apr 5, 2015 · 7 comments

Comments

@cig0
Copy link

cig0 commented Apr 5, 2015

Hi all,
@vivien, rest of the contributing folks: I just want to thank you'll for i3blocks, I just switched to it over last night and I love it.

So, here's my little contribution that I would like to add to the wiki in case anyone find it useful once we all agree it meets the minimum quality standards :)


mic

I use Skype, Linphone and Hangouts every day at work and I constantly forget to mute the damn mic whenever I'm on a call but not participating on it actively or just waiting for my turn to speak.
I created this little blocklet that hopefully will help me be aware whenever my mic is open so I can mute it and keep things professionally :D

Also I hope my pal @cawa will stop babysitting me and telling me to shut the mic!

So without more ado here are some screenshots and the correspondent code.

Screenshots

2015-04-04_2620_1600x900
2015-04-04_3033_1600x900
micc_alt
mico
mico_alt
micc

As you can see on the above screenshots I already ship two variants of the mics shown - also the colors can be customized too.

Fonts utilized:
i3: font pango:Terminus 9 (frames, dialog boxes, status bar)
Eye candy: Font Awesome

Code

Now the most important part is done (that is showing some fancy screenshots), here comes the code.
Relevant ~/.config/i3blocks/config stuff:

...
command=~/.config/i3blocks/blocklets/$BLOCK_NAME
[mic]
color=#FFFFFF
interval=5
...

~/.config/i3blocks/blocklets/mic:

#!/bin/bash
# Copyright (C) 2015 Martín Cigorraga <archlinux.us: msx>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the Affero GNU General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


# Check mouse event
case $BLOCK_BUTTON in
    3)
    #/usr/bin/amixer set Capture toggle &>/dev/null;  # AlsaMixer
    /usr/bin/pactl set-source-mute 1 toggle;  # PulseAudio
esac


# Determine mic's state
#amixer contents | grep -q "values=off" && [[ $? -eq 0 ]] && state="off";  # If you use AlaMixer
pactl list sources | grep -q "Mute: yes" && [[ $? -eq 0 ]] && state="off";  # If you rather go with PulseAudio


# Toggle mic's state
case $state in
    off)
    echo "" " muted ";
    #echo "  "
    echo
    echo \#005FD7;  # Soft blue
    #echo \#00FF00;  # Bright green
    exit 0;
    ;;
    *)
    echo "" " OPEN   ";
    #echo "      ";
    exit 33;
    ;;
esac

exit 0;

Features

  • Avoids possibly mistakes when you are unaware the mic is open 👍
  • Lets you toggle MUTE state with a right-click.
  • The script reads mic's state every 5 seconds (default) so if you set the mic state using AlsaMixer or similar app the change will be reflected on next refresh.
  • I ship the script ready to use it with AlsaMixer and PulseAudio (default), you can toggle which backend you prefer by simply uncommenting the appropriate lines.
  • If you happen to sometimes be faraway as I am, you will probably choose to use the bigger alert. However as everything is in plain text you can customize anything to your liking.

Requirements

For toggling mic's state:
  • amixer (AlsaMixer)
  • pactl (PulseAudio)
Eye candy:

That's all for now, I hope mic will be useful for someone else.
Any ideas/critics on how to improve this circus is welcome (in fact I would love to know about them).
Cheers!

@zopieux
Copy link
Contributor

zopieux commented Apr 5, 2015

I guess you can update the wiki without requesting it in an issue. Thanks for your work, seems really handy and pretty!

@cig0
Copy link
Author

cig0 commented Apr 5, 2015

EDIT: moved to the wiki with the other blocklets, thanks :)

@cig0 cig0 closed this as completed Apr 5, 2015
@ghost
Copy link

ghost commented Apr 7, 2015

Hope you don't mind, I just cleaned up the code a touch to keep a consistent style. I also removed the colour within the script because it should be set in the i3blocks config. A also fixed AlsaMixer's lines because the code didn't work for me when I used it.

Very clever idea btw! I'm very glad to have this going forward.

@cig0
Copy link
Author

cig0 commented Apr 7, 2015

Thank you very much, I will check everything later when I have a break.
Cheers!

@vivien
Copy link
Owner

vivien commented Apr 14, 2015

Thanks @msx for this addition! I add the link here https://github.com/vivien/i3blocks/wiki/Blocklets#mic since it's definitely a good piece of work!

@cig0
Copy link
Author

cig0 commented Apr 14, 2015

Nice to see it could be useful to anyone else, thank you Vivien :)

@qazip
Copy link

qazip commented Apr 30, 2022

Sorry, but is this script available in the contrib repo? I can't find it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants