Scripts: new hdmi-switch script.

Awesome: better support for multi head.
master
Pierre Neidhardt 2013-05-19 17:43:14 +02:00
parent c2be8ede3d
commit c2c305fa2d
2 changed files with 77 additions and 29 deletions

View File

@ -434,8 +434,8 @@ globalkeys = awful.util.table.join(
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
-- Multi screen
awful.key({ modkey, "Mod1" }, "Next", function () awful.screen.focus_relative( 1) end),
awful.key({ modkey, "Mod1" }, "Prior", function () awful.screen.focus_relative(-1) end),
awful.key({ modkey, "Control" }, "Next", function () awful.screen.focus_relative( 1) end),
awful.key({ modkey, "Control" }, "Prior", function () awful.screen.focus_relative(-1) end),
-- Prompt
@ -523,36 +523,42 @@ end
-- Be careful: we use keycodes to make it works on any keyboard layout.
-- This should map on the top row of your keyboard, usually 1 to 9.
for i = 1, keynumber do
globalkeys = awful.util.table.join(globalkeys,
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
end
end),
globalkeys = awful.util.table.join(
globalkeys,
awful.key({ modkey, "Control" }, "#" .. i + 9,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewtoggle(tags[screen][i])
end
end),
awful.key({ modkey }, "#" .. i + 9,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewonly(tags[screen][i])
end
end),
awful.key({ modkey, "Mod1" }, "#" .. i + 9,
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.movetotag(tags[client.focus.screen][i])
end
end)
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
function ()
local screen = mouse.screen
if tags[screen][i] then
awful.tag.viewtoggle(tags[screen][i])
end
end),
awful.key({ modkey, "Mod1" }, "#" .. i + 9,
function ()
if client.focus and tags[client.focus.screen][i] then
awful.client.movetotag(tags[client.focus.screen][i])
end
end),
-- Multi screen
awful.key({ modkey, "Control" }, "#" .. i + 9,
function ()
if client.focus and tags[client.focus.screen+1] and tags[client.focus.screen+1][i] then
awful.client.movetotag(tags[client.focus.screen+1][i])
elseif client.focus and tags[1][i] then
awful.client.movetotag(tags[1][i])
end
end)
)
-- awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
-- function ()
-- if client.focus and tags[client.focus.screen][i] then
-- awful.client.toggletag(tags[client.focus.screen][i])
-- end
-- end)
end
clientbuttons = awful.util.table.join(

42
.scripts/hdmi-switch Executable file
View File

@ -0,0 +1,42 @@
#!/bin/sh
## This script will toggle HDMI Audio (and set video properly).
## To do this automatically when the cable is plugged, add the following udev
## rule (Linux only):
## $ cat /etc/udev/rules.d/hdmi.rules
## SUBSYSTEM=="drm", ACTION=="change", RUN+="/bin/sh /usr/local/bin/hdmi-switch"
udevadm settle --quiet --timeout=16
HDMI_STATUS="$(cat /sys/class/drm/card0-HDMI-A-1/status)"
ALSACONF="/etc/asound.conf"
HDMICARD="$(aplay -l | awk '/HDMI/ {sub(/:/,"",$2); sub(/:/,"",$7); printf "card " $2 "\ndevice " $7 "\n"}')"
[ -z "$HDMI_STATUS" ] && exit
## Video
for i in $(xrandr | awk '/^[[:alnum:]-]+ connected/ {print $1}'); do
xrandr --output "$i" --auto
done
## Sound
if [ "$HDMI_STATUS" = "connected" ]; then
echo "pcm.!default {
type hw
$HDMICARD
}" > "$ALSACONF"
else
echo "pcm.!default {
type hw
card 0
device 0
}" > "$ALSACONF"
fi
chmod 644 "${ALSACONF}"