awesome-www/recipes/mic.mdwn

51 lines
1.2 KiB
Plaintext
Raw Normal View History

2021-03-18 23:01:30 +01:00
# Microphone state widget/watcher
2021-04-02 11:38:54 +02:00
2021-03-18 23:01:30 +01:00
This widget can be used to display the current microphone status.
## Requirements
2021-04-02 11:38:54 +02:00
2021-03-18 23:01:30 +01:00
- `amixer` - this command is used to get and toggle microphone state
## Usage
2021-04-02 11:38:54 +02:00
2021-03-18 23:01:30 +01:00
- Download [mic.lua](https://awesomewm.org/recipes/mic.lua) file and put it into awesome's
folder (like `~/.config/awesome/widgets/mic.lua`)
2021-04-02 11:38:54 +02:00
2021-03-18 23:01:30 +01:00
- Add widget to `theme.lua`:
2021-04-02 11:38:54 +02:00
```lua
local widgets = {
mic = require("widgets/mic"),
}
theme.mic = widgets.mic({
timeout = 10,
settings = function(self)
if self.state == "muted" then
self.widget:set_image(theme.widget_micMuted)
else
self.widget:set_image(theme.widget_micUnmuted)
end
end
})
local widget_mic = wibox.widget { theme.mic.widget, layout = wibox.layout.align.horizontal }
```
2021-03-18 23:01:30 +01:00
- Create a shortcut to toggle microphone state (add to `rc.lua`):
2021-04-02 11:38:54 +02:00
```lua
-- Toggle microphone state
awful.key({ modkey, "Shift" }, "m",
function ()
beautiful.mic:toggle()
end,
{description = "Toggle microphone (amixer)", group = "Hotkeys"}
),
```
2021-03-18 23:01:30 +01:00
- You can also add a command to mute the microphone state on boot. Add this to your `rc.lua`:
2021-04-02 11:38:54 +02:00
```lua
-- Mute microphone on boot
beautiful.mic:mute()
```