Advertisement
Guest User

volume_widget

a guest
Jul 15th, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.01 KB | None | 0 0
  1. local volumeImage = wibox.widget {
  2.     image = path_to_icons.."audio-volume-high-symbolic.svg",
  3.     resize = false,
  4.     widget = wibox.widget.imagebox,
  5. };
  6.  
  7. local volumeLevel = awful.widget.watch(
  8.     'bash -c "amixer -D pulse sget Master | awk \'END{print $5;}\' | sed \'s/[][%?]//g\'"',
  9.     10,
  10.     function (widget, stdout)
  11.         local level = tonumber(stdout);
  12.         if level > 80 then
  13.             volumeImage:set_image(path_to_icons.."audio-volume-high-symbolic.svg");
  14.             widget:set_text(level);
  15.         elseif level > 40 then
  16.             volumeImage:set_image(path_to_icons.."audio-volume-medium-symbolic.svg");
  17.             widget:set_text(level);
  18.         else
  19.             volumeImage:set_image(path_to_icons.."audio-volume-low-symbolic.svg");
  20.             widget:set_text(level);
  21.         end
  22.     end
  23. )
  24.  
  25. local volume = {
  26.     {
  27.         volumeImage;
  28.         widget = wibox.container.margin,
  29.         top = 7,
  30.     },
  31.     {
  32.         volumeLevel;
  33.         widget = wibox.container.margin,
  34.         top = 2,
  35.     },
  36.     {
  37.         percentSymbol,
  38.         widget = wibox.container.margin,
  39.         top = 2,
  40.     },
  41.     spacing = 3;
  42.     layout = wibox.layout.fixed.horizontal;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement