home/qtile: add volume keys and ease testing
This commit is contained in:
parent
dd4cd9aaf4
commit
b53ad263e6
3 changed files with 89 additions and 63 deletions
11
Justfile
11
Justfile
|
@ -44,6 +44,17 @@ update-this-device:
|
|||
fi
|
||||
fi
|
||||
|
||||
hm-iterate-qtile:
|
||||
#!/usr/bin/env bash
|
||||
set -xe
|
||||
home-manager switch
|
||||
Xephyr -ac -br -resizeable :1 &
|
||||
XEPHYR_PID=$!
|
||||
echo ${XEPHYR_PID}
|
||||
DISPLAY=:1 $(grep qtile ~/.xsession) &
|
||||
wait $!
|
||||
kill ${XEPHYR_PID}
|
||||
|
||||
# Sorry, this is a manual step for now. Please see nix/os/modules/encryptedDisk.nix for the layout
|
||||
disk-prepare:
|
||||
echo NOT IMPLEMENTED
|
||||
|
|
|
@ -7,7 +7,27 @@ let
|
|||
mkSimpleTrayService
|
||||
;
|
||||
|
||||
qtileConfig = pkgs.writeScript "config.py" ''
|
||||
audio = pkgs.writeScript "audio" ''
|
||||
#!${pkgs.bash}/bin/bash
|
||||
case $1 in
|
||||
mute)
|
||||
${pkgs.pulseaudio}/bin/pactl set-sink-mute $(${pkgs.pulseaudio}/bin/pactl list short sinks | grep RUNNING | awk '{ print $1 }') toggle
|
||||
;;
|
||||
lower)
|
||||
${pkgs.pulseaudio}/bin/pactl set-sink-volume $(${pkgs.pulseaudio}/bin/pactl list short sinks | grep RUNNING | awk '{ print $1 }') -10%
|
||||
;;
|
||||
raise)
|
||||
${pkgs.pulseaudio}/bin/pactl set-sink-volume $(${pkgs.pulseaudio}/bin/pactl list short sinks | grep RUNNING | awk '{ print $1 }') +10%
|
||||
;;
|
||||
*)
|
||||
echo Unknown command: $1
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
'';
|
||||
|
||||
qtileConfig = pkgs.writeScript "qtile_config.py" ''
|
||||
from libqtile.config import Key, Screen, Group, Drag, Click
|
||||
from libqtile.command import lazy
|
||||
from libqtile import layout, bar, widget
|
||||
|
@ -24,45 +44,45 @@ handler = logging.handlers.RotatingFileHandler(
|
|||
handler.setLevel(logging.WARN)
|
||||
logger.addHandler(handler)
|
||||
|
||||
@hook.subscribe.screen_change
|
||||
def restart_on_randr(qtile, ev):
|
||||
import time
|
||||
|
||||
with open(os.path.join(os.environ['HOME'], ".qtilelastrestart"), "w"):
|
||||
pass
|
||||
|
||||
lastRestart = 0
|
||||
with open(os.path.join(os.environ['HOME'], ".qtilelastrestart"), "r+") as lastRestartFile:
|
||||
lastRestartStr = lastRestartFile.read()
|
||||
if len(lastRestartStr) > 0:
|
||||
lastRestart = float(lastRestartStr)
|
||||
|
||||
print("screen changed. (last change: %s)" % lastRestart)
|
||||
|
||||
delta=time.time()-lastRestart
|
||||
if delta > 3:
|
||||
import subprocess
|
||||
lastRestartFile.seek(0)
|
||||
lastRestartFile.write("%s" % time.time())
|
||||
lastRestartFile.truncate()
|
||||
|
||||
subprocess.call(["autorandr","-c"])
|
||||
qtile.cmd_restart()
|
||||
else:
|
||||
print("screen is changing too fast: %s" % delta)
|
||||
|
||||
active_screen = 0
|
||||
@hook.subscribe.client_focus
|
||||
def focus_changed(window):
|
||||
global active_screen
|
||||
pass
|
||||
active_screen = window.group.screen.index
|
||||
|
||||
@hook.subscribe.current_screen_change
|
||||
def move_widget():
|
||||
global active_screen
|
||||
systray = widget.Systray()
|
||||
logging.warn("Screen changed to %i" % active_screen)
|
||||
# @hook.subscribe.screen_change
|
||||
# def restart_on_randr(qtile, ev):
|
||||
# import time
|
||||
#
|
||||
# with open(os.path.join(os.environ['HOME'], ".qtilelastrestart"), "w"):
|
||||
# pass
|
||||
#
|
||||
# lastRestart = 0
|
||||
# with open(os.path.join(os.environ['HOME'], ".qtilelastrestart"), "r+") as lastRestartFile:
|
||||
# lastRestartStr = lastRestartFile.read()
|
||||
# if len(lastRestartStr) > 0:
|
||||
# lastRestart = float(lastRestartStr)
|
||||
#
|
||||
# print("screen changed. (last change: %s)" % lastRestart)
|
||||
#
|
||||
# delta=time.time()-lastRestart
|
||||
# if delta > 3:
|
||||
# import subprocess
|
||||
# lastRestartFile.seek(0)
|
||||
# lastRestartFile.write("%s" % time.time())
|
||||
# lastRestartFile.truncate()
|
||||
#
|
||||
# subprocess.call(["autorandr","-c"])
|
||||
# qtile.cmd_restart()
|
||||
# else:
|
||||
# print("screen is changing too fast: %s" % delta)
|
||||
#
|
||||
# active_screen = 0
|
||||
# @hook.subscribe.client_focus
|
||||
# def focus_changed(window):
|
||||
# global active_screen
|
||||
# pass
|
||||
# active_screen = window.group.screen.index
|
||||
#
|
||||
# @hook.subscribe.current_screen_change
|
||||
# def move_widget():
|
||||
# global active_screen
|
||||
# systray = widget.Systray()
|
||||
# logging.warn("Screen changed to %i" % active_screen)
|
||||
|
||||
key_super = "mod4"
|
||||
key_alt = "mod1"
|
||||
|
@ -76,14 +96,11 @@ keys = [
|
|||
Key([key_super], "r", lazy.spawncmd()),
|
||||
Key([key_super], "w", lazy.window.kill()),
|
||||
|
||||
# Key([key_alt, key_super], "l", lazy.spawn("xscreensaver-command -lock")),
|
||||
# Key([key_alt, key_super], "l", lazy.spawn("sh -c '(sleep 1; xset dpms force off) & xautolock -locknow'")),
|
||||
# Key([key_alt, key_super], "l", lazy.spawn("light-locker-command -l")),
|
||||
# Key([key_alt, key_super], "l", lazy.spawn("dm-tool lock")),
|
||||
Key([key_alt, key_super], "l", lazy.spawn('${pkgs.bash}/bin/sh -c "loginctl lock-session $XDG_SESSION_ID"')),
|
||||
Key([key_alt, key_super], "s", lazy.spawn("${pkgs.systemd}/bin/systemctl suspend")),
|
||||
|
||||
Key([key_super, key_control], "r", lazy.restart()),
|
||||
# Key([key_super, key_control], "r", lazy.restart()),
|
||||
Key([key_super, key_control], "r", lazy.spawn("${pkgs.autorandr}/bin/autorandr -c"), lazy.restart()),
|
||||
Key([key_super, key_control], "q", lazy.shutdown()),
|
||||
|
||||
# Toggle between different layouts as defined below
|
||||
|
@ -137,11 +154,9 @@ keys = [
|
|||
## Microsoft Comfort Curve specific
|
||||
Key([key_super, "shift"], "XF86TouchpadToggle", lazy.spawn("${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous")),
|
||||
Key([key_alt, key_super], "XF86TouchpadToggle", lazy.spawn("${pkgs.dbus}/bin/dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next")),
|
||||
|
||||
# FIXME: Backlight currently broken
|
||||
# Key([], "XF86MonBrightnessDown", lazy.spawn("xbacklight -inc -5")),
|
||||
# Key([], "XF86MonBrightnessUp", lazy.spawn("xbacklight -inc 5")),
|
||||
|
||||
Key([], "XF86AudioMute", lazy.spawn("${audio} mute")),
|
||||
Key([], "XF86AudioLowerVolume", lazy.spawn("${audio} lower")),
|
||||
Key([], "XF86AudioRaiseVolume", lazy.spawn("${audio} raise")),
|
||||
Key([], "Print", lazy.spawn("${pkgs.flameshot}/bin/flameshot gui")),
|
||||
]
|
||||
groups = [Group(i) for i in "1234567890"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue