Commit 17a82025 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Added media keys to awesome-wm

parent a60fbbb7
Loading
Loading
Loading
Loading

.config/awesome/keys.lua

deleted100644 → 0
+0 −14
Original line number Diff line number Diff line
local awful = require("awful")

local keys = {}

function keys.run(keysuffix, cmd)
	return awful.key({}, "XF86Audio"..keysuffix, function()
		awful.util.spawn(cmd, false)
	end)
end

function keys.kodi(keysuffix, method, params)
end

return keys
+19 −0
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ local gears = require("gears")
local awful = require("awful")
local beautiful = require("beautiful")
local debian_menu = require("debian.menu")
local util = require("util")


-- {{{ Link titlebars with floating property
@@ -78,3 +79,21 @@ rules.add_rule{
	}
}
 -- }}}


-- {{{ Global keys
if util.path.has_executable('pactl') then
	local pa_device = PA_DEVICE or '0'
	root.keys(awful.util.table.join(root.keys(),
		util.keys.run({}, 'XF86AudioRaiseVolume', {
			'pactl', 'set-sink-volume', pa_device. '+5%'
		}),
		util.keys.run({}, 'XF86AudioLowerVolume', {
			'pactl', 'set-sink-volume', pa_device, '-5%'
		}),
		util.keys.run({}, 'XF86AudioMute', {
			'pactl', 'set-sink-mute', pa_device, 'toggle'
		})
	))
end
-- }}}
+4 −0
Original line number Diff line number Diff line
return {
	keys = require('util.keys'),
	path = require('util.path')
}
+9 −0
Original line number Diff line number Diff line
local awful = require("awful")

local keys = {}

function keys.run(mod, keyname, cmd)
	return awful.key(mod, keyname, function() awful.spawn(cmd) end)
end

return keys
+34 −0
Original line number Diff line number Diff line
local awful = require('awful')

local path = {}

function path.exists(path)
	local f = io.open(path, 'r')
	if f ~= nil then
		f:close()
		return true
	else
		return false
	end
end

function path.has_executable(prog)
	-- check relative or absolute paths directly
	if prog:match('^%./') or prog:match('^/') then
		return path.exists(name)
	end

	-- search PATH
	local search_paths = os.getenv('PATH') or ''
	for directory in search_paths:gmatch('([^:]+):?') do
		local file = directory .. '/' .. prog
		if path.exists(file) then
			return true
		end
	end

	-- nothing found
	return false
end

return path