Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Notification widget #186

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion net-speed-widget/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Net Speed Widget

The widget and readme is in progress
The widget and readme is in progress
15 changes: 15 additions & 0 deletions notification-widgets/version1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Important #
This works only for the `awesome-git` Version otherwise an error would appear!

# Screenshot #
![Couldn't load image :(](Screenshot.png)

# Requirements #
- Font: *Liberation*

# How to use it #
Just add this line to your `rc.lua`:
```lua
require("awesome-wm-widgets.notification-widgets.version1.notify")
```
and it should work than out of the box.
Binary file added notification-widgets/version1/Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
128 changes: 128 additions & 0 deletions notification-widgets/version1/notify.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
----------------------------
-- Notification widget
--
-- IMPORTANT: IT ONLY WORKS WITH THE AWESOME-GIT VERSION!!!
-- @author TornaxO7
-- @copyright TornaxO7
----------------------------

------ Awesome Library -----
local beautiful = require("beautiful")
local awful = require("awful")
local naughty = require("naughty")
local gears = require("gears")
local wibox = require("wibox")
local xresources = require("beautiful.xresources")
local dpi = xresources.apply_dpi
----------------------------

beautiful.notification_bg = beautiful.bg_normal
beautiful.notification_fg = "#5B8234"
beautiful.notification_border_color = "#93a1a1"

naughty.notification.font = "Liberation Sans Bold 13"
naughty.notification.screen = 1
naughty.notification.border_width = dpi(5)
naughty.notification.width = dpi(500)
naughty.notification.timeout = 3

naughty.notification.icon_size = dpi(150)
local icon_size = dpi(150)

----- Widget Templates -----
local default_template = {
{
{
{ ----- Icon -----
forced_width = icon_size,
forced_height = icon_size,

widget = naughty.widget.icon
},
{
{
{ ---- Title -----
naughty.widget.title,

valign = "center",
halign = "center",

widget = wibox.container.place
},

{ ----- Body/Message -----
naughty.widget.message,

valign = "top",
align = "center",

widget = wibox.container.place
},

layout = wibox.layout.align.vertical,
expand = "outside",
},

margins = dpi(10),
widget = wibox.container.margin,
},
layout = wibox.layout.align.horizontal,
},

margins = dpi(10),
widget = wibox.container.margin
},
----- To let the text wrap ------
strategy = "max",
widget = wibox.container.constraint,
}

local template_without_icon = {
{

{
{ ----- Title -----
naughty.widget.title,

valign = "center",
halign = "center",

widget = wibox.container.place
},
{ ----- Body/Message -----
naughty.widget.message,

valign = "top",
align = "center",

widget = wibox.container.place
},
layout = wibox.layout.fixed.vertical,
},
----- The space between border and text -----
margins = dpi(10),
widget = wibox.container.margin
},

----- To let the text wrap ------
strategy = "max",
widget = wibox.container.constraint,
}

naughty.connect_signal("request::display", function(notification)

-- Set the markup of the title
notification.title = '<span underline="low">' .. notification.title .. '</span>'

notification.timeout = 3
notification.resident = false

-- Only if there's an icon: Add the icon-widget
naughty.layout.box {
notification = notification,
border_width = dpi(5),
screen = 1,
widget_template = notification.icon and default_template or
template_without_icon,
}
end)