summaryrefslogtreecommitdiff
path: root/volumebar-widget
diff options
context:
space:
mode:
Diffstat (limited to 'volumebar-widget')
-rw-r--r--volumebar-widget/README.md85
-rw-r--r--volumebar-widget/custom.pngbin9126 -> 0 bytes
-rw-r--r--volumebar-widget/out.gifbin5983 -> 0 bytes
-rw-r--r--volumebar-widget/volumebar.lua87
4 files changed, 0 insertions, 172 deletions
diff --git a/volumebar-widget/README.md b/volumebar-widget/README.md
deleted file mode 100644
index 305b254..0000000
--- a/volumebar-widget/README.md
+++ /dev/null
@@ -1,85 +0,0 @@
-# Volumebar widget
-
-Almost the same as volume widget, but more minimalistic:
-
-![screenshot](./out.gif)
-
-Supports
- - scroll up - increase volume,
- - scroll down - decrease volume,
- - left click - mute/unmute.
-
-## Customization
-
-It is possible to customize widget by providing a table with all or some of the following config parameters:
-
-| Name | Default | Description |
-|---|---|---|
-| `main_color` | `beautiful.fg_normal` | Color of the bar |
-| `bg_color` | `#ffffff11` | Color of the bar's background |
-| `mute_color` | `beautiful.fg_urgent` | Color of the bar when mute |
-| `width` | 50 | The bar width |
-| `shape` | `bar` | [gears.shape](https://awesomewm.org/doc/api/libraries/gears.shape.html), could be `octogon`, `hexagon`, `powerline`, etc |
-| `margins` | `10` | Top and bottom margin (if your wibar is 22 px high, bar will be 2 px (22 - 2*10)) |
-| `timeout` | 1 | How often in seconds the widget refreshes |
-| `get_volume_cmd` | `amixer -D pulse sget Master` | Get current volume level |
-| `inc_volume_cmd` | `amixer -D pulse sset Master 5%+` | Increase volume level |
-| `dec_volume_cmd` | `amixer -D pulse sset Master 5%-` | Decrease volume level |
-| `tog_volume_cmd` | `amixer -D pulse sset Master toggle` | Mute / unmute |
-
-### Example:
-
- ```lua
- volumebar_widget({
- main_color = '#af13f7',
- mute_color = '#ff0000',
- width = 80,
- shape = 'rounded_bar',
- margins = 8
-})
- ```
-
-Above config results in following widget:
-
-![custom](./custom.png)
-
-
-## Installation
-
-1. Clone this repo under **~/.config/awesome/**
-
- ```bash
- git clone https://github.com/streetturtle/awesome-wm-widgets.git ~/.config/awesome/
- ```
-
-1. Require volumebar widget at the beginning of **rc.lua**:
-
- ```lua
- local volumebar_widget = require("awesome-wm-widgets.volumebar-widget.volumebar")
- ```
-
-1. Add widget to the tasklist:
-
- ```lua
- s.mytasklist, -- Middle widget
- { -- Right widgets
- layout = wibox.layout.fixed.horizontal,
- ...
- --[[default]]
- volumebar_widget(),
- --[[or customized]]
- volumebar_widget({
- main_color = '#af13f7',
- mute_color = '#ff0000',
- width = 80,
- shape = 'rounded_bar', -- octogon, hexagon, powerline, etc
- -- bar's height = wibar's height minus 2x margins
- margins = 8
- }),
-
- ...
- ```
-
-## Troubleshooting
-
-If the bar is not showing up, try to decrease top or bottom margin - widget uses hardcoded margins for vertical alignment, so if your wibox is too small then bar is simply hidden by the margins.
diff --git a/volumebar-widget/custom.png b/volumebar-widget/custom.png
deleted file mode 100644
index d86143b..0000000
--- a/volumebar-widget/custom.png
+++ /dev/null
Binary files differ
diff --git a/volumebar-widget/out.gif b/volumebar-widget/out.gif
deleted file mode 100644
index 16653c8..0000000
--- a/volumebar-widget/out.gif
+++ /dev/null
Binary files differ
diff --git a/volumebar-widget/volumebar.lua b/volumebar-widget/volumebar.lua
deleted file mode 100644
index e7ee64d..0000000
--- a/volumebar-widget/volumebar.lua
+++ /dev/null
@@ -1,87 +0,0 @@
--------------------------------------------------
--- Volume Bar Widget for Awesome Window Manager
--- Shows the current volume level
--- More details could be found here:
--- https://github.com/streetturtle/awesome-wm-widgets/tree/master/volumebar-widget
-
--- @author Pavel Makhov
--- @copyright 2018 Pavel Makhov
--------------------------------------------------
-
-local awful = require("awful")
-local beautiful = require("beautiful")
-local gears = require("gears")
-local spawn = require("awful.spawn")
-local watch = require("awful.widget.watch")
-local wibox = require("wibox")
-
-local GET_VOLUME_CMD = 'amixer -D pulse sget Master'
-local INC_VOLUME_CMD = 'amixer -D pulse sset Master 5%+'
-local DEC_VOLUME_CMD = 'amixer -D pulse sset Master 5%-'
-local TOG_VOLUME_CMD = 'amixer -D pulse sset Master toggle'
-
-local widget = {}
-
-local function worker(user_args)
-
- local args = user_args or {}
-
- local main_color = args.main_color or beautiful.fg_normal
- local mute_color = args.mute_color or beautiful.fg_urgent
- local bg_color = args.bg_color or '#ffffff11'
- local width = args.width or 50
- local shape = args.shape or 'bar'
- local margins = args.margins or 10
- local timeout = args.timeout or 1
-
- local get_volume_cmd = args.get_volume_cmd or GET_VOLUME_CMD
- local inc_volume_cmd = args.inc_volume_cmd or INC_VOLUME_CMD
- local dec_volume_cmd = args.dec_volume_cmd or DEC_VOLUME_CMD
- local tog_volume_cmd = args.tog_volume_cmd or TOG_VOLUME_CMD
-
- local volumebar_widget = wibox.widget {
- max_value = 1,
- forced_width = width,
- color = main_color,
- background_color = bg_color,
- shape = gears.shape[shape],
- margins = {
- top = margins,
- bottom = margins,
- },
- widget = wibox.widget.progressbar
- }
-
- local update_graphic = function(_, stdout, _, _, _)
- local mute = string.match(stdout, "%[(o%D%D?)%]") -- \[(o\D\D?)\] - [on] or [off]
- local volume = string.match(stdout, "(%d?%d?%d)%%") -- (\d?\d?\d)\%)
- volume = tonumber(string.format("% 3d", volume))
-
- widget.value = volume / 100;
- widget.color = mute == "off"
- and mute_color
- or main_color
-
- end
-
- volumebar_widget:connect_signal("button::press", function(_, _, _, button)
- if (button == 4) then
- awful.spawn(inc_volume_cmd)
- elseif (button == 5) then
- awful.spawn(dec_volume_cmd)
- elseif (button == 1) then
- awful.spawn(tog_volume_cmd)
- end
-
- spawn.easy_async(get_volume_cmd, function(stdout, stderr, exitreason, exitcode)
- update_graphic(volumebar_widget, stdout, stderr, exitreason, exitcode)
- end)
- end)
-
- watch(get_volume_cmd, timeout, update_graphic, volumebar_widget)
-
- return volumebar_widget
-end
-
-return setmetatable(widget, { __call = function(_, ...) return worker(...) end })
-