Initial commit
This commit is contained in:
		
							
								
								
									
										33
									
								
								src/client/client_keys.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								src/client/client_keys.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,33 @@
 | 
			
		||||
local gears = require('gears')
 | 
			
		||||
local awful = require('awful')
 | 
			
		||||
local naughty = require('naughty')
 | 
			
		||||
local globals = require('src.globals')
 | 
			
		||||
local constrain = require('libconstrain')
 | 
			
		||||
 | 
			
		||||
local modkey = globals.modkey
 | 
			
		||||
local altkey = globals.altkey
 | 
			
		||||
 | 
			
		||||
local keys = gears.table.join(
 | 
			
		||||
    awful.key({ modkey }, 'f', function(c) c.fullscreen = not c.fullscreen c:raise() end, { description = 'toggle fullscreen', group = 'client' }),
 | 
			
		||||
    awful.key({ modkey, 'Shift' }, 'c', function(c) c:kill() end, { description = 'close', group = 'client' }),
 | 
			
		||||
    awful.key({ modkey, 'Shift', 'Control', altkey }, 'c', function(c) awesome.kill(c.pid, awesome.unix_signal['SIGKILL']) c:kill() end, { description = 'send sigkill', group = 'client' }),
 | 
			
		||||
    awful.key({ modkey, 'Control' }, 'space', awful.client.floating.toggle, { description = 'toggle floating', group = 'client' }),
 | 
			
		||||
    awful.key({ modkey }, 'o', function(c) c:move_to_screen() end, { description = 'move to next screen', group = 'client' }),
 | 
			
		||||
    awful.key({ modkey }, 't', function(c) c.ontop = not c.ontop end, { description = 'toggle keep on top', group = 'client' }),
 | 
			
		||||
    awful.key({ modkey }, 'n', function(c) c.minimized = true end, { description = 'minimize', group = 'client' }),
 | 
			
		||||
    awful.key({ modkey }, 'm', function(c) c.maximized = not c.maximized c:raise() end, { description = '(un)maximize', group = 'client' }),
 | 
			
		||||
    awful.key({ modkey, 'Control' }, 's', function(c) awful.titlebar.toggle(c) c:raise() end, { description = 'toggle titlebar', group = 'client' }),
 | 
			
		||||
    awful.key({ modkey, 'Control' }, 'F10', function(c) naughty.notify({ text = constrain.toggle(c), timeout = 3 }) end, { description = 'toggle mouse constrain', group = 'client' })
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
local buttons = gears.table.join(
 | 
			
		||||
    awful.button({}, 1, function(c) c:emit_signal('request::activate', 'mouse_click', { raise = true }) end),
 | 
			
		||||
    awful.button({ modkey }, 1, function(c) c:emit_signal('request::activate', 'mouse_click', { raise = true }) awful.mouse.client.move(c) end),
 | 
			
		||||
    awful.button({ modkey }, 3, function(c) c:emit_signal('request::activate', 'mouse_click', { raise = true }) awful.mouse.client.resize(c) end)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
    keys = keys,
 | 
			
		||||
    buttons = buttons
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										51
									
								
								src/client/init.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/client/init.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
			
		||||
local awful = require('awful')
 | 
			
		||||
local beautiful = require('beautiful')
 | 
			
		||||
local gears = require('gears')
 | 
			
		||||
local wibox = require('wibox')
 | 
			
		||||
 | 
			
		||||
require('src.client.rules')
 | 
			
		||||
 | 
			
		||||
-- New client
 | 
			
		||||
client.connect_signal('manage', function(c)
 | 
			
		||||
	if awesome.startup and not c.size_hints.user_position and not c.size_hints.program_position then
 | 
			
		||||
		awful.placement.no_offscreen(c)
 | 
			
		||||
	end
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
client.connect_signal('request::titlebars', function(c)
 | 
			
		||||
	local buttons = gears.table.join(
 | 
			
		||||
		awful.button({}, 1, function() c:emit_signal('request::activate', 'titlebar', { raise = true }) awful.mouse.client.move(c) end),
 | 
			
		||||
		awful.button({}, 2, function() c:kill() end),
 | 
			
		||||
		awful.button({}, 3, function() c:emit_signal('request::activate', 'titlebar', { raise = true }) awful.mouse.client.resize(c) end)
 | 
			
		||||
	)
 | 
			
		||||
 | 
			
		||||
	awful.titlebar(c, { size = 16 }):setup({
 | 
			
		||||
		{ -- Left
 | 
			
		||||
			awful.titlebar.widget.iconwidget(c),
 | 
			
		||||
			buttons = buttons,
 | 
			
		||||
			layout = wibox.layout.fixed.horizontal,
 | 
			
		||||
		},
 | 
			
		||||
		{ -- Middle
 | 
			
		||||
			{ -- Title
 | 
			
		||||
				align = 'center',
 | 
			
		||||
				widget = awful.titlebar.widget.titlewidget(c),
 | 
			
		||||
			},
 | 
			
		||||
			buttons = buttons,
 | 
			
		||||
			layout = wibox.layout.flex.horizontal,
 | 
			
		||||
		},
 | 
			
		||||
		{ -- Right
 | 
			
		||||
			awful.titlebar.widget.floatingbutton(c),
 | 
			
		||||
			awful.titlebar.widget.maximizedbutton(c),
 | 
			
		||||
			awful.titlebar.widget.stickybutton(c),
 | 
			
		||||
			awful.titlebar.widget.ontopbutton(c),
 | 
			
		||||
			awful.titlebar.widget.closebutton(c),
 | 
			
		||||
			layout = wibox.layout.fixed.horizontal(),
 | 
			
		||||
		},
 | 
			
		||||
		layout = wibox.layout.align.horizontal,
 | 
			
		||||
	})
 | 
			
		||||
	awful.titlebar.hide(c)
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
client.connect_signal('mouse::enter', function(c) c:emit_signal('request::activate', 'mouse_enter', { raise = false }) end)
 | 
			
		||||
client.connect_signal('focus', function(c) c.border_color = beautiful.border_focus end)
 | 
			
		||||
client.connect_signal('unfocus', function(c) c.border_color = beautiful.border_normal end)
 | 
			
		||||
							
								
								
									
										51
									
								
								src/client/rules.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								src/client/rules.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
			
		||||
local awful = require('awful')
 | 
			
		||||
local beautiful = require('beautiful')
 | 
			
		||||
local rules = require('ruled.client')
 | 
			
		||||
local cb = require('src.client.client_keys')
 | 
			
		||||
 | 
			
		||||
rules.append_rules({
 | 
			
		||||
    {
 | 
			
		||||
        rule = {},
 | 
			
		||||
        properties = {
 | 
			
		||||
            border_width = beautiful.border_width,
 | 
			
		||||
            border_color = beautiful.border_normal,
 | 
			
		||||
            callback = awful.client.setslave,
 | 
			
		||||
            focus = awful.client.focus.filter,
 | 
			
		||||
            raise = true,
 | 
			
		||||
            keys = cb.keys,
 | 
			
		||||
            buttons = cb.buttons,
 | 
			
		||||
            screen = awful.screen.preferred,
 | 
			
		||||
            placement = awful.placement.no_overlap + awful.placement.no_offscreen,
 | 
			
		||||
            size_hints_honor = false,
 | 
			
		||||
            no_border = false,
 | 
			
		||||
            titlebars_enabled = false
 | 
			
		||||
        }
 | 
			
		||||
    }, {
 | 
			
		||||
        rule_any = {
 | 
			
		||||
            class = { 'Tor Browser' },
 | 
			
		||||
            name = { 'Event Tester' },
 | 
			
		||||
            role = {
 | 
			
		||||
                'AlarmWindow',
 | 
			
		||||
                'ConfigManager',
 | 
			
		||||
                'pop-up'
 | 
			
		||||
            }
 | 
			
		||||
        },
 | 
			
		||||
        properties = { floating = true }
 | 
			
		||||
    }, {
 | 
			
		||||
        rule_any = { class = { 'firefox', 'factorio', 'Blender' } },
 | 
			
		||||
        properties = { opacity = 1, maximized = false, floating = false },
 | 
			
		||||
    }, {
 | 
			
		||||
        rule = { class = 'mpv' },
 | 
			
		||||
        properties = { fullscreen = true },
 | 
			
		||||
    }, {
 | 
			
		||||
        rule = { class = 'supcom-fa' },
 | 
			
		||||
        properties = {
 | 
			
		||||
            floating = true,
 | 
			
		||||
            border_width = 0,
 | 
			
		||||
            x = 0,
 | 
			
		||||
            y = 1080,
 | 
			
		||||
            no_border = true,
 | 
			
		||||
        }
 | 
			
		||||
    },
 | 
			
		||||
    { rule_any = { type = { 'normal', 'dialog' } }, properties = { titlebars_enabled = true } },
 | 
			
		||||
})
 | 
			
		||||
							
								
								
									
										136
									
								
								src/global_keys.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								src/global_keys.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,136 @@
 | 
			
		||||
local gears = require('gears')
 | 
			
		||||
local awful = require('awful')
 | 
			
		||||
local lain = require('lain')
 | 
			
		||||
local hotkeys_popup = require('awful.hotkeys_popup')
 | 
			
		||||
local globals = require('src.globals')
 | 
			
		||||
 | 
			
		||||
local modkey = globals.modkey
 | 
			
		||||
local altkey = globals.altkey
 | 
			
		||||
 | 
			
		||||
local mpris = require('src.util.mpris')
 | 
			
		||||
local volume = require('src.util.volume')
 | 
			
		||||
 | 
			
		||||
local quake_terminal_name = 'QuakeTerminal'
 | 
			
		||||
local quake = lain.util.quake({
 | 
			
		||||
	followtag = true,
 | 
			
		||||
	overlap = true,
 | 
			
		||||
 | 
			
		||||
	app = globals.terminal,
 | 
			
		||||
	argname = '-t ' .. quake_terminal_name,
 | 
			
		||||
	name = quake_terminal_name,
 | 
			
		||||
	extra = '--class ' .. quake_terminal_name,
 | 
			
		||||
 | 
			
		||||
	vert = 'center',
 | 
			
		||||
	horiz = 'center',
 | 
			
		||||
	height = 0.6,
 | 
			
		||||
	width = 0.6
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
local function focus_bydirection(direction)
 | 
			
		||||
	awful.client.focus.global_bydirection(direction)
 | 
			
		||||
	if client.focus then
 | 
			
		||||
		client.focus:raise()
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local globalkeys = gears.table.join(
 | 
			
		||||
	---- HOTKEYS ----
 | 
			
		||||
	awful.key({ modkey, altkey }, 'p', function() awful.spawn('flameshot gui') end, { description = 'screenshot', group = 'hotkeys' }),
 | 
			
		||||
	awful.key({ modkey, altkey, 'Control' }, 'l', function() awful.spawn('dm-tool lock') end, { description = 'lock', group = 'hotkeys' }),
 | 
			
		||||
	awful.key({ modkey }, 's', hotkeys_popup.show_help),
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	---- TAG ----
 | 
			
		||||
	-- NAVIGATION
 | 
			
		||||
	awful.key({ modkey }, 'Left', awful.tag.viewprev, { description = 'view previous', group = 'tag' }),
 | 
			
		||||
	awful.key({ modkey }, 'Right', awful.tag.viewnext, { description = 'view next', group = 'tag' }),
 | 
			
		||||
 | 
			
		||||
	awful.key({ altkey }, 'Left', function() lain.util.tag_view_nonempty(-1) end, { description = 'view previous nonempty', group = 'tag' }),
 | 
			
		||||
	awful.key({ altkey }, 'Right', function() lain.util.tag_view_nonempty(1) end, { description = 'view next nonempty', group = 'tag' }),
 | 
			
		||||
 | 
			
		||||
	-- CREATE/MOVE/DELETE
 | 
			
		||||
	awful.key({ modkey, 'Shift' }, 'n', function() lain.util.add_tag() end, { description = 'add new tag', group = 'tag' }),
 | 
			
		||||
	awful.key({ modkey, 'Shift' }, 'r', function() lain.util.rename_tag() end, { description = 'rename tag', group = 'tag' }),
 | 
			
		||||
	awful.key({ modkey, 'Shift' }, 'Left', function() lain.util.move_tag(-1) end, { description = 'move tag to the left', group = 'tag' }),
 | 
			
		||||
	awful.key({ modkey, 'Shift' }, 'Right', function() lain.util.move_tag(1) end, { description = 'move tag to the right', group = 'tag' }),
 | 
			
		||||
	awful.key({ modkey, 'Shift' }, 'd', function() lain.util.delete_tag() end, { description = 'delete tag', group = 'tag' }),
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	---- CLIENT ----
 | 
			
		||||
	awful.key({ altkey }, 'j', function() awful.client.focus.byidx(1) end, { description = 'focus next by index', group = 'client' }),
 | 
			
		||||
	awful.key({ altkey }, 'k', function() awful.client.focus.byidx(-1) end, { description = 'focus previous by index', group = 'client' }),
 | 
			
		||||
 | 
			
		||||
	awful.key({ modkey }, 'h', function() focus_bydirection('left') end, { description = 'focus left', group = 'client' }),
 | 
			
		||||
	awful.key({ modkey }, 'j', function() focus_bydirection('down') end, { description = 'focus down', group = 'client' }),
 | 
			
		||||
	awful.key({ modkey }, 'k', function() focus_bydirection('up') end, { description = 'focus up', group = 'client' }),
 | 
			
		||||
	awful.key({ modkey }, 'l', function() focus_bydirection('right') end, { description = 'focus right', group = 'client' }),
 | 
			
		||||
 | 
			
		||||
	awful.key({ modkey }, 'u', awful.client.urgent.jumpto, { description = 'jump to urgent client', group = 'client' }),
 | 
			
		||||
 | 
			
		||||
	awful.key({ modkey, 'Control' }, 'n', function()
 | 
			
		||||
		local c = awful.client.restore()
 | 
			
		||||
		if c then c:emit_signal('request::activate', 'key.unminimize', { raise = true }) end
 | 
			
		||||
	end, { description = 'restore minimized', group = 'client' }),
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	---- AWESOME ----
 | 
			
		||||
	awful.key({ modkey }, 'b', function() for s in screen do s.wibox.visible = not s.wibox.visible end end, { description = 'toggle wibox', group = 'awesome' }),
 | 
			
		||||
 | 
			
		||||
	awful.key({ modkey, 'Control' }, 'r', awesome.restart, { description = 'reload awesome', group = 'awesome' }),
 | 
			
		||||
	awful.key({ modkey, 'Shift', 'Control' }, 'q', awesome.quit, { description = 'quit awesome', group = 'awesome' }),
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	---- PROGRAMS ----
 | 
			
		||||
	awful.key({ modkey }, 'Return', function() awful.spawn(globals.terminal) end, { description = 'open a terminal', group = 'programs' }),
 | 
			
		||||
	awful.key({ modkey, altkey }, 'Return', function() quake:toggle() end, { description = 'Dropdown terminal', group = 'programs' }),
 | 
			
		||||
	awful.key({ modkey }, 'y', function()
 | 
			
		||||
		awful.spawn('rofi -show drun -theme "' .. os.getenv('HOME') .. '/.config/awesome/rofi/launcher.rasi"')
 | 
			
		||||
	end, { description = 'show rofi', group = 'launcher' }),
 | 
			
		||||
	awful.key({ modkey, 'Shift' }, 'y', function()
 | 
			
		||||
		awful.spawn(os.getenv('HOME') .. '/.config/awesome/rofi/launcher_launcher.sh')
 | 
			
		||||
	end, { description = 'show rofi', group = 'launcher' }),
 | 
			
		||||
 | 
			
		||||
	---- LAYOUT ----
 | 
			
		||||
	awful.key({ modkey, altkey }, 'l', function() awful.tag.incmwfact(0.05) end, { description = 'increase master width factor', group = 'layout' }),
 | 
			
		||||
	awful.key({ modkey, altkey }, 'h', function() awful.tag.incmwfact(-0.05) end, { description = 'decrease master width factor', group = 'layout' }),
 | 
			
		||||
	awful.key({ modkey, 'Shift' }, 'h', function() awful.tag.incnmaster(1, nil, true) end, { description = 'increase the number of master clients', group = 'layout' }),
 | 
			
		||||
	awful.key({ modkey, 'Shift' }, 'l', function() awful.tag.incnmaster(-1, nil, true) end, { description = 'decrease the number of master clients', group = 'layout' }),
 | 
			
		||||
	awful.key({ modkey, 'Control' }, 'h', function() awful.tag.incncol(1, nil, true) end, { description = 'increase the number of columns', group = 'layout' }),
 | 
			
		||||
	awful.key({ modkey, 'Control' }, 'l', function() awful.tag.incncol(-1, nil, true) end, { description = 'decrease the number of columns', group = 'layout' }),
 | 
			
		||||
	awful.key({ modkey }, 'space', function() awful.layout.inc(1) end, { description = 'select next', group = 'layout' }),
 | 
			
		||||
	awful.key({ modkey, 'Shift' }, 'space', function() awful.layout.inc(-1) end, { description = 'select previous', group = 'layout' }),
 | 
			
		||||
 | 
			
		||||
	---- AUDIO KEYS ----
 | 
			
		||||
	awful.key({}, "XF86AudioMute", volume.toggle_mute),
 | 
			
		||||
	awful.key({}, "XF86AudioLowerVolume", volume.vol_down),
 | 
			
		||||
	awful.key({}, "XF86AudioRaiseVolume", volume.vol_up),
 | 
			
		||||
	awful.key({ 'Control' }, "XF86AudioMute", mpris.play_pause),
 | 
			
		||||
	awful.key({ 'Control' }, "XF86AudioLowerVolume", mpris.previous),
 | 
			
		||||
	awful.key({ 'Control' }, "XF86AudioRaiseVolume", mpris.skip)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
-- Bind all key numbers to tags.
 | 
			
		||||
for i = 1, 9 do
 | 
			
		||||
	globalkeys = gears.table.join(
 | 
			
		||||
		globalkeys,
 | 
			
		||||
		-- View tag only.
 | 
			
		||||
		awful.key({ modkey }, '#' .. i + 9, function()
 | 
			
		||||
			local screen = awful.screen.focused()
 | 
			
		||||
			local tag = screen.tags[i]
 | 
			
		||||
			if tag then
 | 
			
		||||
				tag:view_only()
 | 
			
		||||
			end
 | 
			
		||||
		end, { description = 'view tag #' .. i, group = 'tag' }),
 | 
			
		||||
		-- Move client to tag.
 | 
			
		||||
		awful.key({ modkey, 'Shift' }, '#' .. i + 9, function()
 | 
			
		||||
			if client.focus then
 | 
			
		||||
				local tag = client.focus.screen.tags[i]
 | 
			
		||||
				if tag then
 | 
			
		||||
					client.focus:move_to_tag(tag)
 | 
			
		||||
				end
 | 
			
		||||
			end
 | 
			
		||||
		end, { description = 'move focused client to tag #' .. i, group = 'tag' })
 | 
			
		||||
	)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
return globalkeys
 | 
			
		||||
							
								
								
									
										7
									
								
								src/globals.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/globals.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
return {
 | 
			
		||||
	modkey = 'Mod4',
 | 
			
		||||
	altkey = 'Mod1',
 | 
			
		||||
	terminal = 'alacritty',
 | 
			
		||||
	cycle_prev = true,
 | 
			
		||||
	editor = 'nvim',
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										19
									
								
								src/layouts.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								src/layouts.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,19 @@
 | 
			
		||||
local awful = require('awful')
 | 
			
		||||
 | 
			
		||||
tag.connect_signal("request::default_layouts", function()
 | 
			
		||||
    awful.layout.append_default_layouts({
 | 
			
		||||
        awful.layout.suit.fair,
 | 
			
		||||
        awful.layout.suit.fair.horizontal,
 | 
			
		||||
        awful.layout.suit.tile,
 | 
			
		||||
        awful.layout.suit.tile.left,
 | 
			
		||||
        awful.layout.suit.tile.bottom,
 | 
			
		||||
        awful.layout.suit.tile.top,
 | 
			
		||||
        awful.layout.suit.spiral,
 | 
			
		||||
        awful.layout.suit.spiral.dwindle,
 | 
			
		||||
        awful.layout.suit.max,
 | 
			
		||||
        awful.layout.suit.max.fullscreen,
 | 
			
		||||
        awful.layout.suit.magnifier,
 | 
			
		||||
        awful.layout.suit.corner.nw,
 | 
			
		||||
        awful.layout.suit.floating
 | 
			
		||||
    })
 | 
			
		||||
end)
 | 
			
		||||
							
								
								
									
										106
									
								
								src/theme/init.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										106
									
								
								src/theme/init.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,106 @@
 | 
			
		||||
local dpi = require('beautiful.xresources').apply_dpi
 | 
			
		||||
local naughty = require('naughty')
 | 
			
		||||
 | 
			
		||||
local confdir = require('src.util.path').conf_dir
 | 
			
		||||
 | 
			
		||||
local function load_settings()
 | 
			
		||||
    local status, settings = pcall(function()
 | 
			
		||||
        return dofile(confdir .. '/settings.lua')
 | 
			
		||||
    end)
 | 
			
		||||
    if status then
 | 
			
		||||
        return settings
 | 
			
		||||
    else
 | 
			
		||||
        naughty.notify({
 | 
			
		||||
            preset = naughty.config.presets.critical,
 | 
			
		||||
            title = 'Error while parsing settings!',
 | 
			
		||||
            text = settings,
 | 
			
		||||
        })
 | 
			
		||||
        return {}
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local settings = load_settings()
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
    confdir = confdir,
 | 
			
		||||
    wallpaper = confdir .. '/wallpapers/' .. (settings['wallpaper'] or 'wall.png'),
 | 
			
		||||
    font = 'Terminus 8',
 | 
			
		||||
    font_mono = 'Mononoki Nerd Font Mono 10',
 | 
			
		||||
    bg_normal = '#000000',
 | 
			
		||||
    bg_focus = '#000000',
 | 
			
		||||
    bg_urgent = '#000000',
 | 
			
		||||
    fg_normal = '#aaaaaa',
 | 
			
		||||
    fg_focus = '#ff8c00',
 | 
			
		||||
    fg_urgent = '#af1d18',
 | 
			
		||||
    fg_minimize = '#ffffff',
 | 
			
		||||
    border_width = 1,
 | 
			
		||||
    border_normal = '#1c2022',
 | 
			
		||||
    border_focus = '#606060',
 | 
			
		||||
    border_marked = '#3ca4d8',
 | 
			
		||||
    menu_border_width = 1,
 | 
			
		||||
    menu_width = dpi(130),
 | 
			
		||||
    menu_submenu_icon = confdir .. '/icons/submenu.png',
 | 
			
		||||
    menu_fg_normal = '#aaaaaa',
 | 
			
		||||
    menu_fg_focus = '#ff8c00',
 | 
			
		||||
    menu_bg_normal = '#050505dd',
 | 
			
		||||
    menu_bg_focus = '#050505dd',
 | 
			
		||||
    widget_cpu = confdir .. '/icons/info/cpu.png',
 | 
			
		||||
    widget_mem = confdir .. '/icons/info/mem.png',
 | 
			
		||||
    widget_netdown = confdir .. '/icons/info/download.png',
 | 
			
		||||
    widget_netup = confdir .. '/icons/info/upload.png',
 | 
			
		||||
    widget_bat_charge = confdir .. '/icons/info/batcharge.png',
 | 
			
		||||
    widget_bat_empty = confdir .. '/icons/info/batempty.png',
 | 
			
		||||
    widget_bat_low = confdir .. '/icons/info/batlow.png',
 | 
			
		||||
    widget_bat_mid = confdir .. '/icons/info/batmid.png',
 | 
			
		||||
    widget_bat_high = confdir .. '/icons/info/bathigh.png',
 | 
			
		||||
    widget_bat_full = confdir .. '/icons/info/batfull.png',
 | 
			
		||||
    widget_vol_mute = confdir .. '/icons/info/volmute.png',
 | 
			
		||||
    widget_vol_low = confdir .. '/icons/info/vollow.png',
 | 
			
		||||
    widget_vol_high = confdir .. '/icons/info/volhigh.png',
 | 
			
		||||
    widget_play = confdir .. '/icons/info/play.png',
 | 
			
		||||
    widget_pause = confdir .. '/icons/info/pause.png',
 | 
			
		||||
    widget_stop = confdir .. '/icons/info/stop.png',
 | 
			
		||||
    taglist_fg_focus = '#000000',
 | 
			
		||||
    taglist_bg_focus = '#b3b3b3',
 | 
			
		||||
    taglist_squares_unsel = confdir .. '/icons/usedtag.png',
 | 
			
		||||
    taglist_squares_resize = true,
 | 
			
		||||
    useless_gap = 0,
 | 
			
		||||
    layout_tile = confdir .. '/icons/tile.png',
 | 
			
		||||
    layout_tilegaps = confdir .. '/icons/tilegaps.png',
 | 
			
		||||
    layout_tileleft = confdir .. '/icons/tileleft.png',
 | 
			
		||||
    layout_tilebottom = confdir .. '/icons/tilebottom.png',
 | 
			
		||||
    layout_tiletop = confdir .. '/icons/tiletop.png',
 | 
			
		||||
    layout_fairv = confdir .. '/icons/fairv.png',
 | 
			
		||||
    layout_fairh = confdir .. '/icons/fairh.png',
 | 
			
		||||
    layout_spiral = confdir .. '/icons/spiral.png',
 | 
			
		||||
    layout_dwindle = confdir .. '/icons/dwindle.png',
 | 
			
		||||
    layout_max = confdir .. '/icons/max.png',
 | 
			
		||||
    layout_fullscreen = confdir .. '/icons/fullscreen.png',
 | 
			
		||||
    layout_magnifier = confdir .. '/icons/magnifier.png',
 | 
			
		||||
    layout_floating = confdir .. '/icons/floating.png',
 | 
			
		||||
    titlebar_close_button_normal = confdir .. '/icons/titlebar/close_normal.png',
 | 
			
		||||
    titlebar_close_button_focus = confdir .. '/icons/titlebar/close_focus.png',
 | 
			
		||||
    titlebar_minimize_button_normal = confdir .. '/icons/titlebar/minimize_normal.png',
 | 
			
		||||
    titlebar_minimize_button_focus = confdir .. '/icons/titlebar/minimize_focus.png',
 | 
			
		||||
    titlebar_ontop_button_normal_inactive = confdir .. '/icons/titlebar/ontop_normal_inactive.png',
 | 
			
		||||
    titlebar_ontop_button_focus_inactive = confdir .. '/icons/titlebar/ontop_focus_inactive.png',
 | 
			
		||||
    titlebar_ontop_button_normal_active = confdir .. '/icons/titlebar/ontop_normal_active.png',
 | 
			
		||||
    titlebar_ontop_button_focus_active = confdir .. '/icons/titlebar/ontop_focus_active.png',
 | 
			
		||||
    titlebar_sticky_button_normal_inactive = confdir .. '/icons/titlebar/sticky_normal_inactive.png',
 | 
			
		||||
    titlebar_sticky_button_focus_inactive = confdir .. '/icons/titlebar/sticky_focus_inactive.png',
 | 
			
		||||
    titlebar_sticky_button_normal_active = confdir .. '/icons/titlebar/sticky_normal_active.png',
 | 
			
		||||
    titlebar_sticky_button_focus_active = confdir .. '/icons/titlebar/sticky_focus_active.png',
 | 
			
		||||
    titlebar_floating_button_normal_inactive = confdir .. '/icons/titlebar/floating_normal_inactive.png',
 | 
			
		||||
    titlebar_floating_button_focus_inactive = confdir .. '/icons/titlebar/floating_focus_inactive.png',
 | 
			
		||||
    titlebar_floating_button_normal_active = confdir .. '/icons/titlebar/floating_normal_active.png',
 | 
			
		||||
    titlebar_floating_button_focus_active = confdir .. '/icons/titlebar/floating_focus_active.png',
 | 
			
		||||
    titlebar_maximized_button_normal_inactive = confdir .. '/icons/titlebar/maximized_normal_inactive.png',
 | 
			
		||||
    titlebar_maximized_button_focus_inactive = confdir .. '/icons/titlebar/maximized_focus_inactive.png',
 | 
			
		||||
    titlebar_maximized_button_normal_active = confdir .. '/icons/titlebar/maximized_normal_active.png',
 | 
			
		||||
    titlebar_maximized_button_focus_active = confdir .. '/icons/titlebar/maximized_focus_active.png',
 | 
			
		||||
    tasklist_fg_minimize = '#b3b3b3',
 | 
			
		||||
    tasklist_bg_minimize = '#4d4d4d',
 | 
			
		||||
    tasklist_plain_task_name = true,
 | 
			
		||||
    tasklist_disable_icon = true,
 | 
			
		||||
    systray_screen = settings.systray_screen or 1
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										83
									
								
								src/theme/screen.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										83
									
								
								src/theme/screen.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,83 @@
 | 
			
		||||
local awful = require('awful')
 | 
			
		||||
local gears = require('gears')
 | 
			
		||||
local wibox = require('wibox')
 | 
			
		||||
local dpi = require('beautiful.xresources').apply_dpi
 | 
			
		||||
local theme = require('src.theme')
 | 
			
		||||
local widgets = require('src.widgets')
 | 
			
		||||
 | 
			
		||||
local info_widgets = {}
 | 
			
		||||
for i = #widgets, 1, -1 do
 | 
			
		||||
    table.insert(info_widgets, wibox.widget.separator({ orientation = 'vertical', forced_width = 9, thickness = 1, span_ratio = 0.7, color = theme.fg_normal }))
 | 
			
		||||
    table.insert(info_widgets, widgets[i])
 | 
			
		||||
end
 | 
			
		||||
info_widgets['layout'] = wibox.layout.fixed.horizontal
 | 
			
		||||
 | 
			
		||||
local layout_buttons = gears.table.join(
 | 
			
		||||
    awful.button({}, 1, function() awful.layout.inc(1) end),
 | 
			
		||||
    awful.button({}, 2, function() awful.layout.set(awful.layout.layouts[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)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
local taglist_buttons = gears.table.join(
 | 
			
		||||
    awful.button({}, 1, function(t) t:view_only() end),
 | 
			
		||||
    awful.button({ 'shift' }, 1, function(t) if client.focus then client.focus:move_to_tag(t) end end),
 | 
			
		||||
    awful.button({}, 3, awful.tag.viewtoggle),
 | 
			
		||||
    awful.button({ 'shift' }, 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)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
local tasklist_buttons = gears.table.join(
 | 
			
		||||
    awful.button({}, 1, function(c) c:emit_signal('request::activate', 'tasklist', { raise = true }) end)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
screen.connect_signal('property::geometry', function(s) gears.wallpaper.maximized(theme.wallpaper, s, true) end)
 | 
			
		||||
 | 
			
		||||
return function(s)
 | 
			
		||||
    gears.wallpaper.maximized(theme.wallpaper, s, true)
 | 
			
		||||
 | 
			
		||||
    awful.tag.new({'1', '2', '3', '4', '5'}, s, awful.layout.suit.fair)
 | 
			
		||||
 | 
			
		||||
    local tasklist = awful.widget.tasklist({
 | 
			
		||||
        screen = s,
 | 
			
		||||
        filter = awful.widget.tasklist.filter.minimizedcurrenttags,
 | 
			
		||||
        buttons = tasklist_buttons,
 | 
			
		||||
        style = { shape = gears.shape.rectangle },
 | 
			
		||||
        layout = {
 | 
			
		||||
            spacing = 5,
 | 
			
		||||
            layout = wibox.layout.flex.horizontal,
 | 
			
		||||
        },
 | 
			
		||||
        widget_template = {
 | 
			
		||||
            {
 | 
			
		||||
                { id = 'text_role', widget = wibox.widget.textbox },
 | 
			
		||||
                left = 10,
 | 
			
		||||
                right = 10,
 | 
			
		||||
                widget = wibox.container.margin,
 | 
			
		||||
            },
 | 
			
		||||
            id = 'background_role',
 | 
			
		||||
            widget = wibox.container.background,
 | 
			
		||||
        },
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    s.wibox = awful.wibar({ position = 'top', screen = s, height = dpi(19), bg = theme.bg_normal, fg = theme.fg_normal })
 | 
			
		||||
 | 
			
		||||
    if s.index == theme.systray_screen then
 | 
			
		||||
        local tray = wibox.widget.systray()
 | 
			
		||||
        tray.screen = s
 | 
			
		||||
        table.insert(info_widgets, 1, tray)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    s.wibox:setup({
 | 
			
		||||
        layout = wibox.layout.align.horizontal,
 | 
			
		||||
        {
 | 
			
		||||
            layout = wibox.layout.fixed.horizontal,
 | 
			
		||||
            awful.widget.layoutbox({ screen = s, buttons = layout_buttons }),
 | 
			
		||||
            awful.widget.taglist({ screen = s, filter = function() return true end, buttons = taglist_buttons})
 | 
			
		||||
        },
 | 
			
		||||
        wibox.container.margin(tasklist, 10, 10, 0, 0),
 | 
			
		||||
        info_widgets,
 | 
			
		||||
        { widget = wibox.container.margin, left = 50, { widget = wibox.widget.textbox } }
 | 
			
		||||
    })
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										17
									
								
								src/util/mpris.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/util/mpris.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
local function play_pause()
 | 
			
		||||
    os.execute('playerctl play-pause')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function previous()
 | 
			
		||||
    os.execute('playerctl previous')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function skip()
 | 
			
		||||
    os.execute('playerctl next')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
    play_pause = play_pause,
 | 
			
		||||
    skip = skip,
 | 
			
		||||
    previous = previous
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										7
									
								
								src/util/path.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								src/util/path.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,7 @@
 | 
			
		||||
local fs = require('gears.filesystem')
 | 
			
		||||
 | 
			
		||||
print(awesome.conffile)
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
    conf_dir = awesome.conffile:match('^(.+)/')
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										23
									
								
								src/util/volume.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/util/volume.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
local volume_changed_signal = 'volume_changed'
 | 
			
		||||
 | 
			
		||||
local function toggle_mute()
 | 
			
		||||
    os.execute('wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle')
 | 
			
		||||
    awesome.emit_signal(volume_changed_signal)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function vol_up()
 | 
			
		||||
    os.execute('wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+')
 | 
			
		||||
    awesome.emit_signal(volume_changed_signal)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function vol_down()
 | 
			
		||||
    os.execute('wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%-')
 | 
			
		||||
    awesome.emit_signal(volume_changed_signal)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
    volume_changed_signal = volume_changed_signal,
 | 
			
		||||
    toggle_mute = toggle_mute,
 | 
			
		||||
    vol_up = vol_up,
 | 
			
		||||
    vol_down = vol_down,
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										18
									
								
								src/widgets/1_clock.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								src/widgets/1_clock.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,18 @@
 | 
			
		||||
local theme = require('src.theme')
 | 
			
		||||
local lain = require('lain')
 | 
			
		||||
local wibox = require('wibox')
 | 
			
		||||
 | 
			
		||||
os.setlocale(os.getenv('LANG')) -- to localize the clock
 | 
			
		||||
local clock = wibox.widget.textclock('%I:%M %a %d.%m')
 | 
			
		||||
clock.font = theme.font
 | 
			
		||||
 | 
			
		||||
lain.widget.cal({
 | 
			
		||||
    attach_to = { clock },
 | 
			
		||||
    notification_preset = {
 | 
			
		||||
        font = theme.font_mono,
 | 
			
		||||
        fg = theme.fg_normal,
 | 
			
		||||
        bg = theme.bg_normal
 | 
			
		||||
    },
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
return { clock }
 | 
			
		||||
							
								
								
									
										17
									
								
								src/widgets/2_fs.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/widgets/2_fs.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
local awful = require('awful')
 | 
			
		||||
local lain = require('lain')
 | 
			
		||||
local theme = require('src.theme')
 | 
			
		||||
 | 
			
		||||
local fs = lain.widget.fs({
 | 
			
		||||
    notification_preset = { font = theme.font_mono, fg = theme.fg_normal },
 | 
			
		||||
    settings = function()
 | 
			
		||||
        -- luacheck: globals widget fs_now
 | 
			
		||||
        widget:set_text(
 | 
			
		||||
            fs_now['/'].percentage .. '% (' .. string.format('%.3f', fs_now['/'].free) .. ' ' .. fs_now['/'].units .. ' left)'
 | 
			
		||||
        )
 | 
			
		||||
    end,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
fs.widget:buttons(awful.button({}, 1, function() awful.spawn('krusader') end))
 | 
			
		||||
 | 
			
		||||
return { fs.widget }
 | 
			
		||||
							
								
								
									
										11
									
								
								src/widgets/3_cpu.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/widgets/3_cpu.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
local theme = require('src.theme')
 | 
			
		||||
local lain = require('lain')
 | 
			
		||||
local wibox = require('wibox')
 | 
			
		||||
local cpu = lain.widget.cpu({
 | 
			
		||||
    settings = function()
 | 
			
		||||
        -- luacheck: globals widget cpu_now
 | 
			
		||||
        widget:set_text(cpu_now.usage .. '%')
 | 
			
		||||
    end,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
return { wibox.layout.fixed.horizontal(wibox.widget.imagebox(theme.widget_cpu), cpu.widget) }
 | 
			
		||||
							
								
								
									
										12
									
								
								src/widgets/4_mem.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								src/widgets/4_mem.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
local wibox = require('wibox')
 | 
			
		||||
local lain = require('lain')
 | 
			
		||||
local theme = require('src.theme')
 | 
			
		||||
 | 
			
		||||
local memory = lain.widget.mem({
 | 
			
		||||
    settings = function()
 | 
			
		||||
        -- luacheck: globals widget mem_now
 | 
			
		||||
        widget:set_text(mem_now.used .. 'M')
 | 
			
		||||
    end,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
return { wibox.layout.fixed.horizontal(wibox.widget.imagebox(theme.widget_mem), memory.widget) }
 | 
			
		||||
							
								
								
									
										52
									
								
								src/widgets/5_vol.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								src/widgets/5_vol.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,52 @@
 | 
			
		||||
local wibox = require('wibox')
 | 
			
		||||
local awful = require('awful')
 | 
			
		||||
local gears = require('gears')
 | 
			
		||||
local theme = require('src.theme')
 | 
			
		||||
local volume = require('src.util.volume')
 | 
			
		||||
 | 
			
		||||
local volumeicon = wibox.widget.imagebox(theme.widget_vol_mute)
 | 
			
		||||
local volume_widget = wibox.widget.textbox()
 | 
			
		||||
 | 
			
		||||
local function spawn_callback(stdout)
 | 
			
		||||
    local volume_str = stdout:sub(9,12):gsub('[.]', '')
 | 
			
		||||
    local mute = stdout:match('MUTED')
 | 
			
		||||
    local level = tonumber(volume_str)
 | 
			
		||||
    if level == nil then
 | 
			
		||||
        volume_widget:set_markup('Waiting')
 | 
			
		||||
        return
 | 
			
		||||
    end
 | 
			
		||||
    if mute then
 | 
			
		||||
        volumeicon:set_image(theme.widget_vol_mute)
 | 
			
		||||
    elseif level == 0 then
 | 
			
		||||
        volumeicon:set_image(theme.widget_vol_mute)
 | 
			
		||||
    elseif level <= 50 then
 | 
			
		||||
        volumeicon:set_image(theme.widget_vol_low)
 | 
			
		||||
    else
 | 
			
		||||
        volumeicon:set_image(theme.widget_vol_high)
 | 
			
		||||
    end
 | 
			
		||||
    volume_widget:set_markup(level .. (mute  and 'M' or '%'))
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function timer_callback()
 | 
			
		||||
    awful.spawn.easy_async('wpctl get-volume @DEFAULT_AUDIO_SINK@', spawn_callback)
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local volume_timer = gears.timer {
 | 
			
		||||
    timeout = 30,
 | 
			
		||||
    autostart = true,
 | 
			
		||||
    call_now = true,
 | 
			
		||||
    callback = timer_callback
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
awesome.connect_signal(volume.volume_changed_signal, function() volume_timer:emit_signal('timeout') end)
 | 
			
		||||
 | 
			
		||||
local volumebuttons = awful.util.table.join(
 | 
			
		||||
    awful.button({}, 1, volume.toggle_mute),
 | 
			
		||||
    awful.button({}, 4, volume.vol_up),
 | 
			
		||||
    awful.button({}, 5, volume.vol_down)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
volume_widget:buttons(volumebuttons)
 | 
			
		||||
volumeicon:buttons(volumebuttons)
 | 
			
		||||
 | 
			
		||||
return { wibox.layout.fixed.horizontal(volumeicon, volume_widget) }
 | 
			
		||||
							
								
								
									
										17
									
								
								src/widgets/6_net.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								src/widgets/6_net.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,17 @@
 | 
			
		||||
local wibox = require('wibox')
 | 
			
		||||
local lain = require('lain')
 | 
			
		||||
local theme = require('src.theme')
 | 
			
		||||
 | 
			
		||||
local netdowninfo = wibox.widget.textbox()
 | 
			
		||||
local netupinfo = lain.widget.net({
 | 
			
		||||
    settings = function()
 | 
			
		||||
        -- luacheck: globals widget net_now
 | 
			
		||||
        widget:set_text(net_now.sent)
 | 
			
		||||
        netdowninfo:set_text(net_now.received)
 | 
			
		||||
    end,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
return {
 | 
			
		||||
    wibox.layout.fixed.horizontal(wibox.widget.imagebox(theme.widget_netdown), netdowninfo),
 | 
			
		||||
    wibox.layout.fixed.horizontal(wibox.widget.imagebox(theme.widget_netup), netupinfo.widget),
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										77
									
								
								src/widgets/7_mpris.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								src/widgets/7_mpris.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,77 @@
 | 
			
		||||
local wibox = require('wibox')
 | 
			
		||||
local awful = require('awful')
 | 
			
		||||
local lgi = require('lgi')
 | 
			
		||||
local theme = require('src.theme')
 | 
			
		||||
local mpris = require('src.util.mpris')
 | 
			
		||||
 | 
			
		||||
local mpris_icon = wibox.widget.imagebox(theme.widget_pause)
 | 
			
		||||
local mpris_widget = wibox.widget.textbox()
 | 
			
		||||
 | 
			
		||||
local function variant_strip(v)
 | 
			
		||||
    if not tostring(v):find("GLib%.Variant$") then
 | 
			
		||||
        if type(v) == "table" and #v > 0 then
 | 
			
		||||
            v.n = nil
 | 
			
		||||
        end
 | 
			
		||||
        return v
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if v:is_container() and not v:is_of_type(lgi.GLib.VariantType.VARIANT) then
 | 
			
		||||
        local out = {}
 | 
			
		||||
        local n_children = v:n_children()
 | 
			
		||||
        local idx = 0
 | 
			
		||||
 | 
			
		||||
        local is_dict = v:is_of_type(lgi.GLib.VariantType.DICTIONARY)
 | 
			
		||||
        while idx < n_children do
 | 
			
		||||
            local val = v:get_child_value(idx)
 | 
			
		||||
            idx = idx + 1
 | 
			
		||||
            if is_dict then
 | 
			
		||||
                local key = val[1]
 | 
			
		||||
                local value = variant_strip(val[2])
 | 
			
		||||
                out[key] = variant_strip(value)
 | 
			
		||||
            else
 | 
			
		||||
                out[idx] = variant_strip(val)
 | 
			
		||||
            end
 | 
			
		||||
        end
 | 
			
		||||
 | 
			
		||||
        return out
 | 
			
		||||
    else
 | 
			
		||||
        return variant_strip(v.value)
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local function signal_cbk(_conn, _sender, _object_path, _interface_name, _signal_name, params, _user_data)
 | 
			
		||||
    local data = variant_strip(params)
 | 
			
		||||
    if type(data) ~= 'table' or type(data[2]) ~= 'table' then return end
 | 
			
		||||
    data = data[2]
 | 
			
		||||
    if data['PlaybackStatus'] then
 | 
			
		||||
        if data['PlaybackStatus'] == 'Playing' then
 | 
			
		||||
            mpris_icon:set_image(theme.widget_play)
 | 
			
		||||
        elseif data['PlaybackStatus'] == 'Paused' then
 | 
			
		||||
            mpris_icon:set_image(theme.widget_pause)
 | 
			
		||||
        else
 | 
			
		||||
            mpris_icon:set_image(theme.widget_stop)
 | 
			
		||||
            mpris_widget.text = 'Nothing playing'
 | 
			
		||||
        end
 | 
			
		||||
    elseif data['Metadata'] then
 | 
			
		||||
        data = data['Metadata']
 | 
			
		||||
        local title = data['xesam:title'] or ''
 | 
			
		||||
        local artist = (data['xesam:artist'] or {})[1] or ''
 | 
			
		||||
        mpris_widget.text = artist .. ' | ' .. title
 | 
			
		||||
    end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
lgi.Gio.bus_get_sync(lgi.Gio.BusType.SESSION):signal_subscribe(
 | 
			
		||||
    nil, 'org.freedesktop.DBus.Properties', 'PropertiesChanged', '/org/mpris/MediaPlayer2',
 | 
			
		||||
    nil, lgi.Gio.DBusSignalFlags.NONE, signal_cbk
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
local mpris_buttons = awful.util.table.join(
 | 
			
		||||
    awful.button({}, 1, mpris.play_pause),
 | 
			
		||||
    awful.button({}, 2, mpris.previous),
 | 
			
		||||
    awful.button({}, 3, mpris.skip)
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
mpris_icon:buttons(mpris_buttons)
 | 
			
		||||
mpris_widget:buttons(mpris_buttons)
 | 
			
		||||
 | 
			
		||||
return { wibox.layout.fixed.horizontal(mpris_icon, mpris_widget) }
 | 
			
		||||
							
								
								
									
										11
									
								
								src/widgets/init.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								src/widgets/init.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
			
		||||
local gears = require('gears')
 | 
			
		||||
 | 
			
		||||
return gears.table.join(
 | 
			
		||||
    require('src.widgets.1_clock'),
 | 
			
		||||
    require('src.widgets.2_fs'),
 | 
			
		||||
    require('src.widgets.3_cpu'),
 | 
			
		||||
    require('src.widgets.4_mem'),
 | 
			
		||||
    require('src.widgets.5_vol'),
 | 
			
		||||
    require('src.widgets.6_net'),
 | 
			
		||||
    require('src.widgets.7_mpris')
 | 
			
		||||
)
 | 
			
		||||
		Reference in New Issue
	
	Block a user