@ -0,0 +1,447 @@ |
|||||||
|
|
||||||
|
-- Functions that you use more than once and in different files would |
||||||
|
-- be nice to define here. |
||||||
|
|
||||||
|
local awful = require("awful") |
||||||
|
local gears = require("gears") |
||||||
|
local beautiful = require("beautiful") |
||||||
|
local xresources = require("beautiful.xresources") |
||||||
|
local dpi = xresources.apply_dpi |
||||||
|
local wibox = require("wibox") |
||||||
|
local icons = require("icons") |
||||||
|
local notifications = require("notifications") |
||||||
|
local naughty = require("naughty") |
||||||
|
|
||||||
|
local helpers = {} |
||||||
|
|
||||||
|
-- Create rounded rectangle shape (in one line) |
||||||
|
helpers.rrect = function(radius) |
||||||
|
return function(cr, width, height) |
||||||
|
gears.shape.rounded_rect(cr, width, height, radius) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
helpers.prrect = function(radius, tl, tr, br, bl) |
||||||
|
return function(cr, width, height) |
||||||
|
gears.shape.partially_rounded_rect(cr, width, height, tl, tr, br, bl, radius) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
helpers.squircle = function(rate, delta) |
||||||
|
return function(cr, width, height) |
||||||
|
gears.shape.squircle(cr, width, height, rate, delta) |
||||||
|
end |
||||||
|
end |
||||||
|
helpers.psquircle = function(rate, delta, tl, tr, br, bl) |
||||||
|
return function(cr, width, height) |
||||||
|
gears.shape.partial_squircle(cr, width, height, tl, tr, br, bl, rate, delta) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
helpers.colorize_text = function(text, color) |
||||||
|
return "<span foreground='"..color.."'>"..text.."</span>" |
||||||
|
end |
||||||
|
|
||||||
|
function helpers.client_menu_toggle() |
||||||
|
local instance = nil |
||||||
|
|
||||||
|
return function () |
||||||
|
if instance and instance.wibox.visible then |
||||||
|
instance:hide() |
||||||
|
instance = nil |
||||||
|
else |
||||||
|
instance = awful.menu.clients({ theme = { width = dpi(250) } }) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
-- Escapes a string so that it can be displayed inside pango markup |
||||||
|
-- tags. Modified from: |
||||||
|
-- https://github.com/kernelsauce/turbo/blob/master/turbo/escape.lua |
||||||
|
function helpers.pango_escape(s) |
||||||
|
return (string.gsub(s, "[&<>]", { |
||||||
|
["&"] = "&", |
||||||
|
["<"] = "<", |
||||||
|
[">"] = ">" |
||||||
|
})) |
||||||
|
end |
||||||
|
|
||||||
|
function helpers.vertical_pad(height) |
||||||
|
return wibox.widget{ |
||||||
|
forced_height = height, |
||||||
|
layout = wibox.layout.fixed.vertical |
||||||
|
} |
||||||
|
end |
||||||
|
|
||||||
|
function helpers.horizontal_pad(width) |
||||||
|
return wibox.widget{ |
||||||
|
forced_width = width, |
||||||
|
layout = wibox.layout.fixed.horizontal |
||||||
|
} |
||||||
|
end |
||||||
|
|
||||||
|
local direction_translate = { |
||||||
|
['up'] = 'top', |
||||||
|
['down'] = 'bottom', |
||||||
|
['left'] = 'left', |
||||||
|
['right'] = 'right' |
||||||
|
} |
||||||
|
function helpers.move_to_edge(c, direction) |
||||||
|
local old = c:geometry() |
||||||
|
local new = awful.placement[direction_translate[direction]](c, {honor_padding = true, honor_workarea = true, margins = beautiful.useless_gap * 2, pretend = true}) |
||||||
|
if direction == "up" or direction == "down" then |
||||||
|
c:geometry({ x = old.x, y = new.y }) |
||||||
|
else |
||||||
|
c:geometry({ x = new.x, y = old.y }) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
local double_tap_timer = nil |
||||||
|
function helpers.single_double_tap(single_tap_function, double_tap_function) |
||||||
|
if double_tap_timer then |
||||||
|
double_tap_timer:stop() |
||||||
|
double_tap_timer = nil |
||||||
|
double_tap_function() |
||||||
|
-- naughty.notify({text = "We got a double tap"}) |
||||||
|
return |
||||||
|
end |
||||||
|
|
||||||
|
double_tap_timer = |
||||||
|
gears.timer.start_new(0.20, function() |
||||||
|
double_tap_timer = nil |
||||||
|
-- naughty.notify({text = "We got a single tap"}) |
||||||
|
if single_tap_function then |
||||||
|
single_tap_function() |
||||||
|
end |
||||||
|
return false |
||||||
|
end) |
||||||
|
end |
||||||
|
|
||||||
|
|
||||||
|
-- Used as a custom command in rofi to move a window into the current tag |
||||||
|
-- instead of following it. |
||||||
|
-- Rofi has access to the X window id of the client. |
||||||
|
function helpers.rofi_move_client_here(window) |
||||||
|
local win = function (c) |
||||||
|
return awful.rules.match(c, {window = window}) |
||||||
|
end |
||||||
|
|
||||||
|
for c in awful.client.iterate(win) do |
||||||
|
c.minimized = false |
||||||
|
c:move_to_tag(mouse.screen.selected_tag) |
||||||
|
client.focus = c |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
-- Add a hover cursor to a widget by changing the cursor on |
||||||
|
-- mouse::enter and mouse::leave |
||||||
|
-- You can find the names of the available cursors by opening any |
||||||
|
-- cursor theme and looking in the "cursors folder" |
||||||
|
-- For example: "hand1" is the cursor that appears when hovering over |
||||||
|
-- links |
||||||
|
function helpers.add_hover_cursor(w, hover_cursor) |
||||||
|
local original_cursor = "left_ptr" |
||||||
|
|
||||||
|
w:connect_signal("mouse::enter", function () |
||||||
|
local w = _G.mouse.current_wibox |
||||||
|
if w then |
||||||
|
w.cursor = hover_cursor |
||||||
|
end |
||||||
|
end) |
||||||
|
|
||||||
|
w:connect_signal("mouse::leave", function () |
||||||
|
local w = _G.mouse.current_wibox |
||||||
|
if w then |
||||||
|
w.cursor = original_cursor |
||||||
|
end |
||||||
|
end) |
||||||
|
end |
||||||
|
|
||||||
|
-- Tag back and forth: |
||||||
|
-- If you try to focus the tag you are already at, go back to the previous tag. |
||||||
|
-- Useful for quick switching after for example checking an incoming chat |
||||||
|
-- message at tag 2 and coming back to your work at tag 1 with the same |
||||||
|
-- keypress. |
||||||
|
function helpers.tag_back_and_forth(tag_index) |
||||||
|
local s = mouse.screen |
||||||
|
local tag = s.tags[tag_index] |
||||||
|
if tag then |
||||||
|
if tag == s.selected_tag then |
||||||
|
awful.tag.history.restore() |
||||||
|
else |
||||||
|
tag:view_only() |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
-- Resize DWIM (Do What I Mean) |
||||||
|
-- Resize client or factor |
||||||
|
-- Constants -- |
||||||
|
local floating_resize_amount = dpi(20) |
||||||
|
local tiling_resize_factor= 0.05 |
||||||
|
--------------- |
||||||
|
function helpers.resize_dwim(c, direction) |
||||||
|
if c and c.floating then |
||||||
|
if direction == "up" then |
||||||
|
c:relative_move( 0, 0, 0, -floating_resize_amount) |
||||||
|
elseif direction == "down" then |
||||||
|
c:relative_move( 0, 0, 0, floating_resize_amount) |
||||||
|
elseif direction == "left" then |
||||||
|
c:relative_move( 0, 0, -floating_resize_amount, 0) |
||||||
|
elseif direction == "right" then |
||||||
|
c:relative_move( 0, 0, floating_resize_amount, 0) |
||||||
|
end |
||||||
|
elseif awful.layout.get(mouse.screen) ~= awful.layout.suit.floating then |
||||||
|
if direction == "up" then |
||||||
|
awful.client.incwfact(-tiling_resize_factor) |
||||||
|
elseif direction == "down" then |
||||||
|
awful.client.incwfact( tiling_resize_factor) |
||||||
|
elseif direction == "left" then |
||||||
|
awful.tag.incmwfact(-tiling_resize_factor) |
||||||
|
elseif direction == "right" then |
||||||
|
awful.tag.incmwfact( tiling_resize_factor) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
-- Move client DWIM (Do What I Mean) |
||||||
|
-- Move to edge if the client / layout is floating |
||||||
|
-- Swap by index if maximized |
||||||
|
-- Else swap client by direction |
||||||
|
function helpers.move_client_dwim(c, direction) |
||||||
|
if c.floating or (awful.layout.get(mouse.screen) == awful.layout.suit.floating) then |
||||||
|
helpers.move_to_edge(c, direction) |
||||||
|
elseif awful.layout.get(mouse.screen) == awful.layout.suit.max then |
||||||
|
if direction == "up" or direction == "left" then |
||||||
|
awful.client.swap.byidx(-1, c) |
||||||
|
elseif direction == "down" or direction == "right" then |
||||||
|
awful.client.swap.byidx(1, c) |
||||||
|
end |
||||||
|
else |
||||||
|
awful.client.swap.bydirection(direction, c, nil) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
-- Make client floating and snap to the desired edge |
||||||
|
local axis_translate = { |
||||||
|
['up'] = 'horizontally', |
||||||
|
['down'] = 'horizontally', |
||||||
|
['left'] = 'vertically', |
||||||
|
['right'] = 'vertically' |
||||||
|
} |
||||||
|
function helpers.float_and_edge_snap(c, direction) |
||||||
|
c.maximized = false |
||||||
|
c.maximized_vertical = false |
||||||
|
c.maximized_horizontal = false |
||||||
|
c.floating = true |
||||||
|
local f = awful.placement.scale |
||||||
|
+ awful.placement[direction_translate[direction]] |
||||||
|
+ awful.placement['maximize_'..axis_translate[direction]] |
||||||
|
f(c, {honor_padding = true, honor_workarea=true, to_percent = 0.5, margins = beautiful.useless_gap * 2 }) |
||||||
|
end |
||||||
|
|
||||||
|
-- Rounds a number to any number of decimals |
||||||
|
function helpers.round(number, decimals) |
||||||
|
local power = 10 ^ decimals |
||||||
|
return math.floor(number * power) / power |
||||||
|
end |
||||||
|
|
||||||
|
function helpers.volume_control(step) |
||||||
|
local cmd |
||||||
|
if step == 0 then |
||||||
|
cmd = "pactl set-sink-mute @DEFAULT_SINK@ toggle" |
||||||
|
else |
||||||
|
sign = step > 0 and "+" or "" |
||||||
|
cmd = "pactl set-sink-mute @DEFAULT_SINK@ 0 && pactl set-sink-volume @DEFAULT_SINK@ "..sign..tostring(step).."%" |
||||||
|
end |
||||||
|
awful.spawn.with_shell(cmd) |
||||||
|
end |
||||||
|
|
||||||
|
function helpers.send_key(c, key) |
||||||
|
awful.spawn.with_shell("xdotool key --window "..tostring(c.window).." "..key) |
||||||
|
end |
||||||
|
|
||||||
|
function helpers.send_key_sequence(c, seq) |
||||||
|
awful.spawn.with_shell("xdotool type --delay 5 --window "..tostring(c.window).." "..seq) |
||||||
|
end |
||||||
|
|
||||||
|
function helpers.fake_escape() |
||||||
|
root.fake_input('key_press', "Escape") |
||||||
|
root.fake_input('key_release', "Escape") |
||||||
|
end |
||||||
|
|
||||||
|
local prompt_font = beautiful.prompt_font or "sans bold 8" |
||||||
|
function helpers.prompt(action, textbox, prompt, callback) |
||||||
|
if action == "run" then |
||||||
|
awful.prompt.run { |
||||||
|
prompt = prompt, |
||||||
|
-- prompt = "<b>Run: </b>", |
||||||
|
textbox = textbox, |
||||||
|
font = prompt_font, |
||||||
|
done_callback = callback, |
||||||
|
exe_callback = awful.spawn, |
||||||
|
completion_callback = awful.completion.shell, |
||||||
|
history_path = awful.util.get_cache_dir() .. "/history" |
||||||
|
} |
||||||
|
elseif action == "web_search" then |
||||||
|
awful.prompt.run { |
||||||
|
prompt = prompt, |
||||||
|
-- prompt = '<b>Web search: </b>', |
||||||
|
textbox = textbox, |
||||||
|
font = prompt_font, |
||||||
|
history_path = awful.util.get_cache_dir() .. "/history_web", |
||||||
|
done_callback = callback, |
||||||
|
exe_callback = function(input) |
||||||
|
if not input or #input == 0 then return end |
||||||
|
awful.spawn.with_shell("noglob "..user.web_search_cmd.."'"..input.."'") |
||||||
|
naughty.notify { title = "Searching the web for", text = input, icon = icons.image.firefox, urgency = "low" } |
||||||
|
end |
||||||
|
} |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
-- Given a `match` condition, returns an array with clients that match it, or |
||||||
|
-- just the first found client if `first_only` is true |
||||||
|
function helpers.find_clients(match, first_only) |
||||||
|
local matcher = function (c) |
||||||
|
return awful.rules.match(c, match) |
||||||
|
end |
||||||
|
|
||||||
|
if first_only then |
||||||
|
for c in awful.client.iterate(matcher) do |
||||||
|
return c |
||||||
|
end |
||||||
|
else |
||||||
|
local clients = {} |
||||||
|
for c in awful.client.iterate(matcher) do |
||||||
|
table.insert(clients, c) |
||||||
|
end |
||||||
|
return clients |
||||||
|
end |
||||||
|
return nil |
||||||
|
end |
||||||
|
|
||||||
|
-- Given a `match` condition, calls the specified function `f_do` on all the |
||||||
|
-- clients that match it |
||||||
|
function helpers.find_clients_and_do(match, f_do) |
||||||
|
local matcher = function (c) |
||||||
|
return awful.rules.match(c, match) |
||||||
|
end |
||||||
|
|
||||||
|
for c in awful.client.iterate(matcher) do |
||||||
|
f_do(c) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
function helpers.run_or_raise(match, move, spawn_cmd, spawn_args) |
||||||
|
local matcher = function (c) |
||||||
|
return awful.rules.match(c, match) |
||||||
|
end |
||||||
|
|
||||||
|
-- Find and raise |
||||||
|
local found = false |
||||||
|
for c in awful.client.iterate(matcher) do |
||||||
|
found = true |
||||||
|
c.minimized = false |
||||||
|
if move then |
||||||
|
c:move_to_tag(mouse.screen.selected_tag) |
||||||
|
client.focus = c |
||||||
|
else |
||||||
|
c:jump_to() |
||||||
|
end |
||||||
|
break |
||||||
|
end |
||||||
|
|
||||||
|
-- Spawn if not found |
||||||
|
if not found then |
||||||
|
awful.spawn(spawn_cmd, spawn_args) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
-- Run raise or minimize a client (scratchpad style) |
||||||
|
-- Depends on helpers.run_or_raise |
||||||
|
-- If it not running, spawn it |
||||||
|
-- If it is running, focus it |
||||||
|
-- If it is focused, minimize it |
||||||
|
function helpers.scratchpad(match, spawn_cmd, spawn_args) |
||||||
|
local cf = client.focus |
||||||
|
if cf and awful.rules.match(cf, match) then |
||||||
|
cf.minimized = true |
||||||
|
else |
||||||
|
helpers.run_or_raise(match, true, spawn_cmd, spawn_args) |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
function helpers.float_and_resize(c, width, height) |
||||||
|
c.maximized = false |
||||||
|
c.width = width |
||||||
|
c.height = height |
||||||
|
awful.placement.centered(c,{honor_workarea=true, honor_padding = true}) |
||||||
|
awful.client.property.set(c, 'floating_geometry', c:geometry()) |
||||||
|
c.floating = true |
||||||
|
c:raise() |
||||||
|
end |
||||||
|
|
||||||
|
-- Adds a maximized mask to a screen |
||||||
|
function helpers.screen_mask(s, bg) |
||||||
|
local mask = wibox({visible = false, ontop = true, type = "splash", screen = s}) |
||||||
|
awful.placement.maximize(mask) |
||||||
|
mask.bg = bg |
||||||
|
return mask |
||||||
|
end |
||||||
|
|
||||||
|
-- Useful for periodically checking the output of a command that |
||||||
|
-- requires internet access. |
||||||
|
-- Ensures that `command` will be run EXACTLY once during the desired |
||||||
|
-- `interval`, even if awesome restarts multiple times during this time. |
||||||
|
-- Saves output in `output_file` and checks its last modification |
||||||
|
-- time to determine whether to run the command again or not. |
||||||
|
-- Passes the output of `command` to `callback` function. |
||||||
|
function helpers.remote_watch(command, interval, output_file, callback) |
||||||
|
local run_the_thing = function() |
||||||
|
-- Pass output to callback AND write it to file |
||||||
|
awful.spawn.easy_async_with_shell(command.." | tee "..output_file, function(out) callback(out) end) |
||||||
|
end |
||||||
|
|
||||||
|
local timer |
||||||
|
timer = gears.timer { |
||||||
|
timeout = interval, |
||||||
|
call_now = true, |
||||||
|
autostart = true, |
||||||
|
single_shot = false, |
||||||
|
callback = function() |
||||||
|
awful.spawn.easy_async_with_shell("date -r "..output_file.." +%s", function(last_update, _, __, exitcode) |
||||||
|
-- Probably the file does not exist yet (first time |
||||||
|
-- running after reboot) |
||||||
|
if exitcode == 1 then |
||||||
|
run_the_thing() |
||||||
|
return |
||||||
|
end |
||||||
|
|
||||||
|
local diff = os.time() - tonumber(last_update) |
||||||
|
if diff >= interval then |
||||||
|
run_the_thing() |
||||||
|
else |
||||||
|
-- Pass the date saved in the file since it is fresh enough |
||||||
|
awful.spawn.easy_async_with_shell("cat "..output_file, function(out) callback(out) end) |
||||||
|
|
||||||
|
-- Schedule an update for when the remaining time to complete the interval passes |
||||||
|
timer:stop() |
||||||
|
gears.timer.start_new(interval - diff, function() |
||||||
|
run_the_thing() |
||||||
|
timer:again() |
||||||
|
end) |
||||||
|
end |
||||||
|
end) |
||||||
|
end |
||||||
|
} |
||||||
|
end |
||||||
|
|
||||||
|
-- The directory of the currently executed lua script |
||||||
|
-- Requires the `debug` library to be available in the build of Lua that is running |
||||||
|
function helpers.this_dir() |
||||||
|
local str = debug.getinfo(2, "S").source:sub(2) |
||||||
|
return str:match("(.*/)") |
||||||
|
end |
||||||
|
|
||||||
|
return helpers |
||||||
@ -0,0 +1,102 @@ |
|||||||
|
local awful = require('awful') |
||||||
|
local wibox = require('wibox') |
||||||
|
local gears = require('gears') |
||||||
|
local beautiful = require('beautiful') |
||||||
|
local naughty = require('naughty') |
||||||
|
local dpi = beautiful.xresources.apply_dpi |
||||||
|
|
||||||
|
screen.connect_signal("request::desktop_decoration", function(s) |
||||||
|
|
||||||
|
local panel_width = dpi(300) |
||||||
|
local notify_center = wibox({ |
||||||
|
ontop = true, |
||||||
|
stretch = false, |
||||||
|
width = panel_width, |
||||||
|
height = s.workarea.height, |
||||||
|
visible = false, |
||||||
|
y = beautiful.panel_height, |
||||||
|
x = s.workarea.width - panel_width |
||||||
|
}) |
||||||
|
|
||||||
|
notify_center:setup { |
||||||
|
-- Add a button to dismiss all notifications, because why not. |
||||||
|
{ |
||||||
|
{ |
||||||
|
text = 'Dismiss all', |
||||||
|
align = 'center', |
||||||
|
valign = 'center', |
||||||
|
widget = wibox.widget.textbox |
||||||
|
}, |
||||||
|
buttons = gears.table.join( |
||||||
|
awful.button({ }, 1, function() naughty.destroy_all_notifications() end) |
||||||
|
), |
||||||
|
forced_width = 75, |
||||||
|
shape = gears.shape.rounded_bar, |
||||||
|
shape_border_width = 1, |
||||||
|
shape_border_color = beautiful.bg_highlight, |
||||||
|
widget = wibox.container.background |
||||||
|
}, |
||||||
|
{ |
||||||
|
base_layout = wibox.widget { |
||||||
|
spacing_widget = wibox.widget { |
||||||
|
orientation = 'vertical', |
||||||
|
span_ratio = 0.5, |
||||||
|
widget = wibox.widget.separator, |
||||||
|
}, |
||||||
|
forced_height = 30, |
||||||
|
spacing = 3, |
||||||
|
layout = wibox.layout.fixed.vertical |
||||||
|
}, |
||||||
|
widget_template = { |
||||||
|
{ |
||||||
|
naughty.widget.icon, |
||||||
|
{ |
||||||
|
naughty.widget.title, |
||||||
|
naughty.widget.message, |
||||||
|
{ |
||||||
|
layout = wibox.widget { |
||||||
|
-- Adding the wibox.widget allows to share a |
||||||
|
-- single instance for all spacers. |
||||||
|
spacing_widget = wibox.widget { |
||||||
|
orientation = 'horizontal', |
||||||
|
span_ratio = 0.9, |
||||||
|
widget = wibox.widget.separator, |
||||||
|
}, |
||||||
|
spacing = 3, |
||||||
|
layout = wibox.layout.flex.horizontal |
||||||
|
}, |
||||||
|
widget = naughty.list.widgets, |
||||||
|
}, |
||||||
|
layout = wibox.layout.align.vertical |
||||||
|
}, |
||||||
|
spacing = 10, |
||||||
|
fill_space = true, |
||||||
|
layout = wibox.layout.fixed.horizontal |
||||||
|
}, |
||||||
|
margins = 5, |
||||||
|
widget = wibox.container.margin |
||||||
|
}, |
||||||
|
widget = naughty.list.notifications, |
||||||
|
}, |
||||||
|
layout = wibox.layout.align.vertical |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
local notify_center_trigger = awful.wibar({ |
||||||
|
position = "right", |
||||||
|
width = 1, |
||||||
|
bg = "#00000000", |
||||||
|
opacity = 0, |
||||||
|
ontop = true, |
||||||
|
visible = true |
||||||
|
}) |
||||||
|
|
||||||
|
local notify_center_hide_timer = gears.timer({ timeout = 1}) |
||||||
|
|
||||||
|
notify_center_trigger:geometry({ width = 5, height = s.workarea.height }) |
||||||
|
notify_center_hide_timer:connect_signal("timeout", function() notify_center.visible = false; notify_center_hide_timer:stop() end ) |
||||||
|
notify_center_trigger:connect_signal("mouse::enter", function() notify_center.visible = true end) |
||||||
|
notify_center:connect_signal("mouse::enter", function() if notify_center_hide_timer.started then notify_center_hide_timer:stop() end end) |
||||||
|
notify_center:connect_signal("mouse::leave", function() notify_center_hide_timer:again() end) |
||||||
|
|
||||||
|
end) |
||||||
@ -1,99 +1,113 @@ |
|||||||
local awful = require('awful') |
local awful = require('awful') |
||||||
local wibox = require('wibox') |
local wibox = require('wibox') |
||||||
local gears = require('gears') |
local gears = require('gears') |
||||||
|
local beautiful = require('beautiful') |
||||||
|
local lain = require('../lain') |
||||||
|
|
||||||
local vicious = require("../vicious") |
local bat = lain.widget.bat { |
||||||
local battery = require('../widgets/battery') |
settings = function() |
||||||
--local volume = require('../widgets/volume') |
widget:set_markup("BAT " .. bat_now.perc .. "% ") |
||||||
local date = require('../widgets/date') |
end |
||||||
|
} |
||||||
|
|
||||||
|
local sysload = lain.widget.sysload { |
||||||
|
settings = function() |
||||||
|
widget:set_markup("LOAD " .. load_1 .. ", " .. load_5 .. ", " .. load_15 .. " ") |
||||||
|
end |
||||||
|
} |
||||||
|
|
||||||
require("../modules.widget") |
local cpu = lain.widget.cpu { |
||||||
|
settings = function() |
||||||
|
widget:set_markup("CPU " .. cpu_now.usage .. "% ") |
||||||
|
end |
||||||
|
} |
||||||
|
|
||||||
|
local mem = lain.widget.mem { |
||||||
|
settings = function() |
||||||
|
widget:set_markup("MEM " .. mem_now.perc .. "% ") |
||||||
|
end |
||||||
|
} |
||||||
|
|
||||||
modkey = "Mod4" |
local net = lain.widget.net { |
||||||
|
settings = function() |
||||||
|
widget:set_markup("NET " .. net_now.sent .. "B/" .. net_now.received .. "B ") |
||||||
|
end |
||||||
|
} |
||||||
|
|
||||||
-- Keyboard map indicator and switcher |
modkey = "Mod4" |
||||||
mykeyboardlayout = awful.widget.keyboardlayout() |
|
||||||
|
|
||||||
screen.connect_signal("request::desktop_decoration", function(s) |
screen.connect_signal("request::desktop_decoration", function(s) |
||||||
-- Each screen has its own tag table. |
|
||||||
awful.tag({ "main", "term", "dev", "browse", "social", "misc" }, s, awful.layout.layouts[1]) |
|
||||||
|
|
||||||
-- Create a promptbox for each screen |
-- Create the wibox |
||||||
s.mypromptbox = awful.widget.prompt() |
s.mywibox = awful.wibar({ position = "top" ,height = beautiful.panel_height, screen = s }) |
||||||
|
|
||||||
-- Create an imagebox widget which will contain an icon indicating which layout we're using. |
-- Each screen has its own tag table. |
||||||
-- We need one layoutbox per screen. |
awful.tag({ "main", "term", "dev", "browse", "social", "misc" }, s, awful.layout.layouts[1]) |
||||||
s.mylayoutbox = awful.widget.layoutbox { |
|
||||||
screen = s, |
|
||||||
buttons = { |
|
||||||
awful.button({ }, 1, function () awful.layout.inc( 1) end), |
|
||||||
awful.button({ }, 3, function () awful.layout.inc(-1) end), |
|
||||||
awful.button({ }, 4, function () awful.layout.inc( 1) end), |
|
||||||
awful.button({ }, 5, function () awful.layout.inc(-1) end), |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
-- Create a taglist widget |
-- Create a taglist widget |
||||||
s.mytaglist = awful.widget.taglist { |
s.mytaglist = awful.widget.taglist { |
||||||
screen = s, |
screen = s, |
||||||
filter = awful.widget.taglist.filter.all, |
filter = awful.widget.taglist.filter.all, |
||||||
widget_template = { |
widget_template = { |
||||||
{ |
{ |
||||||
{ |
{ |
||||||
{ |
{ |
||||||
id = 'text_role', |
id = 'text_role', |
||||||
widget = wibox.widget.textbox, |
widget = wibox.widget.textbox, |
||||||
}, |
}, |
||||||
layout = wibox.layout.fixed.horizontal, |
layout = wibox.layout.fixed.horizontal, |
||||||
}, |
|
||||||
left = 18, |
|
||||||
right = 18, |
|
||||||
widget = wibox.container.margin |
|
||||||
}, |
|
||||||
id = 'background_role', |
|
||||||
widget = wibox.container.background, |
|
||||||
}, |
}, |
||||||
buttons = { |
left = 18, |
||||||
awful.button({ }, 1, function(t) t:view_only() end), |
right = 18, |
||||||
awful.button({ modkey }, 1, function(t) |
widget = wibox.container.margin |
||||||
if client.focus then |
}, |
||||||
client.focus:move_to_tag(t) |
id = 'background_role', |
||||||
end |
widget = wibox.container.background, |
||||||
end), |
}, |
||||||
awful.button({ }, 3, awful.tag.viewtoggle), |
buttons = { |
||||||
awful.button({ modkey }, 3, function(t) |
awful.button({ }, 1, function(t) t:view_only() end), |
||||||
if client.focus then |
awful.button({ modkey }, 1, function(t) |
||||||
client.focus:toggle_tag(t) |
if client.focus then |
||||||
end |
client.focus:move_to_tag(t) |
||||||
end), |
end |
||||||
awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), |
end), |
||||||
awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end), |
awful.button({ }, 3, awful.tag.viewtoggle), |
||||||
} |
awful.button({ modkey }, 3, function(t) |
||||||
|
if client.focus then |
||||||
|
client.focus:toggle_tag(t) |
||||||
|
end |
||||||
|
end), |
||||||
|
awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), |
||||||
|
awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end), |
||||||
} |
} |
||||||
|
} |
||||||
|
|
||||||
-- Create the wibox |
-- Add widgets to the wibox |
||||||
s.mywibox = awful.wibar({ position = "top", height = 48, screen = s }) |
s.mywibox.widget = { |
||||||
|
layout = wibox.layout.stack, |
||||||
-- Add widgets to the wibox |
{ |
||||||
s.mywibox.widget = { |
layout = wibox.layout.align.horizontal, |
||||||
layout = wibox.layout.align.horizontal, |
{ -- Left widgets |
||||||
{ -- Left widgets |
layout = wibox.layout.fixed.horizontal, |
||||||
layout = wibox.layout.fixed.horizontal, |
s.mytaglist, |
||||||
mylauncher, |
}, |
||||||
s.mytaglist, |
nil, |
||||||
s.mypromptbox |
{ |
||||||
}, |
layout = wibox.layout.fixed.horizontal, |
||||||
nil, |
cpu, |
||||||
-- s.mytasklist, -- Middle widget |
mem, |
||||||
{ -- Right widgets |
-- net, |
||||||
layout = wibox.layout.fixed.horizontal, |
bat, |
||||||
s.mylayoutbox, |
-- sysload, |
||||||
-- mykeyboardlayout, |
-- wibox.widget.systray(), |
||||||
-- wibox.widget.systray(), |
} |
||||||
battery, |
}, |
||||||
date, |
{ -- Right widgets |
||||||
}, |
layout = wibox.container.place, |
||||||
} |
valign = "center", |
||||||
|
halign = "center", |
||||||
|
wibox.widget.textclock |
||||||
|
}, |
||||||
|
} |
||||||
end) |
end) |
||||||
|
|
||||||
|
|||||||
@ -1,43 +0,0 @@ |
|||||||
local wibox = require("wibox") |
|
||||||
local surface = require("gears.surface") |
|
||||||
local shape = require("gears.shape") |
|
||||||
|
|
||||||
local module = {} |
|
||||||
|
|
||||||
local function fit(self, context, width, height) |
|
||||||
local size = math.min(width, height) |
|
||||||
return size, size |
|
||||||
end |
|
||||||
|
|
||||||
local function set_client(self, c) |
|
||||||
ret._private.client[1] = c |
|
||||||
self:emit_signal("widget::redraw_needed") |
|
||||||
end |
|
||||||
|
|
||||||
local function draw(self, content, cr, width, height) |
|
||||||
local c = self._private.client[1] |
|
||||||
local s, geo = surface(c.content), c:geometry() |
|
||||||
local scale = math.min(width/geo.width, height/geo.height) |
|
||||||
local w, h = geo.width*scale, geo.height*scale |
|
||||||
local dx, dy = (width-w)/2, (height-h)/2 |
|
||||||
cr:translate(dx, dy) |
|
||||||
shape.rounded_rect(cr, w, h) |
|
||||||
cr:clip() |
|
||||||
cr:scale(scale, scale) |
|
||||||
cr:set_source_surface(s) |
|
||||||
cr:paint() |
|
||||||
end |
|
||||||
|
|
||||||
local function new(c) |
|
||||||
local ret = wibox.widget.base.make_widget(nil, nil, { |
|
||||||
enable_properties = true, |
|
||||||
}) |
|
||||||
|
|
||||||
rawset(ret, "fit" , fit ) |
|
||||||
rawset(ret, "draw" , draw ) |
|
||||||
rawset(ret, "set_client", set_client) |
|
||||||
ret._private.client = setmetatable({c}, {__mode="v"}) |
|
||||||
return ret |
|
||||||
end |
|
||||||
|
|
||||||
return setmetatable(module, {__call=function(_,...) return new(...) end}) |
|
||||||
@ -0,0 +1,82 @@ |
|||||||
|
local awful = require("awful") |
||||||
|
local ruled = require("ruled") |
||||||
|
|
||||||
|
ruled.client.connect_signal("request::rules", function() |
||||||
|
-- All clients will match this rule. |
||||||
|
ruled.client.append_rule { |
||||||
|
id = "global", |
||||||
|
rule = { }, |
||||||
|
properties = { |
||||||
|
focus = awful.client.focus.filter, |
||||||
|
raise = true, |
||||||
|
screen = awful.screen.preferred, |
||||||
|
placement = awful.placement.no_overlap+awful.placement.no_offscreen |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
-- Floating terminal. |
||||||
|
ruled.client.append_rule { |
||||||
|
id = "floating_terminal", |
||||||
|
rule_any = { |
||||||
|
instance = { "floating_terminal" }, |
||||||
|
}, |
||||||
|
properties = { |
||||||
|
floating = true, |
||||||
|
height = 960, |
||||||
|
width = 1280, |
||||||
|
placement = awful.placement.centered |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
-- Floating clients. |
||||||
|
ruled.client.append_rule { |
||||||
|
id = "floating", |
||||||
|
rule_any = { |
||||||
|
instance = { "copyq", "pinentry" }, |
||||||
|
class = { |
||||||
|
"Arandr", "Blueman-manager", "Gpick", "Kruler", "Sxiv", |
||||||
|
"Tor Browser", "Wpa_gui", "veromix", "xtightvncviewer" |
||||||
|
}, |
||||||
|
-- Note that the name property shown in xprop might be set slightly after creation of the client |
||||||
|
-- and the name shown there might not match defined rules here. |
||||||
|
name = { |
||||||
|
"Event Tester", "Qalculate!" -- xev. |
||||||
|
}, |
||||||
|
role = { |
||||||
|
"AlarmWindow", -- Thunderbird's calendar. |
||||||
|
"ConfigManager", -- Thunderbird's about:config. |
||||||
|
"pop-up", -- e.g. Google Chrome's (detached) Developer Tools. |
||||||
|
} |
||||||
|
}, |
||||||
|
properties = { |
||||||
|
floating = true, |
||||||
|
placement = awful.placement.centered |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
-- Add titlebars to normal clients and dialogs |
||||||
|
ruled.client.append_rule { |
||||||
|
id = "titlebars", |
||||||
|
rule_any = { type = { "normal", "dialog" } }, |
||||||
|
properties = { titlebars_enabled = true } |
||||||
|
} |
||||||
|
ruled.client.append_rule { |
||||||
|
rule = { class = "Plank" }, |
||||||
|
properties = { |
||||||
|
border_width = 0, |
||||||
|
floating = true, |
||||||
|
sticky = true, |
||||||
|
ontop = true, |
||||||
|
focusable = false, |
||||||
|
below = true |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
-- Set Firefox to always map on the tag named "2" on screen 1. |
||||||
|
-- ruled.client.append_rule { |
||||||
|
-- rule = { class = "Firefox" }, |
||||||
|
-- properties = { screen = 1, tag = "2" } |
||||||
|
-- } |
||||||
|
end) |
||||||
|
|
||||||
|
-- }}} |
||||||
|
After Width: | Height: | Size: 235 KiB |
|
After Width: | Height: | Size: 390 B |
|
After Width: | Height: | Size: 385 B |
|
After Width: | Height: | Size: 387 B |
|
After Width: | Height: | Size: 381 B |
|
After Width: | Height: | Size: 425 B |
|
After Width: | Height: | Size: 378 B |
|
After Width: | Height: | Size: 380 B |
|
After Width: | Height: | Size: 389 B |
|
After Width: | Height: | Size: 194 B |
|
After Width: | Height: | Size: 164 B |
|
After Width: | Height: | Size: 187 B |
|
After Width: | Height: | Size: 102 KiB |
|
After Width: | Height: | Size: 6.6 MiB |
|
After Width: | Height: | Size: 322 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 147 B |
|
After Width: | Height: | Size: 147 B |
|
After Width: | Height: | Size: 148 B |
|
After Width: | Height: | Size: 152 B |
@ -0,0 +1 @@ |
|||||||
|
convert *.png -scale 75% -set filename:f '%t' '%[filename:f].png' |
||||||
|
Before Width: | Height: | Size: 194 B After Width: | Height: | Size: 407 B |
|
Before Width: | Height: | Size: 164 B After Width: | Height: | Size: 369 B |
|
Before Width: | Height: | Size: 187 B After Width: | Height: | Size: 402 B |
|
After Width: | Height: | Size: 2.5 MiB |
@ -0,0 +1,59 @@ |
|||||||
|
local wibox = require('wibox') |
||||||
|
local beautiful = require('beautiful') |
||||||
|
|
||||||
|
local create_click_events = function(widget) |
||||||
|
|
||||||
|
local container = wibox.widget { |
||||||
|
widget, |
||||||
|
widget = wibox.container.background |
||||||
|
} |
||||||
|
|
||||||
|
-- Old and new widget |
||||||
|
local old_cursor, old_wibox |
||||||
|
|
||||||
|
-- Mouse hovers on the widget |
||||||
|
container:connect_signal( |
||||||
|
'mouse::enter', |
||||||
|
function() |
||||||
|
container.bg = beautiful.groups_bg |
||||||
|
-- Hm, no idea how to get the wibox from this signal's arguments... |
||||||
|
local w = mouse.current_wibox |
||||||
|
if w then |
||||||
|
old_cursor, old_wibox = w.cursor, w |
||||||
|
w.cursor = 'hand1' |
||||||
|
end |
||||||
|
end |
||||||
|
) |
||||||
|
|
||||||
|
-- Mouse leaves the widget |
||||||
|
container:connect_signal( |
||||||
|
'mouse::leave', |
||||||
|
function() |
||||||
|
container.bg = beautiful.leave_event |
||||||
|
if old_wibox then |
||||||
|
old_wibox.cursor = old_cursor |
||||||
|
old_wibox = nil |
||||||
|
end |
||||||
|
end |
||||||
|
) |
||||||
|
|
||||||
|
-- Mouse pressed the widget |
||||||
|
container:connect_signal( |
||||||
|
'button::press', |
||||||
|
function() |
||||||
|
container.bg = beautiful.press_event |
||||||
|
end |
||||||
|
) |
||||||
|
|
||||||
|
-- Mouse releases the widget |
||||||
|
container:connect_signal( |
||||||
|
'button::release', |
||||||
|
function() |
||||||
|
container.bg = beautiful.release_event |
||||||
|
end |
||||||
|
) |
||||||
|
|
||||||
|
return container |
||||||
|
end |
||||||
|
|
||||||
|
return create_click_events |
||||||