[英]How can I have just only icons of apps in tasklist in Awesome wm ver 3.5?
[英]Awesome WM 3.5 seperate config files
我不確定在這里問這個問題是否可以,所以請告訴我是否不是:)。 我不知道還有什么要問的。
我對真棒WM有問題。 我嘗試將rc.lua分成不同的文件(因為開始時很長),然后將它們加載到rc.lua中。
我具有更改xrandr布局的功能。 直接插入rc.lua時,此代碼可以正常工作。
-- Xrandr settings switcher --
-- Get active outputs
local function outputs()
local outputs = {}
local xrandr = io.popen("xrandr -q")
if xrandr then
for line in xrandr:lines() do
output = line:match("^([%w-]+) connected ")
if output then
outputs[#outputs + 1] = output
end
end
xrandr:close()
end
return outputs
end
local function arrange(out)
-- We need to enumerate all the way to combinate output. We assume
-- we want only an horizontal layout.
local choices = {}
local previous = { {} }
for i = 1, #out do
-- Find all permutation of length `i`: we take the permutation
-- of length `i-1` and for each of them, we create new
-- permutations by adding each output at the end of it if it is
-- not already present.
local new = {}
for _, p in pairs(previous) do
for _, o in pairs(out) do
if not awful.util.table.hasitem(p, o) then
new[#new + 1] = awful.util.table.join(p, {o})
end
end
end
choices = awful.util.table.join(choices, new)
previous = new
end
return choices
end
-- Build available choices
local function menu()
local menu = {}
local out = outputs()
local choices = arrange(out)
for _, choice in pairs(choices) do
local cmd = "xrandr"
-- Enabled outputs
for i, o in pairs(choice) do
cmd = cmd .. " --output " .. o .. " --auto"
if i > 1 then
cmd = cmd .. " --right-of " .. choice[i-1]
end
end
-- Disabled outputs
for _, o in pairs(out) do
if not awful.util.table.hasitem(choice, o) then
cmd = cmd .. " --output " .. o .. " --off"
end
end
local label = ""
if #choice == 1 then
label = 'Only <span weight="bold">' .. choice[1] .. '</span>'
else
for i, o in pairs(choice) do
if i > 1 then label = label .. " + " end
label = label .. '<span weight="bold">' .. o .. '</span>'
end
end
menu[#menu + 1] = { label,
cmd,
"/usr/share/icons/Tango/32x32/devices/display.png"}
end
return menu
end
-- Display xrandr notifications from choices
local state = { iterator = nil,
timer = nil,
cid = nil }
local function xrandr()
-- Stop any previous timer
if state.timer then
state.timer:stop()
state.timer = nil
end
-- Build the list of choices
if not state.iterator then
state.iterator = awful.util.table.iterate(menu(),
function() return true end)
end
-- Select one and display the appropriate notification
local next = state.iterator()
local label, action, icon
if not next then
label, icon = "Keep the current configuration", "/usr/share/icons/Tango/32x32/devices/display.png"
state.iterator = nil
else
label, action, icon = unpack(next)
end
state.cid = naughty.notify({ text = label,
icon = icon,
timeout = 4,
screen = mouse.screen, -- Important, not all screens may be visible
font = "Free Sans 18",
replaces_id = state.cid }).id
-- Setup the timer
state.timer = timer { timeout = 4 }
state.timer:connect_signal("timeout",
function()
state.timer:stop()
state.timer = nil
state.iterator = nil
if action then
awful.util.spawn(action, false)
end
end)
state.timer:start()
end
我將其另存為xrandr.lua並將其粘貼到文件夾awesome / rc中。
然后我在rc.lua中具有從“ rc”文件夾( 從此處 )加載文件的功能:
function loadrc(name, mod)
local success
local result
-- Which file? In rc/ or in lib/?
local path = awful.util.getdir("config") .. "/" ..
(mod and "lib" or "rc") ..
"/" .. name .. ".lua"
-- If the module is already loaded, don't load it again
if mod and package.loaded[mod] then return package.loaded[mod] end
-- Execute the RC/module file
success, result = pcall(function() return dofile(path) end)
if not success then
naughty.notify({ title = "Error while loading an RC file",
text = "When loading `" .. name ..
"`, got the following error:\n" .. result,
preset = naughty.config.presets.critical
})
return print("E: error loading RC file '" .. name .. "': " .. result)
end
-- Is it a module?
if mod then
return package.loaded[mod]
end
return result
end
然后我將'loadrc(“ xrandr”)'粘貼到我的rc.lua中,但是沒有任何反應。 我嘗試了不同的文件(例如,簡單的小部件,然后將這個小部件文件loadrc),但我得到的只是錯誤包,它不起作用。
我也嘗試過:“ require(” xrandr“)”但還是一樣。
我嘗試過使用google,但是一切都很棒3.4,而且我對Lua代碼不是很有經驗。 感謝幫助
基本上, require("xrandr")
在~/.config/awesome/rc.lua
告訴LUA到處尋找一個名為xrandr.lua
在~/.config/awesome/
而你是將它存儲在~/.config/awesome/rc/
。 這就是為什么它找不到任何東西的原因。 這應該夠了吧:
require("rc.xrandr")
您可以通過其他人的配置來激發自己: rc.lua
基本上,就像envolyse所說的那樣,require(something)將查看rootdir / something.lua,而require(somedir.something)將查看rootdir / somedir / something。
不過,您仍然需要從something.rc進行附加調用(以包含庫):
myrc.lua:
local naughty = require("naughty");
naughty.somecall();
從lua 5.2開始,您將需要在較舊版本的lua上使用局部變量來存儲指向包含的庫的指針lib''require(“ naughty”);' 就足夠了。
駭客入侵。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.