Formatting

This commit is contained in:
Thomas Avé 2022-07-23 19:31:38 +02:00
parent 20b61f0f67
commit 8dcb8694e5
11 changed files with 1124 additions and 1125 deletions

View File

@ -31,30 +31,30 @@ local exit_screen = {}
local icon_size = dpi(90)
local build_button = function(icon)
local button = wibox.widget {
wibox.widget {
wibox.widget {
local button = wibox.widget {
wibox.widget {
wibox.widget {
image = icon,
widget = wibox.widget.imagebox
wibox.widget {
image = icon,
widget = wibox.widget.imagebox
},
top = dpi(16),
bottom = dpi(16),
left = dpi(16),
right = dpi(16),
widget = wibox.container.margin
},
top = dpi(16),
bottom = dpi(16),
left = dpi(16),
right = dpi(16),
widget = wibox.container.margin
},
shape = gears.shape.circle,
forced_width = icon_size,
forced_height = icon_size,
widget = clickable_container
},
left = dpi(24),
right = dpi(24),
widget = wibox.container.margin
}
shape = gears.shape.circle,
forced_width = icon_size,
forced_height = icon_size,
widget = clickable_container
},
left = dpi(24),
right = dpi(24),
widget = wibox.container.margin
}
return button
return button
end
@ -66,102 +66,102 @@ end
local exit_screen_grabber
local function suspend_command()
exit_screen.hide()
awful.spawn.with_shell(apps.lock .. " & systemctl suspend")
exit_screen.hide()
awful.spawn.with_shell(apps.lock .. " & systemctl suspend")
end
local function exit_command()
awesome.quit()
awesome.quit()
end
local function lock_command()
exit_screen.hide()
awful.spawn.with_shell("sleep 1 && " .. apps.lock)
exit_screen.hide()
awful.spawn.with_shell("sleep 1 && " .. apps.lock)
end
local function poweroff_command()
awful.spawn.with_shell("poweroff")
awful.keygrabber.stop(exit_screen_grabber)
awful.spawn.with_shell("poweroff")
awful.keygrabber.stop(exit_screen_grabber)
end
local function reboot_command()
awful.spawn.with_shell("reboot")
awful.keygrabber.stop(exit_screen_grabber)
awful.spawn.with_shell("reboot")
awful.keygrabber.stop(exit_screen_grabber)
end
local poweroff = build_button(ICON_DIR .. "power.png", "Shutdown")
poweroff:connect_signal(
"button::release",
function()
poweroff_command()
end
"button::release",
function()
poweroff_command()
end
)
local reboot = build_button(ICON_DIR .. "restart.png", "Restart")
reboot:connect_signal(
"button::release",
function()
reboot_command()
end
"button::release",
function()
reboot_command()
end
)
local suspend = build_button(ICON_DIR .. "sleep.png", "Sleep")
suspend:connect_signal(
"button::release",
function()
suspend_command()
end
"button::release",
function()
suspend_command()
end
)
local exit = build_button(ICON_DIR .. "logout.png", "Logout")
exit:connect_signal(
"button::release",
function()
exit_command()
end
"button::release",
function()
exit_command()
end
)
local lock = build_button(ICON_DIR .. "lock.png", "Lock")
lock:connect_signal(
"button::release",
function()
lock_command()
end
"button::release",
function()
lock_command()
end
)
-- subscribe to the show_exit_screen signal
-- show the exit screen when signal is broadcasted
awesome.connect_signal("show_exit_screen",
function()
exit_screen_grabber = awful.keygrabber.run(
function(_, key, event)
if event == "release" then
return
end
function()
exit_screen_grabber = awful.keygrabber.run(
function(_, key, event)
if event == "release" then
return
end
if key == "s" then
suspend_command()
elseif key == "e" then
exit_command()
elseif key == "l" then
lock_command()
elseif key == "p" then
poweroff_command()
elseif key == "r" then
reboot_command()
elseif key == "Escape" or key == "q" or key == "x" then
exit_screen.hide()
if key == "s" then
suspend_command()
elseif key == "e" then
exit_command()
elseif key == "l" then
lock_command()
elseif key == "p" then
poweroff_command()
elseif key == "r" then
reboot_command()
elseif key == "Escape" or key == "q" or key == "x" then
exit_screen.hide()
end
end
end
)
exit_screen.widget.visible = true
end
)
exit_screen.widget.visible = true
end
)
-- hide exit screen
function exit_screen.hide()
awful.keygrabber.stop(exit_screen_grabber)
exit_screen.widget.visible = false
awful.keygrabber.stop(exit_screen_grabber)
exit_screen.widget.visible = false
end
@ -174,52 +174,52 @@ local screen_geometry = awful.screen.focused().geometry
-- Create the widget
exit_screen.widget = wibox({
x = screen_geometry.x,
y = screen_geometry.y,
visible = false,
ontop = true,
type = "splash",
height = screen_geometry.height,
width = screen_geometry.width
x = screen_geometry.x,
y = screen_geometry.y,
visible = false,
ontop = true,
type = "splash",
height = screen_geometry.height,
width = screen_geometry.width
})
exit_screen.widget:buttons(
gears.table.join(
-- Middle click - Hide exit_screen
awful.button({}, 2,
function()
exit_screen.hide()
end
),
-- Right click - Hide exit_screen
awful.button({}, 3,
function()
exit_screen.hide()
end
)
)
gears.table.join(
-- Middle click - Hide exit_screen
awful.button({}, 2,
function()
exit_screen.hide()
end
),
-- Right click - Hide exit_screen
awful.button({}, 3,
function()
exit_screen.hide()
end
)
)
)
-- Item placement
exit_screen.widget:setup {
nil,
{
nil,
{
poweroff,
reboot,
suspend,
exit,
lock,
layout = wibox.layout.fixed.horizontal
},
nil,
expand = "none",
layout = wibox.layout.align.horizontal
},
nil,
expand = "none",
layout = wibox.layout.align.vertical
nil,
{
nil,
{
poweroff,
reboot,
suspend,
exit,
lock,
layout = wibox.layout.fixed.horizontal
},
nil,
expand = "none",
layout = wibox.layout.align.horizontal
},
nil,
expand = "none",
layout = wibox.layout.align.vertical
}
return exit_screen

View File

@ -32,14 +32,14 @@ naughty.config.defaults.margin = dpi(16)
naughty.config.defaults.border_width = 0
naughty.config.defaults.position = "top_right"
naughty.config.defaults.shape = function(cr, w, h)
gears.shape.rounded_rect(cr, w, h, dpi(6))
gears.shape.rounded_rect(cr, w, h, dpi(6))
end
naughty.config.padding = dpi(7)
naughty.config.spacing = dpi(7)
naughty.config.icon_dirs = {
"/usr/share/icons/Tela-dark",
"/usr/share/pixmaps/"
"/usr/share/icons/Tela-dark",
"/usr/share/pixmaps/"
}
naughty.config.icon_formats = {"png", "svg"}
@ -48,25 +48,25 @@ naughty.config.presets.low.timeout = 3
naughty.config.presets.critical.timeout = 0
naughty.config.presets.normal = {
font = beautiful.title_font,
fg = beautiful.fg_normal,
bg = beautiful.bg_normal,
position = "top_right"
font = beautiful.title_font,
fg = beautiful.fg_normal,
bg = beautiful.bg_normal,
position = "top_right"
}
naughty.config.presets.low = {
font = beautiful.title_font,
fg = beautiful.fg_normal,
bg = beautiful.bg_normal,
position = "top_right"
font = beautiful.title_font,
fg = beautiful.fg_normal,
bg = beautiful.bg_normal,
position = "top_right"
}
naughty.config.presets.critical = {
font = "SF Display Bold 10",
fg = "#ffffff",
bg = "#ff0000",
position = "top_right",
timeout = 0
font = "SF Display Bold 10",
fg = "#ffffff",
bg = "#ff0000",
position = "top_right",
timeout = 0
}
naughty.config.presets.ok = naughty.config.presets.normal
@ -80,29 +80,29 @@ naughty.config.presets.warn = naughty.config.presets.critical
if awesome.startup_errors then
naughty.notify({
preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors
})
naughty.notify({
preset = naughty.config.presets.critical,
title = "Oops, there were errors during startup!",
text = awesome.startup_errors
})
end
do
local in_error = false
awesome.connect_signal(
"debug::error",
function(err)
if in_error then
return
end
in_error = true
local in_error = false
awesome.connect_signal(
"debug::error",
function(err)
if in_error then
return
end
in_error = true
naughty.notify({
preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = tostring(err)
})
in_error = false
end
)
naughty.notify({
preset = naughty.config.presets.critical,
title = "Oops, an error happened!",
text = tostring(err)
})
in_error = false
end
)
end

View File

@ -82,55 +82,55 @@ local cpu_widget = wibox.widget{
-- ===================================================================
top_panel.create = function(s)
local panel = awful.wibar({
screen = s,
position = "top",
ontop = true,
height = beautiful.top_panel_height,
width = s.geometry.width,
bg = theme.bg_normal .. "99"
})
local panel = awful.wibar({
screen = s,
position = "top",
ontop = true,
height = beautiful.top_panel_height,
width = s.geometry.width,
bg = theme.bg_normal .. "99"
})
panel:setup {
expand = "none",
layout = wibox.layout.align.horizontal,
task_list.create(s),
nil,
{
layout = wibox.layout.fixed.horizontal,
pl(wibox.widget{}, theme.bg_normal .. "00", theme.top_panel_powerline),
pl(wibox.container.margin(wibox.widget.systray(), 0, 0, 5, 5), theme.top_panel_powerline, theme.bg_normal),
pl(volume_widget({widget_type='icon_and_text'}), theme.bg_normal, theme.top_panel_powerline),
pl(awful.widget.watch('bash -c "sensors | grep Tctl | cut -f 10 -d \' \' | cut -c 2-"', 5), theme.top_panel_powerline, theme.bg_normal),
pl(memory_widget, theme.bg_normal, theme.top_panel_powerline),
pl(cpu_widget, theme.top_panel_powerline, theme.bg_normal),
pl(frequency_widget, theme.bg_normal, theme.top_panel_powerline),
pl(updates_indicator, theme.top_panel_powerline, theme.bg_normal),
pl(require("widgets.layout-box"), theme.bg_normal, theme.top_panel_powerline),
pl(wibox.widget.textclock('%a %b %d, %H:%M:%S', 1), theme.top_panel_powerline, theme.top_panel_powerline),
}
}
panel:setup {
expand = "none",
layout = wibox.layout.align.horizontal,
task_list.create(s),
nil,
{
layout = wibox.layout.fixed.horizontal,
pl(wibox.widget{}, theme.bg_normal .. "00", theme.top_panel_powerline),
pl(wibox.container.margin(wibox.widget.systray(), 0, 0, 5, 5), theme.top_panel_powerline, theme.bg_normal),
pl(volume_widget({widget_type='icon_and_text'}), theme.bg_normal, theme.top_panel_powerline),
pl(awful.widget.watch('bash -c "sensors | grep Tctl | cut -f 10 -d \' \' | cut -c 2-"', 5), theme.top_panel_powerline, theme.bg_normal),
pl(memory_widget, theme.bg_normal, theme.top_panel_powerline),
pl(cpu_widget, theme.top_panel_powerline, theme.bg_normal),
pl(frequency_widget, theme.bg_normal, theme.top_panel_powerline),
pl(updates_indicator, theme.top_panel_powerline, theme.bg_normal),
pl(require("widgets.layout-box"), theme.bg_normal, theme.top_panel_powerline),
pl(wibox.widget.textclock('%a %b %d, %H:%M:%S', 1), theme.top_panel_powerline, theme.top_panel_powerline),
}
}
-- ===================================================================
-- Functionality
-- ===================================================================
-- ===================================================================
-- Functionality
-- ===================================================================
-- hide panel when client is fullscreen
local function change_panel_visibility(client)
if client.screen == s then
panel.ontop = not client.fullscreen
end
end
-- hide panel when client is fullscreen
local function change_panel_visibility(client)
if client.screen == s then
panel.ontop = not client.fullscreen
end
end
-- connect panel visibility function to relevant signals
client.connect_signal("property::fullscreen", change_panel_visibility)
client.connect_signal("focus", change_panel_visibility)
-- connect panel visibility function to relevant signals
client.connect_signal("property::fullscreen", change_panel_visibility)
client.connect_signal("focus", change_panel_visibility)
updates_indicator:connect_signal("button::press", function(c, _, _, button)
awful.spawn('bash -c "WINIT_X11_SCALE_FACTOR=1 alacritty -e bash -c \"yay ; echo \'\\nDone, press any key to exit...\' ; read\""')
end)
updates_indicator:connect_signal("button::press", function(c, _, _, button)
awful.spawn('bash -c "WINIT_X11_SCALE_FACTOR=1 alacritty -e bash -c \"yay ; echo \'\\nDone, press any key to exit...\' ; read\""')
end)
end

File diff suppressed because it is too large Load Diff

View File

@ -24,33 +24,33 @@ local pastel = {}
pastel.initialize = function()
-- Import components
require("components.pastel.wallpaper")
require("components.exit-screen")
-- Import components
require("components.pastel.wallpaper")
require("components.exit-screen")
-- Import panels
local top_panel = require("components.pastel.top-panel")
-- Import panels
local top_panel = require("components.pastel.top-panel")
-- Set up each screen (add tags & panels)
awful.screen.connect_for_each_screen(function(s)
for i = 1, 9, 1
do
awful.tag.add(i, {
icon_only = true,
layout = awful.layout.suit.tile,
screen = s,
selected = i == 1
})
end
-- Set up each screen (add tags & panels)
awful.screen.connect_for_each_screen(function(s)
for i = 1, 9, 1
do
awful.tag.add(i, {
icon_only = true,
layout = awful.layout.suit.tile,
screen = s,
selected = i == 1
})
end
s.quake = quake
s.quake = quake
-- Only add the top panel on the primary screen
if s.index == 1 then
top_panel.create(s)
end
-- Only add the top panel on the primary screen
if s.index == 1 then
top_panel.create(s)
end
end)
end)
end
return pastel

View File

@ -20,27 +20,27 @@ local theme_config_dir = gears.filesystem.get_configuration_dir() .. "/configura
-- define default apps (global variable so other components can access it)
apps = {
network_manager = "nm-connection-editor", -- recommended: nm-connection-editor
power_manager = "", -- recommended: xfce4-power-manager
terminal = 'bash -c "WINIT_X11_SCALE_FACTOR=1 alacritty"',
launcher = "/home/user/.toggle_rofi.sh",
lock = "i3lock",
screenshot = "scrot -e 'mv $f ~/Pictures/Screenshots/ 2>/dev/null'",
filebrowser = "nautilus"
network_manager = "nm-connection-editor", -- recommended: nm-connection-editor
power_manager = "", -- recommended: xfce4-power-manager
terminal = 'bash -c "WINIT_X11_SCALE_FACTOR=1 alacritty"',
launcher = "/home/user/.toggle_rofi.sh",
lock = "i3lock",
screenshot = "scrot -e 'mv $f ~/Pictures/Screenshots/ 2>/dev/null'",
filebrowser = "nautilus"
}
-- define wireless and ethernet interface names for the network widget
-- use `ip link` command to determine these
network_interfaces = {
lan = 'enp4s0'
lan = 'enp4s0'
}
-- List of apps to run on start-up
local run_on_start_up = {
"numlockx on",
"bluetoothctl power on",
"nm-applet",
"blueman-applet"
"numlockx on",
"bluetoothctl power on",
"nm-applet",
"blueman-applet"
}
-- ===================================================================
@ -53,13 +53,13 @@ require("components.notifications")
-- Run all the apps listed in run_on_start_up
for _, app in ipairs(run_on_start_up) do
local findme = app
local firstspace = app:find(" ")
if firstspace then
findme = app:sub(0, firstspace - 1)
end
-- pipe commands to bash to allow command to be shell agnostic
awful.spawn.with_shell(string.format("echo 'pgrep -u $USER -x %s > /dev/null || (%s)' | bash -", findme, app), false)
local findme = app
local firstspace = app:find(" ")
if firstspace then
findme = app:sub(0, firstspace - 1)
end
-- pipe commands to bash to allow command to be shell agnostic
awful.spawn.with_shell(string.format("echo 'pgrep -u $USER -x %s > /dev/null || (%s)' | bash -", findme, app), false)
end
-- Import theme
@ -81,36 +81,36 @@ awful.rules.rules = create_rules(keys.clientkeys, keys.clientbuttons)
-- Define layouts
awful.layout.layouts = {
awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
awful.layout.suit.floating,
awful.layout.suit.tile,
awful.layout.suit.tile.left,
awful.layout.suit.tile.bottom,
awful.layout.suit.tile.top,
awful.layout.suit.fair,
awful.layout.suit.fair.horizontal,
}
-- remove gaps if layout is set to max
tag.connect_signal('property::layout', function(t)
local current_layout = awful.tag.getproperty(t, 'layout')
if (current_layout == awful.layout.suit.max) then
t.gap = 0
else
t.gap = beautiful.useless_gap
end
local current_layout = awful.tag.getproperty(t, 'layout')
if (current_layout == awful.layout.suit.max) then
t.gap = 0
else
t.gap = beautiful.useless_gap
end
end)
-- Signal function to execute when a new client appears.
client.connect_signal("manage", function (c)
-- Set the window as a slave (put it at the end of others instead of setting it as master)
if not awesome.startup then
awful.client.setslave(c)
end
-- Set the window as a slave (put it at the end of others instead of setting it as master)
if not awesome.startup then
awful.client.setslave(c)
end
if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then
-- Prevent clients from being unreachable after screen count changes.
awful.placement.no_offscreen(c)
end
if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then
-- Prevent clients from being unreachable after screen count changes.
awful.placement.no_offscreen(c)
end
end)
@ -124,7 +124,7 @@ require("awful.autofocus")
-- Focus clients under mouse
client.connect_signal("mouse::enter", function(c)
c:emit_signal("request::activate", "mouse_enter", {raise = false})
c:emit_signal("request::activate", "mouse_enter", {raise = false})
end)
@ -146,24 +146,24 @@ collectgarbage("setpause", 110)
collectgarbage("setstepmul", 1000)
require("awesomewm-vim-tmux-navigator") {
up = {"Up", "k"},
down = {"Down", "j"},
left = {"Left", "h"},
right = {"Right", "l"},
mod = "Mod4",
mod_keysym = "Super_L",
-- experimental = true
up = {"Up", "k"},
down = {"Down", "j"},
left = {"Left", "h"},
right = {"Right", "l"},
mod = "Mod4",
mod_keysym = "Super_L",
-- experimental = true
}
local handle_single_win = function(focused)
local hide = focused.maximized or focused.fullscreen
for i, c in ipairs(client.get()) do
if not c.floating and c.screen == focused.screen then
c.minimized = hide
end
end
local hide = focused.maximized or focused.fullscreen
for i, c in ipairs(client.get()) do
if not c.floating and c.screen == focused.screen then
c.minimized = hide
end
end
focused.minimized = false
focused.minimized = false
end
--
-- client.connect_signal("property::fullscreen", handle_single_win)

View File

@ -28,97 +28,97 @@ local rules = {}
-- return a table of client rules including provided keys / buttons
function rules.create(clientkeys, clientbuttons)
return {
-- All clients will match this rule.
{
rule = {},
properties = {
titlebars_enabled = beautiful.titlebars_enabled,
border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
keys = clientkeys,
buttons = clientbuttons,
screen = awful.screen.preferred,
placement = awful.placement.centered
},
},
-- Floating clients.
{
rule_any = {
instance = {
"DTA",
"copyq",
return {
-- All clients will match this rule.
{
rule = {},
properties = {
titlebars_enabled = beautiful.titlebars_enabled,
border_width = beautiful.border_width,
border_color = beautiful.border_normal,
focus = awful.client.focus.filter,
raise = true,
keys = clientkeys,
buttons = clientbuttons,
screen = awful.screen.preferred,
placement = awful.placement.centered
},
class = {
"Nm-connection-editor"
},
name = {
"Event Tester",
"Steam Guard - Computer Authorization Required"
},
role = {
"pop-up",
"GtkFileChooserDialog"
},
type = {
"dialog"
}
}, properties = {floating = true}
},
},
-- Floating clients.
{
rule_any = {
instance = {
"DTA",
"copyq",
},
class = {
"Nm-connection-editor"
},
name = {
"Event Tester",
"Steam Guard - Computer Authorization Required"
},
role = {
"pop-up",
"GtkFileChooserDialog"
},
type = {
"dialog"
}
}, properties = {floating = true}
},
-- Fullscreen clients
{
rule_any = {
class = {
"Terraria.bin.x86",
-- Fullscreen clients
{
rule_any = {
class = {
"Terraria.bin.x86",
},
}, properties = {fullscreen = true}
},
-- "Switch to tag"
-- These clients make you switch to their tag when they appear
{
rule_any = {
class = {
"Firefox"
},
}, properties = {switchtotag = true}
},
-- Visualizer
{
rule_any = {name = {"cava"}},
properties = {
floating = true,
maximized_horizontal = true,
sticky = true,
ontop = false,
skip_taskbar = true,
below = true,
focusable = false,
height = screen_height * 0.40,
opacity = 0.6
},
}, properties = {fullscreen = true}
},
callback = function (c)
decorations.hide(c)
awful.placement.bottom(c)
end
},
-- "Switch to tag"
-- These clients make you switch to their tag when they appear
{
rule_any = {
class = {
"Firefox"
},
}, properties = {switchtotag = true}
},
-- File chooser dialog
{
rule_any = {role = {"GtkFileChooserDialog"}},
properties = {floating = true, width = screen_width * 0.55, height = screen_height * 0.65}
},
-- Visualizer
{
rule_any = {name = {"cava"}},
properties = {
floating = true,
maximized_horizontal = true,
sticky = true,
ontop = false,
skip_taskbar = true,
below = true,
focusable = false,
height = screen_height * 0.40,
opacity = 0.6
},
callback = function (c)
decorations.hide(c)
awful.placement.bottom(c)
end
},
-- File chooser dialog
{
rule_any = {role = {"GtkFileChooserDialog"}},
properties = {floating = true, width = screen_width * 0.55, height = screen_height * 0.65}
},
-- Pavucontrol & Bluetooth Devices
{
rule_any = {class = {"Pavucontrol"}, name = {"Bluetooth Devices"}},
properties = {floating = true, width = screen_width * 0.55, height = screen_height * 0.45}
},
}
-- Pavucontrol & Bluetooth Devices
{
rule_any = {class = {"Pavucontrol"}, name = {"Bluetooth Devices"}},
properties = {floating = true, width = screen_width * 0.55, height = screen_height * 0.45}
},
}
end
-- return module table

View File

@ -27,47 +27,47 @@ local wibox = require('wibox')
function build(widget)
local container =
wibox.widget {
widget,
widget = wibox.container.background
wibox.widget {
widget,
widget = wibox.container.background
}
local old_cursor, old_wibox
container:connect_signal(
'mouse::enter',
function()
container.bg = '#ffffff11'
local w = _G.mouse.current_wibox
if w then
old_cursor, old_wibox = w.cursor, w
w.cursor = 'hand1'
end
end
'mouse::enter',
function()
container.bg = '#ffffff11'
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
'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
'button::press',
function()
container.bg = '#ffffff22'
end
)
container:connect_signal(
'button::release',
function()
container.bg = '#ffffff11'
end
'button::release',
function()
container.bg = '#ffffff11'
end
)
return container

View File

@ -30,14 +30,14 @@ local folder = {}
-- split a string into a list based on a deliminator
local function split_string(inputstr, delim)
if delim == nil then
delim = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..delim.."]+)") do
table.insert(t, str)
end
return t
if delim == nil then
delim = "%s"
end
local t={}
for str in string.gmatch(inputstr, "([^"..delim.."]+)") do
table.insert(t, str)
end
return t
end
@ -47,50 +47,50 @@ end
function folder.create(directory)
local docu_widget = wibox.widget {
{
id = "icon",
widget = wibox.widget.imagebox,
resize = true
},
layout = wibox.layout.align.horizontal
}
local docu_widget = wibox.widget {
{
id = "icon",
widget = wibox.widget.imagebox,
resize = true
},
layout = wibox.layout.align.horizontal
}
local docu_button = clickable_container(wibox.container.margin(docu_widget, dpi(8), dpi(8), dpi(8), dpi(8)))
docu_button:buttons(
gears.table.join(
awful.button({}, 1, nil,
function()
awful.spawn.easy_async_with_shell(apps.filebrowser .. " " .. directory, function(stderr) end, 1)
end
)
)
)
local docu_button = clickable_container(wibox.container.margin(docu_widget, dpi(8), dpi(8), dpi(8), dpi(8)))
docu_button:buttons(
gears.table.join(
awful.button({}, 1, nil,
function()
awful.spawn.easy_async_with_shell(apps.filebrowser .. " " .. directory, function(stderr) end, 1)
end
)
)
)
-- determine hover name & icon to use
-- icon name must correspond with name of folder
local folder_name = ""
if directory == HOME_DIR then
folder_name = "Home"
elseif directory == "trash://" then
folder_name = "Trash"
else
local dir_list = split_string(directory, "/")
folder_name = dir_list[#dir_list]
end
-- determine hover name & icon to use
-- icon name must correspond with name of folder
local folder_name = ""
if directory == HOME_DIR then
folder_name = "Home"
elseif directory == "trash://" then
folder_name = "Trash"
else
local dir_list = split_string(directory, "/")
folder_name = dir_list[#dir_list]
end
awful.tooltip({
objects = {docu_button},
mode = "outside",
align = "right",
timer_function = function()
return folder_name
end,
preferred_positions = {"right", "left", "top", "bottom"}
})
awful.tooltip({
objects = {docu_button},
mode = "outside",
align = "right",
timer_function = function()
return folder_name
end,
preferred_positions = {"right", "left", "top", "bottom"}
})
docu_widget.icon:set_image(PATH_TO_ICONS .. folder_name:lower() .. ".png")
return docu_button
docu_widget.icon:set_image(PATH_TO_ICONS .. folder_name:lower() .. ".png")
return docu_button
end
return folder

View File

@ -10,7 +10,6 @@
-- ===================================================================
local clickable_container = require('widgets.clickable-container')
local awful = require('awful')
@ -21,31 +20,31 @@ local awful = require('awful')
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
-- We need one layoutbox per screen.
local layout_box = clickable_container(awful.widget.layoutbox(s))
local layout_box = awful.widget.layoutbox(s)
layout_box:buttons(
awful.util.table.join(
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
)
)
awful.util.table.join(
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
)
)
)
return layout_box

View File

@ -1,9 +1,9 @@
-- ████████╗ █████╗ ███████╗██╗ ██╗ ██╗ ██╗███████╗████████╗
-- ╚══██╔══╝██╔══██╗██╔════╝██║ ██╔╝ ██║ ██║██╔════╝╚══██╔══╝
-- ██║ ███████║███████╗█████╔╝ ██║ ██║███████╗ ██║
-- ██║ ██╔══██║╚════██║██╔═██╗ ██║ ██║╚════██║ ██║
-- ██║ ██║ ██║███████║██║ ██╗ ███████╗██║███████║ ██║
-- ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚══════╝╚═╝╚══════╝ ╚═╝
-- ████████╗ █████╗ ███████╗██╗ ██╗ ██╗ ██╗███████╗████████╗
-- ╚══██╔══╝██╔══██╗██╔════╝██║ ██╔╝ ██║ ██║██╔════╝╚══██╔══╝
-- ██║ ███████║███████╗█████╔╝ ██║ ██║███████╗ ██║
-- ██║ ██╔══██║╚════██║██╔═██╗ ██║ ██║╚════██║ ██║
-- ██║ ██║ ██║███████║██║ ██╗ ███████╗██║███████║ ██║
-- ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚══════╝╚═╝╚══════╝ ╚═╝
-- ===================================================================
-- Initialization
@ -31,118 +31,118 @@ local task_list = {}
local function create_buttons(buttons, object)
if buttons then
local btns = {}
for _, b in ipairs(buttons) do
-- Create a proxy button object: it will receive the real
-- press and release events, and will propagate them to the
-- button object the user provided, but with the object as
-- argument.
local btn = capi.button {modifiers = b.modifiers, button = b.button}
btn:connect_signal('press',
function()
object.minimized = not object.minimized
end
)
btns[#btns + 1] = btn
end
return btns
end
if buttons then
local btns = {}
for _, b in ipairs(buttons) do
-- Create a proxy button object: it will receive the real
-- press and release events, and will propagate them to the
-- button object the user provided, but with the object as
-- argument.
local btn = capi.button {modifiers = b.modifiers, button = b.button}
btn:connect_signal('press',
function()
object.minimized = not object.minimized
end
)
btns[#btns + 1] = btn
end
return btns
end
end
local function list_update(w, buttons, label, data, objects)
-- update the widgets, creating them if needed
w:reset()
local index = 0
local count = 0
for _ in pairs(objects) do
count = count + 1
end
for i, o in ipairs(objects) do
index = index + 1
local ib, cb, tb, cbm, bgb, tbm, ibm, tt, l, ll
ib = wibox.widget.imagebox()
tb = wibox.widget.textbox()
cb = wibox.container.margin(wibox.widget.imagebox(ICON_DIR .. "close.svg"), dpi(9), dpi(9), dpi(9), dpi(9))
cb.shape = gears.shape.circle
cbm = wibox.container.margin(cb, dpi(0), dpi(0), dpi(0), dpi(0)) -- 4, 8 ,12 ,12 -- close button
cbm:buttons(gears.table.join(awful.button({}, 1, nil,
function()
o.kill(o)
end
)))
bgb = wibox.container.background()
tbm = wibox.container.margin(tb, dpi(4), dpi(4))
ibm = wibox.container.margin(ib, dpi(5), dpi(5), dpi(5), dpi(5)) -- 12 is default top and bottom margin --app icon
l = wibox.layout.fixed.horizontal()
ll = wibox.layout.fixed.horizontal()
-- update the widgets, creating them if needed
w:reset()
local index = 0
local count = 0
for _ in pairs(objects) do
count = count + 1
end
for i, o in ipairs(objects) do
index = index + 1
local ib, cb, tb, cbm, bgb, tbm, ibm, tt, l, ll
ib = wibox.widget.imagebox()
tb = wibox.widget.textbox()
cb = wibox.container.margin(wibox.widget.imagebox(ICON_DIR .. "close.svg"), dpi(9), dpi(9), dpi(9), dpi(9))
cb.shape = gears.shape.circle
cbm = wibox.container.margin(cb, dpi(0), dpi(0), dpi(0), dpi(0)) -- 4, 8 ,12 ,12 -- close button
cbm:buttons(gears.table.join(awful.button({}, 1, nil,
function()
o.kill(o)
end
)))
bgb = wibox.container.background()
tbm = wibox.container.margin(tb, dpi(4), dpi(4))
ibm = wibox.container.margin(ib, dpi(5), dpi(5), dpi(5), dpi(5)) -- 12 is default top and bottom margin --app icon
l = wibox.layout.fixed.horizontal()
ll = wibox.layout.fixed.horizontal()
-- All of this is added in a fixed widget
l:fill_space(true)
l:add(ibm)
l:add(tbm)
ll:add(l)
ll:add(cbm)
-- All of this is added in a fixed widget
l:fill_space(true)
l:add(ibm)
l:add(tbm)
ll:add(l)
ll:add(cbm)
if (index % 2 == 0) then
local end_color = (count == index or objects[index+1].minimized) and "#12151c" or theme.top_panel_powerline
local main_color = o.minimized and "#12151c" or theme.bg_normal
bgb:set_widget(pl(ll, main_color, end_color, true))
else
local end_color = (count == index or objects[index+1].minimized) and "#12151c" or theme.bg_normal
local main_color = o.minimized and "#12151c" or theme.top_panel_powerline
bgb:set_widget(pl(ll, main_color, end_color, true))
end
if (index % 2 == 0) then
local end_color = (count == index or objects[index+1].minimized) and "#12151c" or theme.top_panel_powerline
local main_color = o.minimized and "#12151c" or theme.bg_normal
bgb:set_widget(pl(ll, main_color, end_color, true))
else
local end_color = (count == index or objects[index+1].minimized) and "#12151c" or theme.bg_normal
local main_color = o.minimized and "#12151c" or theme.top_panel_powerline
bgb:set_widget(pl(ll, main_color, end_color, true))
end
l:buttons(create_buttons(buttons, o))
l:buttons(create_buttons(buttons, o))
-- Tooltip to display whole title, if it was truncated
tt = awful.tooltip({
objects = {tb},
mode = 'outside',
align = 'bottom',
delay_show = 1,
})
-- Tooltip to display whole title, if it was truncated
tt = awful.tooltip({
objects = {tb},
mode = 'outside',
align = 'bottom',
delay_show = 1,
})
local text, bg, bg_image, icon, args = label(o, tb)
args = args or {}
local text, bg, bg_image, icon, args = label(o, tb)
args = args or {}
-- The text might be invalid, so use pcall.
if text == nil or text == '' then
tbm:set_margins(0)
else
-- truncate when title is too long
local text_only = text:match('>(.*)<')
if (text_only:len() > 25) then
text = text:gsub('>(.*)<', '>' .. utf8.char(utf8.codepoint(text_only, 1, 25)) .. '...<')
tt:set_text(text)
tt:add_to_object(tb)
else
tt:remove_from_object(tb)
end
if not tb:set_markup_silently(text) then
tb:set_markup('<i>&lt;Invalid text&gt;</i>')
end
end
-- bgb:set_bg(bg)
if type(bg_image) == 'function' then
-- TODO: Why does this pass nil as an argument?
bg_image = bg_image(tb, o, nil, objects, i)
end
-- bgb:set_bgimage(bg_image)
if icon then
ib.image = icon
else
ibm:set_margins(0)
end
-- The text might be invalid, so use pcall.
if text == nil or text == '' then
tbm:set_margins(0)
else
-- truncate when title is too long
local text_only = text:match('>(.*)<')
if (text_only:len() > 25) then
text = text:gsub('>(.*)<', '>' .. utf8.char(utf8.codepoint(text_only, 1, 25)) .. '...<')
tt:set_text(text)
tt:add_to_object(tb)
else
tt:remove_from_object(tb)
end
if not tb:set_markup_silently(text) then
tb:set_markup('<i>&lt;Invalid text&gt;</i>')
end
end
-- bgb:set_bg(bg)
if type(bg_image) == 'function' then
-- TODO: Why does this pass nil as an argument?
bg_image = bg_image(tb, o, nil, objects, i)
end
-- bgb:set_bgimage(bg_image)
if icon then
ib.image = icon
else
ibm:set_margins(0)
end
bgb.shape = args.shape
bgb.shape_border_width = args.shape_border_width
bgb.shape_border_color = args.shape_border_color
bgb.shape = args.shape
bgb.shape_border_width = args.shape_border_width
bgb.shape_border_color = args.shape_border_color
w:add(bgb)
end
w:add(bgb)
end
end
@ -152,67 +152,67 @@ end
local tasklist_buttons = awful.util.table.join(
awful.button({}, 1,
function(c)
if c == client.focus then
c.minimized = true
else
-- Without this, the following
-- :isvisible() makes no sense
c.minimized = false
if not c:isvisible() and c.first_tag then
c.first_tag:view_only()
end
-- This will also un-minimize
-- the client, if needed
client.focus = c
c:raise()
end
end
),
awful.button({}, 2,
function(c)
c.kill(c)
end
),
awful.button({}, 4,
function()
awful.client.focus.byidx(1)
end
),
awful.button({}, 5,
function()
awful.client.focus.byidx(-1)
end
)
awful.button({}, 1,
function(c)
if c == client.focus then
c.minimized = true
else
-- Without this, the following
-- :isvisible() makes no sense
c.minimized = false
if not c:isvisible() and c.first_tag then
c.first_tag:view_only()
end
-- This will also un-minimize
-- the client, if needed
client.focus = c
c:raise()
end
end
),
awful.button({}, 2,
function(c)
c.kill(c)
end
),
awful.button({}, 4,
function()
awful.client.focus.byidx(1)
end
),
awful.button({}, 5,
function()
awful.client.focus.byidx(-1)
end
)
)
local filter = function(c, _)
local tags = c.screen.tags
for _, t in ipairs(tags) do
if t.selected then
local ctags = c:tags()
for _, v in ipairs(ctags) do
if v == t then
return true
local tags = c.screen.tags
for _, t in ipairs(tags) do
if t.selected then
local ctags = c:tags()
for _, v in ipairs(ctags) do
if v == t then
return true
end
end
end
end
end
return false
end
end
return false
end
task_list.create = function(s)
return awful.widget.tasklist(
s,
filter,
tasklist_buttons,
{},
list_update,
wibox.layout.fixed.horizontal()
)
return awful.widget.tasklist(
s,
filter,
tasklist_buttons,
{},
list_update,
wibox.layout.fixed.horizontal()
)
end
return task_list