Compare commits
2 commits
962f1cf796
...
269bda650d
Author | SHA1 | Date | |
---|---|---|---|
269bda650d | |||
c06691c45f |
7 changed files with 100 additions and 31 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
result/
|
result/
|
||||||
|
target/
|
||||||
|
|
BIN
home/audio/discord-mute.mp3
Normal file
BIN
home/audio/discord-mute.mp3
Normal file
Binary file not shown.
BIN
home/audio/discord-unmute.mp3
Normal file
BIN
home/audio/discord-unmute.mp3
Normal file
Binary file not shown.
58
home/modules/pipewire-controller.nix
Normal file
58
home/modules/pipewire-controller.nix
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
{ lib, config, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.snowhawk.pipewire-controller;
|
||||||
|
|
||||||
|
pipewire-controller =
|
||||||
|
let
|
||||||
|
mpv = lib.getExe pkgs.mpv;
|
||||||
|
pamixer = lib.getExe pkgs.pamixer;
|
||||||
|
in
|
||||||
|
pkgs.writers.writeRustBin "pipewire-controller" { } ''
|
||||||
|
use std::{process::Command, str};
|
||||||
|
|
||||||
|
const MUTE_AUDIO: &str = "${../audio/discord-mute.mp3}";
|
||||||
|
const UNMUTE_AUDIO: &str = "${../audio/discord-unmute.mp3}";
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let mute_status = Command::new("${pamixer}")
|
||||||
|
.args(["--default-source", "--get-mute"])
|
||||||
|
.output()
|
||||||
|
.expect("Unable to get mute status from pamixer")
|
||||||
|
.stdout;
|
||||||
|
|
||||||
|
let mute_status = str::from_utf8(&mute_status[..]).expect("pamixer output wasn't a string");
|
||||||
|
|
||||||
|
if mute_status == "false" {
|
||||||
|
Command::new("${pamixer}")
|
||||||
|
.args(["--default-source", "--mute"])
|
||||||
|
.output()
|
||||||
|
.expect("Unable to mute via pamixer");
|
||||||
|
|
||||||
|
Command::new("${mpv}")
|
||||||
|
.args(["--no-video", MUTE_AUDIO])
|
||||||
|
.output()
|
||||||
|
.expect("Unable to play audio via mpv");
|
||||||
|
} else {
|
||||||
|
Command::new("${pamixer}")
|
||||||
|
.args(["--default-source", "--unmute"])
|
||||||
|
.output()
|
||||||
|
.expect("Unable to mute via pamixer");
|
||||||
|
|
||||||
|
Command::new("${mpv}")
|
||||||
|
.args(["--no-video", UNMUTE_AUDIO])
|
||||||
|
.output()
|
||||||
|
.expect("Unable to play audio via mpv");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.snowhawk.pipewire-controller = {
|
||||||
|
enable = lib.mkEnableOption "pipewire-controller home-manager module";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
home.packages = [ pipewire-controller ];
|
||||||
|
};
|
||||||
|
}
|
|
@ -2,14 +2,6 @@
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.snowhawk.playerctl;
|
cfg = config.snowhawk.playerctl;
|
||||||
|
|
||||||
keybindingsStr = lib.concatStringsSep "\n" (lib.mapAttrsToList
|
|
||||||
(hotkey: command:
|
|
||||||
lib.optionalString (command != null) ''
|
|
||||||
${hotkey}
|
|
||||||
${command}
|
|
||||||
'')
|
|
||||||
config.services.sxhkd.keybindings);
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.snowhawk.playerctl = {
|
options.snowhawk.playerctl = {
|
||||||
|
@ -27,30 +19,14 @@ in
|
||||||
playerctl
|
playerctl
|
||||||
];
|
];
|
||||||
|
|
||||||
systemd.user.services.sxhkd = {
|
snowhawk.sxhkd.enable = lib.mkDefault true;
|
||||||
Unit = {
|
|
||||||
Description = "sxhkd service";
|
|
||||||
PartOf = [ "graphical-session.target" ];
|
|
||||||
};
|
|
||||||
Service = {
|
|
||||||
Type = "exec";
|
|
||||||
ExecStart = "${pkgs.sxhkd}/bin/sxhkd";
|
|
||||||
};
|
|
||||||
Install.WantedBy = [ "graphical-session.target" ];
|
|
||||||
};
|
|
||||||
|
|
||||||
xdg.configFile."sxhkd/sxhkdrc".text = keybindingsStr;
|
services.sxhkd.keybindings =
|
||||||
|
let playerctl = "${pkgs.playerctl}/bin/playerctl";
|
||||||
services.sxhkd =
|
in {
|
||||||
let
|
|
||||||
playerctl = "${pkgs.playerctl}/bin/playerctl";
|
|
||||||
in
|
|
||||||
{
|
|
||||||
keybindings = {
|
|
||||||
"XF86AudioPlay" = "${playerctl} play-pause";
|
"XF86AudioPlay" = "${playerctl} play-pause";
|
||||||
"XF86AudioPrev" = "${playerctl} previous";
|
"XF86AudioPrev" = "${playerctl} previous";
|
||||||
"XF86AudioNext" = "${playerctl} next";
|
"XF86AudioNext" = "${playerctl} next";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
33
home/modules/sxhkd.nix
Normal file
33
home/modules/sxhkd.nix
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.snowhawk.sxhkd;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.snowhawk.sxhkd = {
|
||||||
|
enable = lib.mkEnableOption "custom sxhkd home-manager module";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
systemd.user.services.sxhkd = {
|
||||||
|
Unit = {
|
||||||
|
Description = "sxhkd service";
|
||||||
|
PartOf = [ "graphical-session.target" ];
|
||||||
|
};
|
||||||
|
Service = {
|
||||||
|
Type = "exec";
|
||||||
|
ExecStart = "${pkgs.sxhkd}/bin/sxhkd";
|
||||||
|
};
|
||||||
|
Install.WantedBy = [ "graphical-session.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
xdg.configFile."sxhkd/sxhkdrc".text =
|
||||||
|
lib.concatStringsSep "\n" (lib.mapAttrsToList
|
||||||
|
(hotkey: command:
|
||||||
|
lib.optionalString (command != null) ''
|
||||||
|
${hotkey}
|
||||||
|
${command}
|
||||||
|
'')
|
||||||
|
config.services.sxhkd.keybindings);
|
||||||
|
};
|
||||||
|
}
|
|
@ -14,6 +14,7 @@
|
||||||
playerctl.enable = true;
|
playerctl.enable = true;
|
||||||
alacritty.enable = true;
|
alacritty.enable = true;
|
||||||
defaultPrograms.enable = true;
|
defaultPrograms.enable = true;
|
||||||
|
pipewire-controller.enable = true;
|
||||||
|
|
||||||
# Games
|
# Games
|
||||||
xivlauncher.enable = true;
|
xivlauncher.enable = true;
|
||||||
|
|
Loading…
Reference in a new issue