TechTycho

effects/tagswitch.lua

Dec 29th, 2022 (edited)
1,203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.11 KB | None | 0 0
  1. local awful     = require("awful")
  2. local wibox     = require("wibox")
  3. local beautiful = require("beautiful")
  4. local fade      = require("animations.fade")
  5.  
  6. -- DPI
  7. local xresources = require("beautiful.xresources")
  8. local dpi = xresources.apply_dpi
  9.  
  10. local M = wibox {
  11.   visible = false,
  12.   opacity = 0,
  13.   bg      = beautiful.bg_tagswitch or beautiful.bg_normal,
  14.   fg      = beautiful.fg_tagswitch or beautiful.fg_normal,
  15.   ontop   = true,
  16.   height  = beautiful.tagswitch_height or dpi(90),
  17.   width   = beautiful.tagswitch_width or dpi(180),
  18. }
  19.  
  20. M:setup {
  21.   {
  22.     id     = "text",
  23.     markup = "<b>dev</b>",
  24.     font   = beautiful.tagswitch_font or beautiful.font,
  25.     widget = wibox.widget.textbox,
  26.   },
  27.   valign = "center",
  28.   halign = "center",
  29.   layout = wibox.container.place,
  30. }
  31.  
  32. awful.placement.centered(M, { parent = awful.screen.focused() })
  33.  
  34. M.changeText = function (text)
  35.   M:get_children_by_id("text")[1]:set_markup("<b>" .. text .. "</b>")
  36. end
  37.  
  38. M.animate = function (text)
  39.   M.changeText(text)
  40.   fade(M, beautiful.tagswitch_speed or 200, beautiful.tagswitch_delay or 0.25)
  41. end
  42.  
  43. return M
Advertisement
Add Comment
Please, Sign In to add comment