Updates
This commit is contained in:
parent
be2e1e5aa3
commit
d76c245b5e
17 changed files with 139 additions and 96 deletions
|
@ -13,7 +13,7 @@ in
|
||||||
config = mkIf (cfg.enable) {
|
config = mkIf (cfg.enable) {
|
||||||
programs.rofi = {
|
programs.rofi = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = myPkgs.rofi-wayland;
|
package = pkgs.rofi-wayland;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
53
flake.nix
53
flake.nix
|
@ -42,32 +42,8 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
# nixosUsers = [{
|
|
||||||
# name = "erwin";
|
|
||||||
# groups = [ "wheel" "networkmanager" "video" ];
|
|
||||||
# uid = 1000;
|
|
||||||
# shell = pkgs.fish;
|
|
||||||
# openssh.authorizedKeys.keys = [
|
|
||||||
# "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMNoTcRsAxDwpiIj6nhUXwzSQjtcgKCR0RDlzP57wi0W erwin@horusvr-ws2"
|
|
||||||
# ];
|
|
||||||
# }];
|
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# homeManagerConfigurations = {
|
|
||||||
# erwin = user.mkHMUser {
|
|
||||||
# userConfig = {
|
|
||||||
# git.enable = true;
|
|
||||||
# ssh.enable = true;
|
|
||||||
# applications.enable = true;
|
|
||||||
# gpg.enable = true;
|
|
||||||
# fish.enable = true;
|
|
||||||
# sway.enable = true;
|
|
||||||
# };
|
|
||||||
# username = "erwin";
|
|
||||||
# };
|
|
||||||
# };
|
|
||||||
|
|
||||||
overlay = final: prev: (import ./overlays) final prev;
|
overlay = final: prev: (import ./overlays) final prev;
|
||||||
# overlay = final: prev: {
|
# overlay = final: prev: {
|
||||||
# unstable = import nixpkgs {
|
# unstable = import nixpkgs {
|
||||||
|
@ -84,33 +60,6 @@
|
||||||
(builtins.attrNames (builtins.readDir ./modules)));
|
(builtins.attrNames (builtins.readDir ./modules)));
|
||||||
|
|
||||||
nixosConfigurations = {
|
nixosConfigurations = {
|
||||||
# vm1 = host.mkHost {
|
|
||||||
# name = "vm1";
|
|
||||||
# NICs = [ "enp1s0" ];
|
|
||||||
# kernelPackage = pkgs.linuxPackages;
|
|
||||||
# initrdMods = [ "ahci" "xhci_pci" "sr_mod" ];
|
|
||||||
# kernelMods = [ "kvm-amd" ];
|
|
||||||
# kernelParams = [ ];
|
|
||||||
# systemConfig = vm1UefiConfig;
|
|
||||||
|
|
||||||
# users = nixosUsers;
|
|
||||||
|
|
||||||
# cpuCores = 6;
|
|
||||||
# };
|
|
||||||
|
|
||||||
# vm2 = host.mkHost {
|
|
||||||
# name = "vm2";
|
|
||||||
# NICs = [ "enp1s0" ];
|
|
||||||
# kernelPackage = pkgs.linuxPackages;
|
|
||||||
# initrdMods = [ "ahci" "xhci_pci" "sr_mod" ];
|
|
||||||
# kernelMods = [ "kvm-amd" ];
|
|
||||||
# kernelParams = [ ];
|
|
||||||
# systemConfig = vm2Config;
|
|
||||||
|
|
||||||
# users = nixosUsers;
|
|
||||||
|
|
||||||
# cpuCores = 4;
|
|
||||||
# };
|
|
||||||
vm1 = defSystem "x86_64-linux" {
|
vm1 = defSystem "x86_64-linux" {
|
||||||
imports = [
|
imports = [
|
||||||
(import (./machines/vm1/configuration.nix) { inherit self; })
|
(import (./machines/vm1/configuration.nix) { inherit self; })
|
||||||
|
@ -130,7 +79,7 @@
|
||||||
|
|
||||||
};
|
};
|
||||||
} //
|
} //
|
||||||
(flake-utils.lib.eachSystem [ "x86_64-linux" ])
|
(flake-utils.lib.eachSystem [ "aarch64-linux" "x86_64-linux" ])
|
||||||
(system:
|
(system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
|
|
|
@ -10,6 +10,7 @@ in
|
||||||
|
|
||||||
programs.rofi = {
|
programs.rofi = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
package = pkgs.rofi-wayland;
|
||||||
theme = ./launch.rasi;
|
theme = ./launch.rasi;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
1
krops.nix
Normal file
1
krops.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ }
|
|
@ -17,7 +17,7 @@
|
||||||
networking = {
|
networking = {
|
||||||
hostName = "vm2";
|
hostName = "vm2";
|
||||||
useDHCP = false;
|
useDHCP = false;
|
||||||
interfaces.enp1s.useDHCP = true;
|
interfaces.enp1s0.useDHCP = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# nix = {
|
# nix = {
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
enable = true;
|
enable = true;
|
||||||
home-manager = true;
|
home-manager = true;
|
||||||
};
|
};
|
||||||
|
nix-common = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
boot.loader.systemd-boot.enable = true;
|
boot.loader.systemd-boot.enable = true;
|
||||||
|
@ -17,7 +20,7 @@
|
||||||
networking = {
|
networking = {
|
||||||
hostName = "vm2";
|
hostName = "vm2";
|
||||||
useDHCP = false;
|
useDHCP = false;
|
||||||
interfaces.enp1s.useDHCP = true;
|
interfaces.enp1s0.useDHCP = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
# nix = {
|
# nix = {
|
||||||
|
|
|
@ -41,13 +41,23 @@ in
|
||||||
|
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
(nerdfonts.override { fonts = [ "CascadiaCode" "FantasqueSansMono" "FiraCode" "Iosevka" "JetBrainsMono" "Meslo" "Noto" "SourceCodePro" ]; })
|
(nerdfonts.override { fonts = [ "CascadiaCode" "FantasqueSansMono" "FiraCode" "Iosevka" "JetBrainsMono" "Meslo" "Noto" "SourceCodePro" ]; })
|
||||||
|
(callPackage ../../pkgs/pamedia { })
|
||||||
];
|
];
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
|
{
|
||||||
|
nixpkgs.overlays = [ self-overlay ];
|
||||||
|
}
|
||||||
../../home-manager/modules/sway
|
../../home-manager/modules/sway
|
||||||
../../home-manager/modules/waybar
|
../../home-manager/modules/waybar
|
||||||
../../home-manager/modules/rofi
|
../../home-manager/modules/rofi
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.pipewire = {
|
||||||
|
enable = true;
|
||||||
|
pulse.enable = true;
|
||||||
|
media-session.enable = true;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
33
modules/nix-common/default.nix
Normal file
33
modules/nix-common/default.nix
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{ lib, pkgs, config, ... }:
|
||||||
|
with lib;
|
||||||
|
let cfg = config.eboskma.nix-common;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.eboskma.nix-common = {
|
||||||
|
enable = mkEnableOption "activate nix-common";
|
||||||
|
disable-cache = mkEnableOption "no not use binary cache";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
nixpkgs = {
|
||||||
|
config.allowUnfree = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
nix = {
|
||||||
|
package = pkgs.nixFlakes;
|
||||||
|
extraOptions = ''
|
||||||
|
experimental-features = nix-command flakes ca-references
|
||||||
|
'';
|
||||||
|
|
||||||
|
autoOptimiseStore = true;
|
||||||
|
|
||||||
|
gc = {
|
||||||
|
automatic = true;
|
||||||
|
dates = "weekly";
|
||||||
|
options = "--delete-older-than=30d";
|
||||||
|
};
|
||||||
|
|
||||||
|
allowedUsers = [ "root" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,4 +1,11 @@
|
||||||
self: super: {
|
final: prev: {
|
||||||
rofi = super.pkgs.callPackage ../pkgs/rofi-wayland { };
|
rofi-wayland = prev.pkgs.callPackage ../pkgs/rofi-wayland { };
|
||||||
pamedia = super.pkgs.callPackage ../pkgs/pamedia { };
|
pamedia = prev.pkgs.callPackage ../pkgs/pamedia {
|
||||||
|
buildPythonPackage = prev.pkgs.python3.pkgs.buildPythonPackage;
|
||||||
|
pulsectl = prev.pkgs.python39Packages.pulsectl;
|
||||||
|
pygobject3 = prev.pkgs.python39Packages.pygobject3;
|
||||||
|
gobject-introspection = prev.pkgs.gobject-introspection;
|
||||||
|
libnotify = prev.pkgs.libnotify;
|
||||||
|
lib = prev.pkgs.lib;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
{ buildPythonPackage, lib, pulsectl }:
|
{ pkgs, ... }:
|
||||||
|
with pkgs;
|
||||||
|
let
|
||||||
|
buildPythonPackage = python3.pkgs.buildPythonPackage;
|
||||||
|
pulsectl = python3.pkgs.pulsectl;
|
||||||
|
pygobject3 = python3.pkgs.pygobject3;
|
||||||
|
in
|
||||||
buildPythonPackage rec {
|
buildPythonPackage rec {
|
||||||
pname = "pamedia";
|
pname = "pamedia";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
|
@ -7,13 +13,11 @@ buildPythonPackage rec {
|
||||||
|
|
||||||
propagatedBuildInputs = [
|
propagatedBuildInputs = [
|
||||||
pulsectl
|
pulsectl
|
||||||
|
pygobject3
|
||||||
|
gobject-introspection
|
||||||
|
libnotify
|
||||||
];
|
];
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
install -d $out/bin
|
|
||||||
install -m 0755 $src/pamedia $out/bin/pamedia
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
description = "Change volume of the PulseAudio default sink";
|
description = "Change volume of the PulseAudio default sink";
|
||||||
license = lib.licenses.mit;
|
license = lib.licenses.mit;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import argparse
|
||||||
import pulsectl
|
import pulsectl
|
||||||
import gi
|
import gi
|
||||||
|
|
||||||
gi.require_version('Notify', '0.7')
|
gi.require_version("Notify", "0.7")
|
||||||
|
|
||||||
from gi.repository import GLib
|
from gi.repository import GLib
|
||||||
from gi.repository import Notify
|
from gi.repository import Notify
|
||||||
|
@ -12,19 +12,22 @@ from gi.repository import Notify
|
||||||
|
|
||||||
class PAMedia:
|
class PAMedia:
|
||||||
def __init__(self, sink=None):
|
def __init__(self, sink=None):
|
||||||
self.client = pulsectl.Pulse('volumectl')
|
self.client = pulsectl.Pulse("volumectl")
|
||||||
sinks = self.client.sink_list()
|
sinks = self.client.sink_list()
|
||||||
|
|
||||||
if sink == None:
|
if sink == None:
|
||||||
self.sink = self.client.get_sink_by_name(
|
self.sink = self.client.get_sink_by_name(
|
||||||
self.client.server_info().default_sink_name)
|
self.client.server_info().default_sink_name
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
if sink > len(sinks):
|
if sink > len(sinks):
|
||||||
notification = Notify.Notification.new(
|
notification = Notify.Notification.new(
|
||||||
'Volume', f'Unknown sink index \'{sink}\', using default sink')
|
"Volume", f"Unknown sink index '{sink}', using default sink"
|
||||||
|
)
|
||||||
notification.show()
|
notification.show()
|
||||||
self.sink = self.client.get_sink_by_name(
|
self.sink = self.client.get_sink_by_name(
|
||||||
self.client.server_info().default_sink_name)
|
self.client.server_info().default_sink_name
|
||||||
|
)
|
||||||
|
|
||||||
self.sink = sinks[sink]
|
self.sink = sinks[sink]
|
||||||
|
|
||||||
|
@ -45,31 +48,31 @@ class PAMedia:
|
||||||
|
|
||||||
def list_sinks(self):
|
def list_sinks(self):
|
||||||
for num, sink in enumerate(self.client.sink_list()):
|
for num, sink in enumerate(self.client.sink_list()):
|
||||||
print(f'[{num}] {sink.description}')
|
print(f"[{num}] {sink.description}")
|
||||||
|
|
||||||
def icon(self):
|
def icon(self):
|
||||||
if self.sink.mute:
|
if self.sink.mute:
|
||||||
return 'muted'
|
return "muted"
|
||||||
elif self.sink.volume.value_flat <= 0.3:
|
elif self.sink.volume.value_flat <= 0.3:
|
||||||
return 'low'
|
return "low"
|
||||||
elif self.sink.volume.value_flat <= 0.7:
|
elif self.sink.volume.value_flat <= 0.7:
|
||||||
return 'medium'
|
return "medium"
|
||||||
else:
|
else:
|
||||||
return 'high'
|
return "high"
|
||||||
|
|
||||||
def notify(self):
|
def notify(self):
|
||||||
icon = f'audio-volume-{self.icon()}'
|
icon = f"audio-volume-{self.icon()}"
|
||||||
title = f'Volume'
|
title = f"Volume"
|
||||||
|
|
||||||
if self.sink.mute:
|
if self.sink.mute:
|
||||||
title = 'Muted'
|
title = "Muted"
|
||||||
|
|
||||||
notification = Notify.Notification.new(title, '', icon)
|
notification = Notify.Notification.new(title, "", icon)
|
||||||
if not self.sink.mute:
|
if not self.sink.mute:
|
||||||
notification.set_hint(
|
notification.set_hint(
|
||||||
'x-canonical-private-synchronous', GLib.Variant.new_string('audio'))
|
"x-canonical-private-synchronous", GLib.Variant.new_string("audio")
|
||||||
notification.set_hint(
|
)
|
||||||
'value', GLib.Variant.new_int32(round(self.volume())))
|
notification.set_hint("value", GLib.Variant.new_int32(round(self.volume())))
|
||||||
|
|
||||||
notification.show()
|
notification.show()
|
||||||
|
|
||||||
|
@ -79,33 +82,37 @@ class PAMedia:
|
||||||
def volume_format(self):
|
def volume_format(self):
|
||||||
volume = round(self.volume())
|
volume = round(self.volume())
|
||||||
|
|
||||||
return f'{volume}%'
|
return f"{volume}%"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='PulseAudio volume control')
|
parser = argparse.ArgumentParser(description="PulseAudio volume control")
|
||||||
parser.add_argument('-s', '--sink', type=int,
|
parser.add_argument("-s", "--sink", type=int, help="Select output sink to control")
|
||||||
help='Select output sink to control')
|
parser.add_argument(
|
||||||
parser.add_argument('command', metavar='CMD', type=str,
|
"command",
|
||||||
nargs='+', help='Command, one of: mute, up, down, set, get, sinks')
|
metavar="CMD",
|
||||||
|
type=str,
|
||||||
|
nargs="+",
|
||||||
|
help="Command, one of: mute, up, down, set, get, sinks",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
ctl = PAMedia(sink=args.sink)
|
ctl = PAMedia(sink=args.sink)
|
||||||
Notify.init('volumectl')
|
Notify.init("volumectl")
|
||||||
|
|
||||||
if args.command[0] == 'mute':
|
if args.command[0] == "mute":
|
||||||
ctl.toggle_mute()
|
ctl.toggle_mute()
|
||||||
elif args.command[0] == 'up':
|
elif args.command[0] == "up":
|
||||||
ctl.volume_up()
|
ctl.volume_up()
|
||||||
elif args.command[0] == 'down':
|
elif args.command[0] == "down":
|
||||||
ctl.volume_down()
|
ctl.volume_down()
|
||||||
elif args.command[0] == 'get':
|
elif args.command[0] == "get":
|
||||||
print(f'Volume: {ctl.volume_format()}')
|
print(f"Volume: {ctl.volume_format()}")
|
||||||
exit(0)
|
exit(0)
|
||||||
elif args.command[0] == 'set' and len(args.command) >= 2:
|
elif args.command[0] == "set" and len(args.command) >= 2:
|
||||||
ctl.volume_set(args.command[1])
|
ctl.volume_set(args.command[1])
|
||||||
elif args.command[0] == 'sinks':
|
elif args.command[0] == "sinks":
|
||||||
ctl.list_sinks()
|
ctl.list_sinks()
|
||||||
exit(0)
|
exit(0)
|
||||||
else:
|
else:
|
5
pkgs/pamedia/src/pamedia/__main__.py
Normal file
5
pkgs/pamedia/src/pamedia/__main__.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from . import main
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
3
pkgs/pamedia/src/pyproject.toml
Normal file
3
pkgs/pamedia/src/pyproject.toml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools", "wheel"]
|
||||||
|
build-backend = "setuptools.build_meta"
|
15
pkgs/pamedia/src/setup.cfg
Normal file
15
pkgs/pamedia/src/setup.cfg
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
[metadata]
|
||||||
|
name = pamedia
|
||||||
|
version = 0.1.0
|
||||||
|
description = Small utility to control the volume of the default PulseAudio sink, including notifications. Also compatible with Pipewire with the PulseAudio compatibility interface
|
||||||
|
author = "Erwin Boskma <erwin@datarift.nl>"
|
||||||
|
|
||||||
|
[options]
|
||||||
|
packages = pamedia
|
||||||
|
install_requires =
|
||||||
|
pulsectl
|
||||||
|
PyGObject
|
||||||
|
|
||||||
|
[options.entry_points]
|
||||||
|
console_scripts =
|
||||||
|
pamedia = pamedia:main
|
4
pkgs/pamedia/src/setup.py
Normal file
4
pkgs/pamedia/src/setup.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
setup()
|
|
@ -32,6 +32,7 @@ stdenv.mkDerivation rec {
|
||||||
xorg.libxcb
|
xorg.libxcb
|
||||||
xorg.xcbutil
|
xorg.xcbutil
|
||||||
xorg.xcbutilwm
|
xorg.xcbutilwm
|
||||||
|
xcb-util-cursor
|
||||||
xcbutilxrm
|
xcbutilxrm
|
||||||
which
|
which
|
||||||
wayland-protocols
|
wayland-protocols
|
||||||
|
|
Loading…
Reference in a new issue