fix: make variables local

This commit is contained in:
Alexander Gehrke 2024-02-06 17:25:23 +01:00
parent 97049a1f75
commit 60bc316c26
10 changed files with 52 additions and 54 deletions

View file

@ -1,6 +1,6 @@
local naughty = require("naughty") local naughty = require("naughty")
actions = {} local actions = {}
function actions.toggle_naughty() function actions.toggle_naughty()
if naughty.is_suspended() then if naughty.is_suspended() then

View file

@ -1,6 +1,6 @@
-- change color of wibars on numlock/capslock/scrolllock -- change color of wibars on numlock/capslock/scrolllock
-- --
require("beautiful") local beautiful = require("beautiful")
local lockhl = { bg_lock = beautiful.bg_urgent, bg_normal = beautiful.bg_normal } local lockhl = { bg_lock = beautiful.bg_urgent, bg_normal = beautiful.bg_normal }
local target_wibars = {} local target_wibars = {}

View file

@ -1,12 +1,9 @@
-- MPD control and playlist editing -- MPD control and playlist editing
-- prompts require dmpc script -- prompts require dmpc script
local M = {} local M = {}
local conf = conf local conf = require("localconf")
local awful = awful local log = require("talkative")
local log = log local naughty = require("naughty")
-- local functions
local dmenu, notify, mpc
local defaults = {} local defaults = {}
local settings = {} local settings = {}

View file

@ -6,12 +6,11 @@ local actions = require("actions")
local modkey = conf.modkey or "Mod4" local modkey = conf.modkey or "Mod4"
local hyper = {"Ctrl", "Shift", "Mod1", "Mod4"} local hyper = {"Ctrl", "Shift", "Mod1", "Mod4"}
local binder = binder or require("separable.binder") local binder = require("separable.binder")
local mb = binder.modal local mb = binder.modal
local mpd = require("mpd") local mpd = require("mpd")
local handy = require("handy") local handy = require("handy")
local myglobalkeys = {}
local wibars = {} local wibars = {}
for s in screen do for s in screen do
@ -133,7 +132,7 @@ local myglobalkeys = awful.util.table.join(
awful.key({ modkey }, "m", function() awful.key({ modkey }, "m", function()
awful.spawn.easy_async_with_shell( awful.spawn.easy_async_with_shell(
"which playerctl && " .. playerctl .. " status", "which playerctl && " .. playerctl .. " status",
function(stdout, stderr, reason, exitcode) function(_, _, _, exitcode)
if exitcode > 0 then if exitcode > 0 then
mb.grab{keymap=mpdmap, name="MPD", stay_in_mode=true} mb.grab{keymap=mpdmap, name="MPD", stay_in_mode=true}
else else

View file

@ -3,7 +3,8 @@ awful.rules = require("awful.rules")
local localconf = require("localconf") local localconf = require("localconf")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local binder = binder or require("separable.binder") local naughty = require("naughty")
local binder = require("separable.binder")
local log = require("talkative") local log = require("talkative")
-- create a notification when given client becomes urgent -- create a notification when given client becomes urgent

View file

@ -1,7 +1,7 @@
-- key bindings -- key bindings
local awful = require("awful") local awful = require("awful")
local beautiful = require("beautiful") local naughty = require("naughty")
local conf = require("localconf")
local modkey = conf.modkey or "Mod4" local modkey = conf.modkey or "Mod4"
local mb = require("modalbind") local mb = require("modalbind")
mb.init() mb.init()
@ -9,7 +9,7 @@ mb.init()
local globalkeys = {} local globalkeys = {}
local globalkeyfuncs = {} local globalkeyfuncs = {}
app_folders = { local app_folders = {
"/usr/share/applications", "/usr/share/applications",
"/usr/local/share/applications", "/usr/local/share/applications",
(os.getenv("XDG_DATA_HOME") or os.getenv("HOME") .. "/.local/share") .. "/applications", (os.getenv("XDG_DATA_HOME") or os.getenv("HOME") .. "/.local/share") .. "/applications",
@ -27,7 +27,7 @@ binder.spawn = spawnf
conf.cmd.run = conf.cmd.run or spawnf("dmenu_run") conf.cmd.run = conf.cmd.run or spawnf("dmenu_run")
local function use_layout(layout) return function() awful.layout.set(layout) end end local function use_layout(layout) return function() awful.layout.set(layout) end end
layoutmap = { local layoutmap = {
{"f", use_layout(awful.layout.suit.fair), "Fair" }, {"f", use_layout(awful.layout.suit.fair), "Fair" },
{"h", use_layout(awful.layout.suit.fair.horizontal), "Fair Horizontal" }, {"h", use_layout(awful.layout.suit.fair.horizontal), "Fair Horizontal" },
{"t", use_layout(awful.layout.suit.tile), "Tile" }, {"t", use_layout(awful.layout.suit.tile), "Tile" },
@ -37,7 +37,7 @@ layoutmap = {
{"space", use_layout(awful.layout.suit.floating), "Float" } {"space", use_layout(awful.layout.suit.floating), "Float" }
} }
layoutsettings = { local layoutsettings = {
{"h", function () awful.tag.incmwfact(-0.05) end, "Master smaller" }, {"h", function () awful.tag.incmwfact(-0.05) end, "Master smaller" },
{"l", function () awful.tag.incmwfact( 0.05) end, "Master bigger" }, {"l", function () awful.tag.incmwfact( 0.05) end, "Master bigger" },
{"H", function () awful.tag.incnmaster( 1) end, "More masters" }, {"H", function () awful.tag.incnmaster( 1) end, "More masters" },
@ -46,20 +46,6 @@ layoutsettings = {
{"C", function () awful.tag.incncol(-1) end, "Less columns" }, {"C", function () awful.tag.incncol(-1) end, "Less columns" },
} }
local function screen_focus_wrapdir(dir)
return function()
local target = screen_in_wrapdir(dir)
awful.screen.focus(target)
end
end
local function screen_move_client_wrapdir(dir)
return function(c)
local target = screen_in_wrapdir(dir)
awful.client.movetoscreen(c, target)
end
end
local opposite_dirs = { local opposite_dirs = {
left = "right", left = "right",
right = "left", right = "left",
@ -67,7 +53,7 @@ local opposite_dirs = {
down = "up" down = "up"
} }
function screen_in_wrapdir(dir, _screen) local function screen_in_wrapdir(dir, _screen)
local sel = _screen or mouse.screen local sel = _screen or mouse.screen
if sel then if sel then
local geomtbl = {} local geomtbl = {}
@ -87,6 +73,21 @@ function screen_in_wrapdir(dir, _screen)
end end
end end
local function screen_focus_wrapdir(dir)
return function()
local target = screen_in_wrapdir(dir)
awful.screen.focus(target)
end
end
local function screen_move_client_wrapdir(dir)
return function(c)
local target = screen_in_wrapdir(dir)
awful.client.movetoscreen(c, target)
end
end
function binder.add_bindings(keys) function binder.add_bindings(keys)
globalkeys = awful.util.table.join(globalkeys, keys); globalkeys = awful.util.table.join(globalkeys, keys);
return binder return binder
@ -105,7 +106,7 @@ end
function binder.apply() function binder.apply()
naughty.notify { text="Reloading key bindings" } naughty.notify { text="Reloading key bindings" }
local allkeys = awful.util.table.clone(globalkeys) local allkeys = awful.util.table.clone(globalkeys)
for k,v in pairs(globalkeyfuncs) do for _,v in pairs(globalkeyfuncs) do
local loadedkeys = v() local loadedkeys = v()
allkeys = awful.util.table.join(allkeys, loadedkeys) allkeys = awful.util.table.join(allkeys, loadedkeys)
end end

View file

@ -1,5 +1,5 @@
local awful = require("awful") local awful = require("awful")
local beautiful = beautiful local beautiful = require("beautiful")
client.connect_signal("manage", function (c) client.connect_signal("manage", function (c)

View file

@ -1,6 +1,6 @@
-- tags -- tags
local awful = require("awful") local awful = require("awful")
local conf = conf local conf = require("localconf")
local modkey = conf.modkey or "Mod4" local modkey = conf.modkey or "Mod4"
local tags={} local tags={}
@ -80,7 +80,7 @@ local tagdef = {
{"F4", { layout = awful.layout.suit.max }}, {"F4", { layout = awful.layout.suit.max }},
} }
function defaultlayout(s) local function defaultlayout(s)
if s.geometry.width > s.geometry.height then if s.geometry.width > s.geometry.height then
return awful.layout.suit.fair return awful.layout.suit.fair
else else
@ -102,6 +102,7 @@ end
function tags.create_bindings() function tags.create_bindings()
local tagkeys = {} local tagkeys = {}
local k
-- Bind all number keys and F-keys to tags -- Bind all number keys and F-keys to tags
for i = 1, 21 do for i = 1, 21 do
@ -109,7 +110,7 @@ function tags.create_bindings()
k = "#" .. i + 9 -- number keys 1-9 k = "#" .. i + 9 -- number keys 1-9
elseif i == 10 then elseif i == 10 then
k = "#19" -- zero k = "#19" -- zero
elseif i > 10 then else --if i > 10 then
k = "F" .. i - 10 -- F keys k = "F" .. i - 10 -- F keys
end end
tagkeys = awful.util.table.join(tagkeys, tagkeys = awful.util.table.join(tagkeys,

View file

@ -1,7 +1,7 @@
-- {{{ Main -- {{{ Main
local awful = require("awful") local awful = require("awful")
theme = {} local theme = {}
theme.wallpaper = "~/.wallpaper" theme.wallpaper = "~/.wallpaper"
theme.icon_theme = "Adwaita" theme.icon_theme = "Adwaita"

View file

@ -1,11 +1,11 @@
local wibox = require("wibox") local wibox = require("wibox")
local vicious = require("vicious") local vicious = require("vicious")
local naughty = require("naughty") local conf = require("localconf")
local modkey = conf.modkey or "Mod4" local modkey = conf.modkey or "Mod4"
local awful = require("awful") local awful = require("awful")
local tag = require("awful.tag")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local widgets = { add = {} } local widgets = { add = {} }
local gears = require("gears")
local wlist = {} local wlist = {}
@ -27,15 +27,8 @@ local function percentage_overlay(p, color, prefix, suffix)
end end
function widgets.setup(s) local function add_bar(s, position, direction, first, second)
return { local newbar = awful.wibar({
left = function(bottom, top) s.leftwibar = add_bar(s, "left", "east", bottom, top) end,
right = function(top, bottom) s.rightwibar = add_bar(s, "right", "west", top, bottom) end
}
end
function add_bar(s, position, direction, first, second)
newbar = awful.wibar({
position = position, position = position,
screen = s, screen = s,
opacity = 0.6, opacity = 0.6,
@ -55,6 +48,12 @@ function add_bar(s, position, direction, first, second)
return newbar return newbar
end end
function widgets.setup(s)
return {
left = function(bottom, top) s.leftwibar = add_bar(s, "left", "east", bottom, top) end,
right = function(top, bottom) s.rightwibar = add_bar(s, "right", "west", top, bottom) end
}
end
function widgets.mail(mailboxes, notify_pos, title) function widgets.mail(mailboxes, notify_pos, title)
local widget = wibox.widget.textbox() local widget = wibox.widget.textbox()
@ -179,7 +178,7 @@ local function bar_with_overlay(fg, bg, width, height)
progress.overlay = wibox.widget { progress.overlay = wibox.widget {
font = beautiful.fontface and (beautiful.fontface .. " " .. 7) or beautiful.font, font = beautiful.fontface and (beautiful.fontface .. " " .. 7) or beautiful.font,
align = center, align = 'center',
widget = wibox.widget.textbox widget = wibox.widget.textbox
} }
@ -192,14 +191,14 @@ end
-- battery -- battery
function widgets.battery(s) function widgets.battery(s)
bat1 = bar_with_overlay(beautiful.fg_focus, beautiful.bg_focus, 100, math.floor(s.dpi / 10)) local bat1 = bar_with_overlay(beautiful.fg_focus, beautiful.bg_focus, 100, math.floor(s.dpi / 10))
combined_bats = graph_label( local combined_bats = graph_label(
bat1, bat1,
"BAT" "BAT"
) )
callback = function (widget, args) local callback = function (widget, args)
if args[2] == 0 then if args[2] == 0 then
combined_bats:set_visible(false) combined_bats:set_visible(false)
return "" return ""
@ -279,7 +278,7 @@ function widgets.dynamic_taskbar(s, signal, when)
widget = s.mytasklist widget = s.mytasklist
}) })
condition = when or function(s) return awful.layout.get(s).name == "max" end local condition = when or function(s) return awful.layout.get(s).name == "max" end
s:connect_signal(signal or "tag::history::update", function() s:connect_signal(signal or "tag::history::update", function()
s.taskbar.visible = condition(s) s.taskbar.visible = condition(s)
end) end)