Initial commit
This commit is contained in:
commit
c5703aca02
373 changed files with 12401 additions and 0 deletions
84
awesome/notif-center/README.md
Normal file
84
awesome/notif-center/README.md
Normal file
|
@ -0,0 +1,84 @@
|
|||
# Notification Center Widget
|
||||
|
||||
## A notification center widget for Awesome Window Manager
|
||||
|
||||
| Screenshot|
|
||||
| --- |
|
||||
|  |
|
||||
|
||||
| Demo |
|
||||
| --- |
|
||||
|  |
|
||||
|
||||
|
||||
# Dependencies:
|
||||
+ Awesome Window Manager (git master branch)
|
||||
+ canberra-gtk-play (optional)
|
||||
|
||||
# Instructions:
|
||||
+ Clone the repo.
|
||||
+ Just copy the `notif-center` folder to `$HOME/.config/awesome/`.
|
||||
+ Then `require` it in your `wibox panel`.
|
||||
+ For example, let's put it in the top panel of a default `rc.lua`:
|
||||
|
||||
```lua
|
||||
s.mywibox = awful.wibar({ position = "top", screen = s })
|
||||
|
||||
-- Add widgets to the wibox
|
||||
s.mywibox.widget = {
|
||||
layout = wibox.layout.align.horizontal,
|
||||
{ -- Left widgets
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
mylauncher,
|
||||
s.mytaglist,
|
||||
s.mypromptbox,
|
||||
},
|
||||
s.mytasklist, -- Middle widget
|
||||
{ -- Right widgets
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
mykeyboardlayout,
|
||||
wibox.widget.systray(),
|
||||
mytextclock,
|
||||
s.mylayoutbox,
|
||||
-- Let's put the notification center button after the layoutbox
|
||||
require('notif-center')
|
||||
},
|
||||
}
|
||||
```
|
||||
+ After that, it is recommended to add a `request::display` signal listener in your `rc.lua`:
|
||||
+ Add the snippet below:
|
||||
|
||||
```lua
|
||||
-- request::display signal listener
|
||||
naughty.connect_signal('request::display', function(n)
|
||||
naughty.layout.box {notification = n}
|
||||
end)
|
||||
```
|
||||
|
||||
+ For `Do not disturb` button to work, add the snippet below to the `request::display` signal listener mentioned above:
|
||||
|
||||
```lua
|
||||
-- We will use `destroy_all_notifications()` instead of `suspend()` because suspending naughty will also suspend the notification-center. It's a hackish way to hide the pop-ups, but hey, it's working.
|
||||
|
||||
-- Don't display notification pop-ups when the panel is visible and dont disturb mode is enabled.
|
||||
if _G.panel_visible or _G.dont_disturb then
|
||||
naughty.destroy_all_notifications()
|
||||
end
|
||||
```
|
||||
|
||||
# Extras
|
||||
You can also add a system sound effects when there is a new notification by installing `canberra-gtk-play`. Again, after that, add the snippet below inside inside the `request::display` signal.
|
||||
|
||||
```lua
|
||||
-- Add sound effects if it's not do not disturb mode
|
||||
if not _G.dont_disturb then
|
||||
-- Add Sound fx to notif
|
||||
-- Depends: canberra-gtk-play
|
||||
awful.spawn('canberra-gtk-play -i message', false)
|
||||
end
|
||||
```
|
||||
|
||||
# Note:
|
||||
+ If you have a problem, try to solve it or just open an issue.
|
||||
+ Putting the widget folder to a different path other than `$HOME/.config/awesome` may cause some issues. It is because there is some hard-coded paths in some of the files. Tinkering it by yourself is recommended. ;)
|
||||
+ Change the colors of notification panel widget in `$HOME/.config/awesome/notif-center/init.lua`
|
1
awesome/notif-center/icons/delete.svg
Normal file
1
awesome/notif-center/icons/delete.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="240" height="240" viewBox="0 0 24 24"><path fill="#ffffff" d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" /></svg>
|
After Width: | Height: | Size: 421 B |
2
awesome/notif-center/icons/dont-disturb-mode.svg
Normal file
2
awesome/notif-center/icons/dont-disturb-mode.svg
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="512px" viewBox="-12 0 448 448.04455" width="512px"><g><path d="m224.023438 448.03125c85.714843.902344 164.011718-48.488281 200.117187-126.230469-22.722656 9.914063-47.332031 14.769531-72.117187 14.230469-97.15625-.109375-175.890626-78.84375-176-176 .972656-65.71875 37.234374-125.832031 94.910156-157.351562-15.554688-1.980469-31.230469-2.867188-46.910156-2.648438-123.714844 0-224.0000005 100.289062-224.0000005 224 0 123.714844 100.2851565 224 224.0000005 224zm0 0" data-original="#000000" class="active-path" data-old_color="#000000" style="--darkreader-inline-" data-darkreader-inline-fill="" fill="#FFFFFF"/></g> </svg>
|
After Width: | Height: | Size: 695 B |
1
awesome/notif-center/icons/empty-notification.svg
Normal file
1
awesome/notif-center/icons/empty-notification.svg
Normal file
|
@ -0,0 +1 @@
|
|||
<svg height="512pt" viewBox="-17 0 511 512" width="512pt" xmlns="http://www.w3.org/2000/svg"><path d="m227.148438 446.128906c0 35.339844-27.96875 64.269532-62.9375 65.800782-.972657.050781-1.949219.070312-2.929688.070312-36.332031 0-65.882812-29.550781-65.882812-65.871094zm0 0" fill="#ff9a00"/><path d="m227.148438 446.128906c0 35.339844-27.96875 64.269532-62.9375 65.800782v-65.800782zm0 0" fill="#e67500"/><path d="m372.617188 150.859375h-84.328126l42.714844-76.324219h-35.386718v-30h86.554687l-42.714844 76.324219h33.160157zm0 0" fill="#6d76e7"/><path d="m468.285156 90.816406h-76.429687l34.035156-60.816406h-22.273437v-30h73.441406l-34.035156 60.816406h25.261718zm0 0" fill="#6d76e7"/><path d="m327.910156 450.921875-163.699218.238281-163.589844.238282-.109375-72.949219-.011719-7.167969 2.339844-3.679688c.109375-.179687 4.5-7.230468 10.171875-19.152343 9.238281-19.378907 21.878906-51.640625 25.007812-88.078125 7.058594-82.152344 52.902344-129.320313 125.769531-129.429688h.421876c38.738281.039063 69.640624 13.1875 91.867187 39.078125 18.871094 22 30.582031 53.109375 33.863281 89.96875 3.269532 36.710938 16.167969 69.140625 25.480469 88.460938 5.609375 11.628906 9.917969 18.511719 10.027344 18.679687l2.332031 3.671875.007812 4.359375.011719 3.289063zm0 0" fill="#ffdb2d"/><path d="m327.910156 450.921875-163.699218.238281v-320.21875c38.738281.039063 69.640624 13.1875 91.867187 39.078125 18.871094 22 30.582031 53.109375 33.863281 89.96875 3.269532 36.710938 16.167969 69.140625 25.480469 88.460938 5.609375 11.628906 9.917969 18.511719 10.027344 18.679687l2.332031 3.671875.007812 4.359375.011719 3.289063zm0 0" fill="#ffaa20"/><path d="m327.800781 378.449219h-327.289062l-.011719-7.167969 2.339844-3.679688c.109375-.179687 4.5-7.230468 10.171875-19.152343h302.410156c5.609375 11.628906 9.917969 18.511719 10.027344 18.679687l2.332031 3.671875.007812 4.359375zm0 0" fill="#fff5cb"/><path d="m327.800781 378.449219h-163.589843v-30h151.210937c5.609375 11.628906 9.917969 18.511719 10.027344 18.679687l2.332031 3.671875.007812 4.359375zm0 0" fill="#ffdba9"/></svg>
|
After Width: | Height: | Size: 2 KiB |
15
awesome/notif-center/icons/new-notif.svg
Normal file
15
awesome/notif-center/icons/new-notif.svg
Normal file
|
@ -0,0 +1,15 @@
|
|||
<svg style="clip-rule:evenodd;fill-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2" version="1.1" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m17.387 45.391l3.91-5.484h17.453s4.968 0.082 4.968-7.006v-22.292c-0.313-4.851-4.714-5.223-4.714-5.223h-29.298s-5.424 0.318-5.502 5.605v21.91c9e-3 6.902 5.502 7.006 5.502 7.006h2.578l3.523 5.463c0.767 0.894 0.778 0.777 1.58 0.021z" style="fill-opacity:.67"/>
|
||||
<path d="m17.387 44.002l3.91-5.484h17.453s4.968 0.081 4.968-7.006v-22.293c-0.313-4.851-4.714-5.223-4.714-5.223h-29.298s-5.424 0.318-5.502 5.606v21.91c9e-3 6.902 5.502 7.006 5.502 7.006h2.578l3.523 5.462c0.767 0.895 0.778 0.778 1.58 0.022z" style="fill:url(#_Linear1)"/>
|
||||
<circle cx="32.84" cy="6.821" r="5.728" style="fill:url(#_Linear2)"/>
|
||||
<defs>
|
||||
<linearGradient id="_Linear1" x2="1" gradientTransform="matrix(.799284 -39.6049 39.6049 .799284 498.134 53.5618)" gradientUnits="userSpaceOnUse">
|
||||
<stop style="stop-color:#888" offset="0"/>
|
||||
<stop style="stop-color:#fefeff" offset="1"/>
|
||||
</linearGradient>
|
||||
<linearGradient id="_Linear2" x2="1" gradientTransform="matrix(7.01453e-16,-11.4556,11.4556,7.01453e-16,87.5702,12.5494)" gradientUnits="userSpaceOnUse">
|
||||
<stop style="stop-color:#05f" offset="0"/>
|
||||
<stop style="stop-color:#00a0ff" offset="1"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 1.3 KiB |
74
awesome/notif-center/icons/notification.svg
Normal file
74
awesome/notif-center/icons/notification.svg
Normal file
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
height="512pt"
|
||||
viewBox="0 -43 512 512"
|
||||
width="512pt"
|
||||
version="1.1"
|
||||
id="svg14"
|
||||
sodipodi:docname="bullet-list.svg"
|
||||
inkscape:version="0.92.4 5da689c313, 2019-01-14">
|
||||
<metadata
|
||||
id="metadata20">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<defs
|
||||
id="defs18" />
|
||||
<sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1321"
|
||||
inkscape:window-height="742"
|
||||
id="namedview16"
|
||||
showgrid="false"
|
||||
inkscape:zoom="0.34570313"
|
||||
inkscape:cx="-161.9887"
|
||||
inkscape:cy="341.33333"
|
||||
inkscape:window-x="45"
|
||||
inkscape:window-y="26"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg14" />
|
||||
<path
|
||||
d="m85.332031 42.667969c0 23.5625-19.101562 42.664062-42.664062 42.664062-23.566407 0-42.667969-19.101562-42.667969-42.664062 0-23.566407 19.101562-42.667969 42.667969-42.667969 23.5625 0 42.664062 19.101562 42.664062 42.667969zm0 0"
|
||||
id="path2"
|
||||
style="fill:#ffffff;fill-opacity:1" />
|
||||
<path
|
||||
d="m85.332031 213.332031c0 23.566407-19.101562 42.667969-42.664062 42.667969-23.566407 0-42.667969-19.101562-42.667969-42.667969 0-23.5625 19.101562-42.664062 42.667969-42.664062 23.5625 0 42.664062 19.101562 42.664062 42.664062zm0 0"
|
||||
id="path4"
|
||||
style="fill:#ffffff;fill-opacity:1" />
|
||||
<path
|
||||
d="m85.332031 384c0 23.5625-19.101562 42.667969-42.664062 42.667969-23.566407 0-42.667969-19.105469-42.667969-42.667969s19.101562-42.667969 42.667969-42.667969c23.5625 0 42.664062 19.105469 42.664062 42.667969zm0 0"
|
||||
id="path6"
|
||||
style="fill:#ffffff;fill-opacity:1" />
|
||||
<path
|
||||
d="m170.667969 64h320c11.796875 0 21.332031-9.535156 21.332031-21.332031s-9.535156-21.335938-21.332031-21.335938h-320c-11.796875 0-21.335938 9.539063-21.335938 21.335938s9.539063 21.332031 21.335938 21.332031zm0 0"
|
||||
id="path8"
|
||||
style="fill:#ffffff;fill-opacity:1" />
|
||||
<path
|
||||
d="m490.667969 192h-320c-11.796875 0-21.335938 9.535156-21.335938 21.332031s9.539063 21.335938 21.335938 21.335938h320c11.796875 0 21.332031-9.539063 21.332031-21.335938s-9.535156-21.332031-21.332031-21.332031zm0 0"
|
||||
id="path10"
|
||||
style="fill:#ffffff;fill-opacity:1" />
|
||||
<path
|
||||
d="m490.667969 362.667969h-320c-11.796875 0-21.335938 9.535156-21.335938 21.332031s9.539063 21.332031 21.335938 21.332031h320c11.796875 0 21.332031-9.535156 21.332031-21.332031s-9.535156-21.332031-21.332031-21.332031zm0 0"
|
||||
id="path12"
|
||||
style="fill:#ffffff;fill-opacity:1" />
|
||||
</svg>
|
After Width: | Height: | Size: 3.2 KiB |
2
awesome/notif-center/icons/notify-mode.svg
Normal file
2
awesome/notif-center/icons/notify-mode.svg
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0"?>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" height="512px" viewBox="-21 0 512 512" width="512px"><g><path d="m448 232.148438c-11.777344 0-21.332031-9.554688-21.332031-21.332032 0-59.839844-23.296875-116.074218-65.601563-158.402344-8.339844-8.339843-8.339844-21.820312 0-30.164062 8.339844-8.339844 21.824219-8.339844 30.164063 0 50.371093 50.367188 78.101562 117.335938 78.101562 188.566406 0 11.777344-9.554687 21.332032-21.332031 21.332032zm0 0" data-original="#000000" class="active-path" style="--darkreader-inline-" data-darkreader-inline-fill="" data-old_color="#000000" fill="#FFFFFF"/><path d="m21.332031 232.148438c-11.773437 0-21.332031-9.554688-21.332031-21.332032 0-71.230468 27.734375-138.199218 78.101562-188.566406 8.339844-8.339844 21.824219-8.339844 30.164063 0 8.34375 8.34375 8.34375 21.824219 0 30.164062-42.304687 42.304688-65.597656 98.5625-65.597656 158.402344 0 11.777344-9.558594 21.332032-21.335938 21.332032zm0 0" data-original="#000000" class="active-path" style="--darkreader-inline-" data-darkreader-inline-fill="" data-old_color="#000000" fill="#FFFFFF"/><path d="m434.753906 360.8125c-32.257812-27.265625-50.753906-67.117188-50.753906-109.335938v-59.476562c0-75.070312-55.765625-137.214844-128-147.625v-23.042969c0-11.796875-9.558594-21.332031-21.332031-21.332031-11.777344 0-21.335938 9.535156-21.335938 21.332031v23.042969c-72.253906 10.410156-128 72.554688-128 147.625v59.476562c0 42.21875-18.496093 82.070313-50.941406 109.503907-8.300781 7.105469-13.058594 17.429687-13.058594 28.351562 0 20.589844 16.746094 37.335938 37.335938 37.335938h352c20.585937 0 37.332031-16.746094 37.332031-37.335938 0-10.921875-4.757812-21.246093-13.246094-28.519531zm0 0" data-original="#000000" class="active-path" style="--darkreader-inline-" data-darkreader-inline-fill="" data-old_color="#000000" fill="#FFFFFF"/><path d="m234.667969 512c38.632812 0 70.953125-27.542969 78.378906-64h-156.757813c7.421876 36.457031 39.742188 64 78.378907 64zm0 0" data-original="#000000" class="active-path" style="--darkreader-inline-" data-darkreader-inline-fill="" data-old_color="#000000" fill="#FFFFFF"/></g> </svg>
|
After Width: | Height: | Size: 2.1 KiB |
54
awesome/notif-center/init.lua
Normal file
54
awesome/notif-center/init.lua
Normal file
|
@ -0,0 +1,54 @@
|
|||
local awful = require('awful')
|
||||
local wibox = require('wibox')
|
||||
local gears = require('gears')
|
||||
local beautiful = require('beautiful')
|
||||
|
||||
local beautiful = require('beautiful')
|
||||
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
|
||||
local HOME = os.getenv('HOME')
|
||||
local clickable_container = require('notif-center.subwidgets.clickable-container')
|
||||
local PATH_TO_ICONS = HOME .. '/.config/awesome/notif-center/icons/'
|
||||
|
||||
|
||||
-- Configuration
|
||||
-- Notification background
|
||||
beautiful.bg_modal = '#252525'
|
||||
-- Notification actions bg color
|
||||
beautiful.bg_actions = '#353535'
|
||||
-- Notification panel background
|
||||
beautiful.panel_bg = '#0a0a0a'
|
||||
-- Rounded corner radius
|
||||
beautiful.modal_radius = dpi(9)
|
||||
|
||||
-- Load panel rules, it will create panel for each screen
|
||||
require('notif-center.notif-panel-rules')
|
||||
|
||||
|
||||
local widget =
|
||||
wibox.widget {
|
||||
{
|
||||
id = 'icon',
|
||||
image = PATH_TO_ICONS .. 'notification' .. '.svg',
|
||||
widget = wibox.widget.imagebox,
|
||||
resize = true
|
||||
},
|
||||
layout = wibox.layout.align.horizontal
|
||||
}
|
||||
|
||||
local widget_button = clickable_container(wibox.container.margin(widget, dpi(4), dpi(4), dpi(4), dpi(4)))
|
||||
widget_button:buttons(
|
||||
gears.table.join(
|
||||
awful.button(
|
||||
{},
|
||||
1,
|
||||
nil,
|
||||
function()
|
||||
_G.screen.primary.notif_panel:toggle()
|
||||
end
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
return widget_button
|
61
awesome/notif-center/notif-panel-rules.lua
Normal file
61
awesome/notif-center/notif-panel-rules.lua
Normal file
|
@ -0,0 +1,61 @@
|
|||
local awful = require('awful')
|
||||
local wibox = require('wibox')
|
||||
local gears = require('gears')
|
||||
|
||||
local notif_panel = require('notif-center.notif-panel')
|
||||
|
||||
-- Create a wibox for each screen connected
|
||||
screen.connect_signal("request::desktop_decoration", function(s)
|
||||
if s.index == 1 then
|
||||
-- Create the notif_panel
|
||||
s.notif_panel = notif_panel(s)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Hide panel when clients go fullscreen
|
||||
showAgain = false
|
||||
function updateRightBarsVisibility()
|
||||
for s in screen do
|
||||
if s.selected_tag then
|
||||
local fullscreen = s.selected_tag.fullscreenMode
|
||||
if s.notif_panel then
|
||||
if fullscreen and s.notif_panel.visible then
|
||||
_G.screen.primary.notif_panel:toggle()
|
||||
showAgain = true
|
||||
elseif not fullscreen and not s.notif_panel.visible and showAgain then
|
||||
_G.screen.primary.notif_panel:toggle()
|
||||
showAgain = false
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
_G.tag.connect_signal(
|
||||
'property::selected',
|
||||
function(t)
|
||||
updateRightBarsVisibility()
|
||||
end
|
||||
)
|
||||
|
||||
_G.client.connect_signal(
|
||||
'property::fullscreen',
|
||||
function(c)
|
||||
if c.first_tag then
|
||||
c.first_tag.fullscreenMode = c.fullscreen
|
||||
end
|
||||
updateRightBarsVisibility()
|
||||
end
|
||||
)
|
||||
|
||||
_G.client.connect_signal(
|
||||
'unmanage',
|
||||
function(c)
|
||||
if c.fullscreen then
|
||||
c.screen.selected_tag.fullscreenMode = false
|
||||
updateRightBarsVisibility()
|
||||
end
|
||||
end
|
||||
)
|
103
awesome/notif-center/notif-panel.lua
Normal file
103
awesome/notif-center/notif-panel.lua
Normal file
|
@ -0,0 +1,103 @@
|
|||
local awful = require('awful')
|
||||
local wibox = require('wibox')
|
||||
local gears = require('gears')
|
||||
local beautiful = require('beautiful')
|
||||
|
||||
local HOME = os.getenv('HOME')
|
||||
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
|
||||
panel_visible = false
|
||||
|
||||
local right_panel = function(screen)
|
||||
local panel_width = dpi(350)
|
||||
local panel = wibox {
|
||||
ontop = true,
|
||||
screen = screen,
|
||||
width = panel_width,
|
||||
height = screen.geometry.height,
|
||||
x = screen.geometry.width - panel_width,
|
||||
bg = beautiful.panel_bg,
|
||||
fg = beautiful.fg_normal,
|
||||
}
|
||||
|
||||
panel.opened = false
|
||||
|
||||
local backdrop = wibox
|
||||
{
|
||||
ontop = true,
|
||||
screen = screen,
|
||||
bg = '#00000000',
|
||||
type = 'dock',
|
||||
x = screen.geometry.x,
|
||||
y = screen.geometry.y,
|
||||
width = screen.geometry.width,
|
||||
height = screen.geometry.height
|
||||
}
|
||||
|
||||
panel:struts(
|
||||
{
|
||||
right = 0
|
||||
}
|
||||
)
|
||||
|
||||
openPanel = function()
|
||||
panel_visible = true
|
||||
backdrop.visible = true
|
||||
panel.visible = true
|
||||
panel:emit_signal('opened')
|
||||
end
|
||||
|
||||
closePanel = function()
|
||||
panel_visible = false
|
||||
panel.visible = false
|
||||
backdrop.visible = false
|
||||
-- Change to notif mode on close
|
||||
panel:emit_signal('closed')
|
||||
end
|
||||
|
||||
-- Hide this panel when app dashboard is called.
|
||||
function panel:HideDashboard()
|
||||
closePanel()
|
||||
end
|
||||
|
||||
-- You can use this function in your keybindings
|
||||
-- Just add this in your global keys:
|
||||
-- _G.screen.primary.right_panel:toggle()
|
||||
function panel:toggle()
|
||||
self.opened = not self.opened
|
||||
if self.opened then
|
||||
openPanel()
|
||||
else
|
||||
closePanel()
|
||||
end
|
||||
end
|
||||
|
||||
backdrop:buttons(
|
||||
awful.util.table.join(
|
||||
awful.button(
|
||||
{},
|
||||
1,
|
||||
function()
|
||||
panel:toggle()
|
||||
end
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
panel:setup {
|
||||
expand = 'none',
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
{
|
||||
require('notif-center.subwidgets.notification-center'),
|
||||
margins = dpi(15),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
}
|
||||
|
||||
return panel
|
||||
end
|
||||
|
||||
return right_panel
|
||||
|
||||
|
52
awesome/notif-center/subwidgets/clickable-container.lua
Normal file
52
awesome/notif-center/subwidgets/clickable-container.lua
Normal file
|
@ -0,0 +1,52 @@
|
|||
local wibox = require('wibox')
|
||||
|
||||
function build(widget)
|
||||
local container =
|
||||
wibox.widget {
|
||||
widget,
|
||||
widget = wibox.container.background
|
||||
}
|
||||
local old_cursor, old_wibox
|
||||
|
||||
container:connect_signal(
|
||||
'mouse::enter',
|
||||
function()
|
||||
container.bg = '#ffffff11'
|
||||
-- Hm, no idea how to get the wibox from this signal's arguments...
|
||||
local w = _G.mouse.current_wibox
|
||||
if w then
|
||||
old_cursor, old_wibox = w.cursor, w
|
||||
w.cursor = 'hand1'
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
container:connect_signal(
|
||||
'mouse::leave',
|
||||
function()
|
||||
container.bg = '#ffffff00'
|
||||
if old_wibox then
|
||||
old_wibox.cursor = old_cursor
|
||||
old_wibox = nil
|
||||
end
|
||||
end
|
||||
)
|
||||
|
||||
container:connect_signal(
|
||||
'button::press',
|
||||
function()
|
||||
container.bg = '#ffffff22'
|
||||
end
|
||||
)
|
||||
|
||||
container:connect_signal(
|
||||
'button::release',
|
||||
function()
|
||||
container.bg = '#ffffff11'
|
||||
end
|
||||
)
|
||||
|
||||
return container
|
||||
end
|
||||
|
||||
return build
|
|
@ -0,0 +1,51 @@
|
|||
local awful = require('awful')
|
||||
local naughty = require('naughty')
|
||||
local wibox = require('wibox')
|
||||
local gears = require('gears')
|
||||
local beautiful = require('beautiful')
|
||||
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local clickable_container = require('notif-center.subwidgets.clickable-container')
|
||||
|
||||
local HOME = os.getenv('HOME')
|
||||
local PATH_TO_ICONS = HOME .. '/.config/awesome/notif-center/icons/'
|
||||
|
||||
|
||||
-- Delete button imagebox
|
||||
local delete_imagebox = wibox.widget {
|
||||
{
|
||||
image = PATH_TO_ICONS .. 'delete' .. '.svg',
|
||||
resize = true,
|
||||
forced_height = dpi(20),
|
||||
forced_width = dpi(20),
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
|
||||
|
||||
local delete_button = clickable_container(wibox.container.margin(delete_imagebox, dpi(7), dpi(7), dpi(7), dpi(7)))
|
||||
delete_button:buttons(
|
||||
gears.table.join(
|
||||
awful.button(
|
||||
{},
|
||||
1,
|
||||
nil,
|
||||
function()
|
||||
_G.reset_notifbox_layout()
|
||||
end
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
local delete_button_wrapped = wibox.widget {
|
||||
{
|
||||
delete_button,
|
||||
bg = beautiful.bg_modal,
|
||||
shape = gears.shape.circle,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
|
||||
return delete_button_wrapped
|
|
@ -0,0 +1 @@
|
|||
true
|
|
@ -0,0 +1,104 @@
|
|||
local awful = require('awful')
|
||||
local naughty = require('naughty')
|
||||
local wibox = require('wibox')
|
||||
local gears = require('gears')
|
||||
local beautiful = require('beautiful')
|
||||
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
local clickable_container = require('notif-center.subwidgets.clickable-container')
|
||||
|
||||
local HOME = os.getenv('HOME')
|
||||
local PATH_TO_ICONS = HOME .. '/.config/awesome/notif-center/icons/'
|
||||
local PATH_TO_WIDGET = HOME .. '/.config/awesome/notif-center/subwidgets/notification-center/'
|
||||
|
||||
dont_disturb = false
|
||||
|
||||
-- Delete button imagebox
|
||||
local dont_disturb_imagebox = wibox.widget {
|
||||
{
|
||||
id = 'icon',
|
||||
image = PATH_TO_ICONS .. 'dont-disturb-mode' .. '.svg',
|
||||
resize = true,
|
||||
forced_height = dpi(20),
|
||||
forced_width = dpi(20),
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
|
||||
local function update_icon()
|
||||
local widgetIconName
|
||||
if dont_disturb then
|
||||
widgetIconName = 'toggled-on'
|
||||
dont_disturb_imagebox.icon:set_image(PATH_TO_ICONS .. 'dont-disturb-mode' .. '.svg')
|
||||
else
|
||||
widgetIconName = 'toggled-off'
|
||||
dont_disturb_imagebox.icon:set_image(PATH_TO_ICONS .. 'notify-mode' .. '.svg')
|
||||
end
|
||||
end
|
||||
|
||||
-- Function to check status after awesome.restart()
|
||||
local check_disturb_status = function()
|
||||
local cmd = "cat " .. PATH_TO_WIDGET .. "disturb_status"
|
||||
awful.spawn.easy_async_with_shell(cmd, function(stdout)
|
||||
local status = stdout
|
||||
if status:match("true") then
|
||||
dont_disturb = true
|
||||
update_icon()
|
||||
elseif status:match("false") then
|
||||
dont_disturb = false
|
||||
update_icon()
|
||||
else
|
||||
dont_disturb = false
|
||||
awful.spawn.easy_async_with_shell("echo " .. 'false' .. " > " .. PATH_TO_WIDGET .. "disturb_status", function(stdout) end, false)
|
||||
update_icon()
|
||||
end
|
||||
end, false)
|
||||
end
|
||||
|
||||
-- Check status on startup
|
||||
check_disturb_status()
|
||||
|
||||
-- Maintain Status even after awesome.restart() by writing on the PATH_TO_WIDGET/ .. disturb_status
|
||||
local toggle_disturb = function()
|
||||
if(dont_disturb == true) then
|
||||
-- Switch Off
|
||||
dont_disturb = false
|
||||
awful.spawn.easy_async_with_shell("echo " .. tostring(dont_disturb) .. " > " .. PATH_TO_WIDGET .. "disturb_status", function(stdout) end, false)
|
||||
update_icon()
|
||||
else
|
||||
-- Switch On
|
||||
dont_disturb = true
|
||||
awful.spawn.easy_async_with_shell("echo " .. tostring(dont_disturb) .. " > " .. PATH_TO_WIDGET .. "disturb_status", function(stdout) end, false)
|
||||
update_icon()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
local dont_disturb_button = clickable_container(wibox.container.margin(dont_disturb_imagebox, dpi(7), dpi(7), dpi(7), dpi(7)))
|
||||
dont_disturb_button:buttons(
|
||||
gears.table.join(
|
||||
awful.button(
|
||||
{},
|
||||
1,
|
||||
nil,
|
||||
function()
|
||||
-- toggle
|
||||
toggle_disturb()
|
||||
end
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
local dont_disturb_wrapped = wibox.widget {
|
||||
{
|
||||
dont_disturb_button,
|
||||
bg = beautiful.bg_modal,
|
||||
shape = gears.shape.circle,
|
||||
widget = wibox.container.background
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
|
||||
return dont_disturb_wrapped
|
|
@ -0,0 +1,344 @@
|
|||
local awful = require('awful')
|
||||
local naughty = require('naughty')
|
||||
local wibox = require('wibox')
|
||||
local gears = require('gears')
|
||||
local beautiful = require('beautiful')
|
||||
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
|
||||
local HOME = os.getenv('HOME')
|
||||
local PATH_TO_ICONS = HOME .. '/.config/awesome/notif-center/icons/'
|
||||
|
||||
-- Boolean variable to remove empty message
|
||||
local remove_notifbox_empty = true
|
||||
|
||||
-- Notification boxes container layout
|
||||
local notifbox_layout = wibox.layout.fixed.vertical()
|
||||
|
||||
-- Notification boxes container layout spacing
|
||||
notifbox_layout.spacing = dpi(5)
|
||||
|
||||
notifbox_layout.expand = 'none'
|
||||
|
||||
-- Notification icon container
|
||||
local notifbox_icon = function(ico_image)
|
||||
local noti_icon = wibox.widget {
|
||||
{
|
||||
id = 'icon',
|
||||
resize = true,
|
||||
forced_height = dpi(25),
|
||||
forced_width = dpi(25),
|
||||
widget = wibox.widget.imagebox
|
||||
},
|
||||
layout = wibox.layout.fixed.horizontal
|
||||
}
|
||||
noti_icon.icon:set_image(ico_image)
|
||||
return noti_icon
|
||||
end
|
||||
|
||||
-- Notification title container
|
||||
local notifbox_title = function(title)
|
||||
return wibox.widget {
|
||||
text = title,
|
||||
font = 'SFNS Display Bold 12',
|
||||
align = 'left',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox
|
||||
}
|
||||
end
|
||||
|
||||
-- Notification message container
|
||||
local notifbox_message = function(msg)
|
||||
return wibox.widget {
|
||||
text = msg,
|
||||
font = 'SFNS Display Regular 11',
|
||||
align = 'left',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox
|
||||
}
|
||||
end
|
||||
|
||||
-- Notification app name container
|
||||
local notifbox_appname = function(app)
|
||||
return wibox.widget {
|
||||
text = app,
|
||||
font = 'SFNS Display Bold 12',
|
||||
align = 'left',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox
|
||||
}
|
||||
end
|
||||
|
||||
-- Get current time
|
||||
local current_time = function()
|
||||
return os.date("%H:%M:%S")
|
||||
end
|
||||
|
||||
-- Convert time to seconds
|
||||
local parse_to_seconds = function(time)
|
||||
-- Convert HH in HH:MM:SS
|
||||
hourInSec = tonumber(string.sub(time, 1, 2)) * 3600
|
||||
|
||||
-- Convert MM in HH:MM:SS
|
||||
minInSec = tonumber(string.sub(time, 4, 5)) * 60
|
||||
|
||||
-- Get SS in HH:MM:SS
|
||||
getSec = tonumber(string.sub(time, 7, 8))
|
||||
|
||||
return (hourInSec + minInSec + getSec)
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- Notification actions container
|
||||
local notifbox_actions = function(notif)
|
||||
actions_template = wibox.widget {
|
||||
notification = notif,
|
||||
base_layout = wibox.widget {
|
||||
spacing = dpi(5),
|
||||
layout = wibox.layout.flex.vertical
|
||||
},
|
||||
widget_template = {
|
||||
{
|
||||
{
|
||||
{
|
||||
id = 'text_role',
|
||||
font = 'SFNS Display Regular 10',
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
widget = wibox.container.place
|
||||
},
|
||||
bg = beautiful.bg_actions,
|
||||
shape = gears.shape.rounded_rect,
|
||||
forced_height = 30,
|
||||
widget = wibox.container.background,
|
||||
},
|
||||
margins = 4,
|
||||
widget = wibox.container.margin,
|
||||
},
|
||||
style = { underline_normal = false, underline_selected = true },
|
||||
widget = naughty.list.actions,
|
||||
}
|
||||
|
||||
return actions_template
|
||||
end
|
||||
|
||||
-- Empty notification message
|
||||
local notifbox_empty = function()
|
||||
local empty_notifbox = wibox.widget {
|
||||
{
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
spacing = dpi(5),
|
||||
{
|
||||
expand = 'none',
|
||||
layout = wibox.layout.align.horizontal,
|
||||
nil,
|
||||
{
|
||||
image = PATH_TO_ICONS .. 'empty-notification' .. '.svg',
|
||||
resize = true,
|
||||
forced_height = dpi(35),
|
||||
forced_width = dpi(35),
|
||||
widget = wibox.widget.imagebox,
|
||||
},
|
||||
nil
|
||||
},
|
||||
{
|
||||
text = 'Wow, such empty.',
|
||||
font = 'SFNS Display Bold 14',
|
||||
align = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
{
|
||||
text = 'Come back later.',
|
||||
font = 'SFNS Display Regular 10',
|
||||
align = 'center',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox
|
||||
},
|
||||
},
|
||||
margins = dpi(20),
|
||||
widget = wibox.container.margin
|
||||
|
||||
}
|
||||
|
||||
|
||||
local separator_for_empty_msg = wibox.widget
|
||||
{
|
||||
orientation = 'vertical',
|
||||
opacity = 0.0,
|
||||
widget = wibox.widget.separator
|
||||
}
|
||||
|
||||
-- Make empty_notifbox center
|
||||
local centered_empty_notifbox = wibox.widget {
|
||||
expand = 'none',
|
||||
layout = wibox.layout.align.vertical,
|
||||
separator_for_empty_msg,
|
||||
empty_notifbox,
|
||||
separator_for_empty_msg
|
||||
}
|
||||
|
||||
return centered_empty_notifbox
|
||||
end
|
||||
|
||||
-- Reset notifbox_layout
|
||||
reset_notifbox_layout = function()
|
||||
notifbox_layout:reset(notifbox_layout)
|
||||
notifbox_layout:insert(1, notifbox_empty())
|
||||
remove_notifbox_empty = true
|
||||
end
|
||||
|
||||
-- Returns the notification box
|
||||
local notifbox_box = function(notif, icon, title, message, app, bgcolor)
|
||||
|
||||
-- Get current time for `this` instance of box
|
||||
local time_of_pop = current_time()
|
||||
|
||||
-- Notification time pop container
|
||||
local notifbox_timepop = wibox.widget {
|
||||
id = 'time_pop',
|
||||
text = nil,
|
||||
font = 'SFNS Display Regular 10',
|
||||
align = 'left',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox
|
||||
}
|
||||
|
||||
-- Timer for notification time pop
|
||||
gears.timer {
|
||||
timeout = 60,
|
||||
call_now = true,
|
||||
autostart = true,
|
||||
callback = function()
|
||||
|
||||
local time_difference = nil
|
||||
-- Get the time difference
|
||||
time_difference = parse_to_seconds(current_time()) - parse_to_seconds(time_of_pop)
|
||||
-- String to Number
|
||||
time_difference = tonumber(time_difference)
|
||||
|
||||
-- If seconds is less than one minute
|
||||
if time_difference < 60 then
|
||||
notifbox_timepop.text = 'now'
|
||||
|
||||
-- If greater that one hour
|
||||
elseif time_difference >= 3600 then
|
||||
notifbox_timepop.text = time_of_pop
|
||||
|
||||
-- Use time of popup instead
|
||||
else
|
||||
local time_in_minutes = math.floor(time_difference / 60)
|
||||
if tonumber(time_in_minutes) > 1 then
|
||||
notifbox_timepop.text = time_in_minutes .. ' ' .. 'minutes ago'
|
||||
else
|
||||
notifbox_timepop.text = time_in_minutes .. ' ' .. 'minute ago'
|
||||
end
|
||||
end
|
||||
|
||||
collectgarbage('collect')
|
||||
end
|
||||
}
|
||||
|
||||
-- Template of notification box
|
||||
local notifbox_template = wibox.widget {
|
||||
id = 'notifbox_template',
|
||||
expand = 'none',
|
||||
{
|
||||
{
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
spacing = dpi(5),
|
||||
{
|
||||
expand = 'none',
|
||||
layout = wibox.layout.align.horizontal,
|
||||
{
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
spacing = dpi(5),
|
||||
notifbox_icon(icon),
|
||||
notifbox_appname(app),
|
||||
},
|
||||
nil,
|
||||
notifbox_timepop
|
||||
},
|
||||
{
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
spacing = dpi(5),
|
||||
{
|
||||
notifbox_title(title),
|
||||
notifbox_message(message),
|
||||
layout = wibox.layout.fixed.vertical
|
||||
},
|
||||
notifbox_actions(notif),
|
||||
},
|
||||
|
||||
},
|
||||
margins = dpi(10),
|
||||
widget = wibox.container.margin
|
||||
},
|
||||
bg = bgcolor,
|
||||
shape = function(cr, width, height)
|
||||
gears.shape.partially_rounded_rect(cr, width, height, true, true, true, true, beautiful.modal_radius) end,
|
||||
widget = wibox.container.background,
|
||||
}
|
||||
|
||||
-- Delete notification box
|
||||
local notifbox_delete = function()
|
||||
notifbox_layout:remove_widgets(notifbox_template, true)
|
||||
end
|
||||
|
||||
-- Delete notification box when pressed
|
||||
notifbox_template:connect_signal("button::press", function(_, _, _, button)
|
||||
if #notifbox_layout.children == 1 then
|
||||
reset_notifbox_layout()
|
||||
else
|
||||
notifbox_delete()
|
||||
end
|
||||
end)
|
||||
|
||||
return notifbox_template
|
||||
end
|
||||
|
||||
|
||||
-- Add empty notification message on start-up
|
||||
notifbox_layout:insert(1, notifbox_empty())
|
||||
|
||||
-- Connect to naughty
|
||||
naughty.connect_signal("request::display", function(n)
|
||||
|
||||
-- If notifbox_layout has a child and remove_notifbox_empty
|
||||
if #notifbox_layout.children == 1 and remove_notifbox_empty then
|
||||
-- Reset layout
|
||||
notifbox_layout:reset(notifbox_layout)
|
||||
remove_notifbox_empty = false
|
||||
end
|
||||
|
||||
|
||||
-- Set background color based on urgency level
|
||||
local notifbox_color = beautiful.bg_modal
|
||||
if n.urgency == 'critical' then
|
||||
notifbox_color = n.bg .. '66'
|
||||
end
|
||||
|
||||
-- Check if there's an icon
|
||||
local appicon = n.icon
|
||||
if not appicon then
|
||||
appicon = PATH_TO_ICONS .. 'new-notif' .. '.svg'
|
||||
end
|
||||
|
||||
-- Throw data from naughty to notifbox_layout
|
||||
-- Generates notifbox
|
||||
notifbox_layout:insert(1,
|
||||
notifbox_box(
|
||||
n,
|
||||
appicon,
|
||||
n.title,
|
||||
n.message,
|
||||
n.app_name,
|
||||
notifbox_color)
|
||||
)
|
||||
|
||||
|
||||
end)
|
||||
|
||||
|
||||
return notifbox_layout
|
47
awesome/notif-center/subwidgets/notification-center/init.lua
Normal file
47
awesome/notif-center/subwidgets/notification-center/init.lua
Normal file
|
@ -0,0 +1,47 @@
|
|||
local awful = require('awful')
|
||||
local wibox = require('wibox')
|
||||
local gears = require('gears')
|
||||
local beautiful = require('beautiful')
|
||||
|
||||
local HOME = os.getenv('HOME')
|
||||
|
||||
local dpi = require('beautiful').xresources.apply_dpi
|
||||
|
||||
|
||||
local notif_header = wibox.widget {
|
||||
text = 'Notification Center',
|
||||
font = 'SFNS Display Bold 14',
|
||||
align = 'left',
|
||||
valign = 'center',
|
||||
widget = wibox.widget.textbox
|
||||
}
|
||||
|
||||
|
||||
|
||||
local separator = wibox.widget {
|
||||
orientation = 'horizontal',
|
||||
opacity = 0.0,
|
||||
forced_height = 5,
|
||||
widget = wibox.widget.separator,
|
||||
}
|
||||
|
||||
|
||||
return wibox.widget {
|
||||
expand = 'none',
|
||||
layout = wibox.layout.fixed.vertical,
|
||||
spacing = dpi(5),
|
||||
{
|
||||
expand = 'none',
|
||||
layout = wibox.layout.align.horizontal,
|
||||
notif_header,
|
||||
nil,
|
||||
{
|
||||
layout = wibox.layout.fixed.horizontal,
|
||||
spacing = dpi(5),
|
||||
require('notif-center.subwidgets.notification-center.dont-disturb'),
|
||||
require('notif-center.subwidgets.notification-center.clear-all')
|
||||
},
|
||||
},
|
||||
separator,
|
||||
require('notif-center.subwidgets.notification-center.generate-notifbox')
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue