2017-04-13 131 views
2

我有几个壁纸和每个主题/调色板,我试图找到一种方法来分配键盘快捷方式将主题从一个更改为另一个。以编程方式更改awesomewm主题

我没有问题设置每个单独的主题,但不能为我的生活想出一个方法来设置主题,一旦awesomewm已经开始运行,而不杀死当前的实例,然后制作一个新的。

我认为一旦主题被分配和awesomewm已instantiated价值观是固定的,如果是这样的话,我不认为这是可能的。

有没有人有任何想法?

回答

0

我认为可能的方法之一是在主题更改后重新创建所有小部件。不知道整个代码,但这里是快速的例子,如何通过hotkey重建面板为真棒v4.0。

一些修改为第一

local function build_panel(s) 
    -- destroy old panel 
    if s.mywibox then s.mywibox:remove() end 

    -- create a promptbox for given screen 
    s.mypromptbox = awful.widget.prompt() 

    -- create a layoutbox for given screen 
    s.mylayoutbox = awful.widget.layoutbox(s) 
    s.mylayoutbox: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)) 
    ) 
    -- create a taglist widget 
    s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons) 

    -- create a tasklist widget 
    s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons) 

    -- create panel wibox 
    s.mywibox = awful.wibar({ position = "top", screen = s }) 

    -- add widgets to the panel wibox 
    s.mywibox:setup { 
     layout = wibox.layout.align.horizontal, 
     { layout = wibox.layout.fixed.horizontal, mylauncher, s.mytaglist, s.mypromptbox }, 
     s.mytasklist, 
     { layout = wibox.layout.fixed.horizontal, mykeyboardlayout, wibox.widget.systray(), mytextclock, s.mylayoutbox }, 
    } 
end 

awful.screen.connect_for_each_screen(function(s) 
    -- wallpaper 
    set_wallpaper(s) 

    -- tags 
    awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1]) 

    -- panel setup 
    build_panel(s) 
end) 

屏幕构建功能并添加动作globalkeys

awful.key(
    { modkey }, "z", 
    function() 
     -- change theme settings 
     beautiful.bg_normal = "#ff2020" 
     beautiful.fg_normal = "#2020ff" 
     -- rebuild panel widgets 
     build_panel(mouse.screen) 
    end, 
    {description="theme colors change", group="awesome"} 
), 
+0

,另外修复了客户端等边框颜色... –

相关问题