aboutsummaryrefslogtreecommitdiff
path: root/pkgs
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2022-02-21 21:54:09 +0100
committerKarel Kočí <cynerd@email.cz>2022-06-10 14:05:48 +0200
commit93b0545d11bf8c7f065203f7f3eaf1d0e3730dce (patch)
treeda93fa5fcd14c493d8ccd86c98f40d26c9697869 /pkgs
downloadnixos-personal-93b0545d11bf8c7f065203f7f3eaf1d0e3730dce.tar.gz
nixos-personal-93b0545d11bf8c7f065203f7f3eaf1d0e3730dce.tar.bz2
nixos-personal-93b0545d11bf8c7f065203f7f3eaf1d0e3730dce.zip
Add initial version
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/default.nix28
-rw-r--r--pkgs/patches/0001-wpctl-Add-get-volume-command-and-functionality.patch123
-rw-r--r--pkgs/patches/0002-wpctl-allow-modifying-volume-levels-using-percentage.patch118
-rw-r--r--pkgs/python/notify-send.nix17
-rw-r--r--pkgs/theme/background-lnxpcs.nix41
-rw-r--r--pkgs/theme/delft-icon-theme.nix35
-rw-r--r--pkgs/theme/myswaylock.nix19
-rwxr-xr-xpkgs/theme/myswaylock.sh19
-rw-r--r--pkgs/theme/swaybackground.nix19
-rwxr-xr-xpkgs/theme/swaybackground.sh43
10 files changed, 462 insertions, 0 deletions
diff --git a/pkgs/default.nix b/pkgs/default.nix
new file mode 100644
index 0000000..2d9af4d
--- /dev/null
+++ b/pkgs/default.nix
@@ -0,0 +1,28 @@
+{ nixpkgs ? <nixpkgs>, nixlib ? nixpkgs.lib }:
+
+let
+ pkgs = nixpkgs // personalpkgs;
+ callPackage = nixlib.callPackageWith pkgs;
+
+ personalpkgs = with pkgs; {
+
+ wireplumber = nixpkgs.wireplumber.overrideAttrs (oldAttrs: {
+ patches = [
+ ./patches/0001-wpctl-Add-get-volume-command-and-functionality.patch
+ ./patches/0002-wpctl-allow-modifying-volume-levels-using-percentage.patch
+ ];
+ });
+
+ delft-icon-theme = callPackage ./theme/delft-icon-theme.nix { };
+ background-lnxpcs = callPackage ./theme/background-lnxpcs.nix { };
+ swaybackground = callPackage ./theme/swaybackground.nix { };
+ myswaylock = callPackage ./theme/myswaylock.nix { };
+
+ #personalPython3Packages = python3.withPackages (pythonPackages:
+ #with pythonPackages; [
+ # (pythonPackages.callPackage ./python/notify-send.nix { })
+ #]);
+
+ };
+
+in personalpkgs
diff --git a/pkgs/patches/0001-wpctl-Add-get-volume-command-and-functionality.patch b/pkgs/patches/0001-wpctl-Add-get-volume-command-and-functionality.patch
new file mode 100644
index 0000000..4bae05f
--- /dev/null
+++ b/pkgs/patches/0001-wpctl-Add-get-volume-command-and-functionality.patch
@@ -0,0 +1,123 @@
+From c44a369a14a13045462018e55595f1e2d83e1d6b Mon Sep 17 00:00:00 2001
+From: Varnit Singh <varnitcls@gmail.com>
+Date: Wed, 8 Jun 2022 09:18:34 +0000
+Subject: [PATCH 1/2] wpctl: Add get-volume command and functionality
+
+---
+ src/tools/wpctl.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 86 insertions(+)
+
+diff --git a/src/tools/wpctl.c b/src/tools/wpctl.c
+index ca5ea01..9f7c6bb 100644
+--- a/src/tools/wpctl.c
++++ b/src/tools/wpctl.c
+@@ -47,6 +47,10 @@ static struct {
+ gboolean is_pid;
+ } set_volume;
+
++ struct {
++ guint64 id;
++ } get_volume;
++
+ struct {
+ guint64 id;
+ guint mute;
+@@ -471,6 +475,78 @@ status_run (WpCtl * self)
+ g_main_loop_quit (self->loop);
+ }
+
++/* get-volume */
++
++static gboolean
++get_volume_parse_positional (gint argc, gchar ** argv, GError **error)
++{
++ if (argc < 3) {
++ g_set_error (error, wpctl_error_domain_quark(), 0,
++ "ID is required");
++ return FALSE;
++ } else {
++ return parse_id (true, false, argv[2], &cmdline.get_volume.id, error);
++ }
++}
++
++static gboolean
++get_volume_prepare (WpCtl * self, GError ** error)
++{
++ wp_object_manager_add_interest (self->om, WP_TYPE_NODE, NULL);
++ wp_object_manager_request_object_features (self->om, WP_TYPE_GLOBAL_PROXY,
++ WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL);
++ return TRUE;
++}
++
++static void
++do_print_volume (WpCtl * self, WpPipewireObject *proxy)
++{
++ g_autoptr (WpPlugin) mixer_api = wp_plugin_find (self->core, "mixer-api");
++ GVariant *variant = NULL;
++ gboolean mute = FALSE;
++ gdouble volume = 1.0;
++ guint32 id = wp_proxy_get_bound_id (WP_PROXY (proxy));
++
++ g_signal_emit_by_name (mixer_api, "get-volume", id, &variant);
++ if (!variant) {
++ fprintf (stderr, "Node %d does not support volume\n", id);
++ return;
++ }
++ g_variant_lookup (variant, "volume", "d", &volume);
++ g_variant_lookup (variant, "mute", "b", &mute);
++ g_clear_pointer (&variant, g_variant_unref);
++
++ printf ("Volume: %.2f%s", volume, mute ? " [MUTED]\n" : "\n");
++}
++
++static void
++get_volume_run (WpCtl * self)
++{
++ g_autoptr (WpPlugin) def_nodes_api = NULL;
++ g_autoptr (GError) error = NULL;
++ g_autoptr (WpPipewireObject) proxy = NULL;
++ guint32 id;
++
++ def_nodes_api = wp_plugin_find (self->core, "default-nodes-api");
++
++ if (!translate_id (def_nodes_api, cmdline.get_volume.id, &id, &error)) {
++ fprintf(stderr, "Translate ID error: %s\n\n", error->message);
++ goto out;
++ }
++
++ proxy = wp_object_manager_lookup (self->om, WP_TYPE_GLOBAL_PROXY,
++ WP_CONSTRAINT_TYPE_G_PROPERTY, "bound-id", "=u", id, NULL);
++ if (!proxy) {
++ fprintf (stderr, "Node '%d' not found\n", id);
++ goto out;
++ }
++
++ do_print_volume (self, proxy);
++
++out:
++ g_main_loop_quit (self->loop);
++}
++
+ /* inspect */
+
+ static gboolean
+@@ -1150,6 +1226,16 @@ static const struct subcommand {
+ .prepare = status_prepare,
+ .run = status_run,
+ },
++ {
++ .name = "get-volume",
++ .positional_args = "ID",
++ .summary = "Displays volume information about the specified node in PipeWire",
++ .description = NULL,
++ .entries = { { NULL } },
++ .parse_positional = get_volume_parse_positional,
++ .prepare = get_volume_prepare,
++ .run = get_volume_run,
++ },
+ {
+ .name = "inspect",
+ .positional_args = "ID",
+--
+2.36.1
+
diff --git a/pkgs/patches/0002-wpctl-allow-modifying-volume-levels-using-percentage.patch b/pkgs/patches/0002-wpctl-allow-modifying-volume-levels-using-percentage.patch
new file mode 100644
index 0000000..9e51797
--- /dev/null
+++ b/pkgs/patches/0002-wpctl-allow-modifying-volume-levels-using-percentage.patch
@@ -0,0 +1,118 @@
+From 43d8753c5ef4cbd4d2f6558182b290d083644521 Mon Sep 17 00:00:00 2001
+From: Varnit Singh <varnitcls@gmail.com>
+Date: Wed, 8 Jun 2022 09:25:45 +0000
+Subject: [PATCH 2/2] wpctl: allow modifying volume levels using
+ percentage/step amount.
+
+---
+ src/tools/wpctl.c | 63 ++++++++++++++++++++++++++++++++++++++++++++---
+ 1 file changed, 59 insertions(+), 4 deletions(-)
+
+diff --git a/src/tools/wpctl.c b/src/tools/wpctl.c
+index 9f7c6bb..0f5bc8c 100644
+--- a/src/tools/wpctl.c
++++ b/src/tools/wpctl.c
+@@ -45,6 +45,7 @@ static struct {
+ guint64 id;
+ gfloat volume;
+ gboolean is_pid;
++ gchar type;
+ } set_volume;
+
+ struct {
+@@ -846,11 +847,38 @@ set_volume_parse_positional (gint argc, gchar ** argv, GError **error)
+ {
+ if (argc < 4) {
+ g_set_error (error, wpctl_error_domain_quark(), 0,
+- "ID and VOL are required");
++ "ID and VOL[%%][-/+] are required");
++ return FALSE;
++ }
++
++ GRegex *regex = g_regex_new ("^(\\d*\\.?\\d*)(%?)([-+]?)$", 0, 0, NULL);
++ GMatchInfo *info = NULL;
++
++ if (g_regex_match(regex, argv[3], 0, &info)) {
++ cmdline.set_volume.volume = strtof(g_match_info_fetch(info, 1), NULL);
++ cmdline.set_volume.type = 'a';
++
++ if (g_strcmp0(g_match_info_fetch(info, 2), "%") == 0) {
++ cmdline.set_volume.type = 'p';
++ }
++
++ if (g_strcmp0(g_match_info_fetch(info, 3), "-") == 0) {
++ cmdline.set_volume.volume = -(cmdline.set_volume.volume);
++ if (cmdline.set_volume.type != 'p') {
++ cmdline.set_volume.type = 's';
++ }
++ } else if (g_strcmp0(g_match_info_fetch(info, 3), "+") == 0 && cmdline.set_volume.type != 'p') {
++ cmdline.set_volume.type = 's';
++ }
++ g_match_info_free (info);
++ g_regex_unref (regex);
++ } else {
++ g_regex_unref (regex);
++ g_set_error (error, wpctl_error_domain_quark(), 0,
++ "Invalid volume argument. See wpctl set-volume --help");
+ return FALSE;
+ }
+
+- cmdline.set_volume.volume = strtof (argv[3], NULL);
+ return parse_id (!cmdline.set_volume.is_pid, false, argv[2],
+ &cmdline.set_volume.id, error);
+ }
+@@ -874,6 +902,7 @@ do_set_volume (WpCtl * self, WpPipewireObject *proxy)
+ g_autoptr (GError) error = NULL;
+ GVariant *variant = NULL;
+ gboolean res = FALSE;
++ gdouble curr_volume = 1.0;
+ guint32 id = wp_proxy_get_bound_id (WP_PROXY (proxy));
+
+ if (WP_IS_ENDPOINT (proxy)) {
+@@ -885,6 +914,27 @@ do_set_volume (WpCtl * self, WpPipewireObject *proxy)
+ id = atoi (str);
+ }
+
++ g_signal_emit_by_name (mixer_api, "get-volume", id, &variant);
++ if (!variant) {
++ fprintf (stderr, "Node %d does not support volume\n", id);
++ g_clear_pointer (&variant, g_variant_unref);
++ return FALSE;
++ }
++ g_variant_lookup (variant, "volume", "d", &curr_volume);
++ g_clear_pointer (&variant, g_variant_unref);
++
++ if (cmdline.set_volume.type == 'a') {
++ cmdline.set_volume.volume = cmdline.set_volume.volume;
++ } else if (cmdline.set_volume.type == 's') {
++ cmdline.set_volume.volume = (cmdline.set_volume.volume + curr_volume);
++ } else if (cmdline.set_volume.type == 'p') {
++ gfloat delta = (cmdline.set_volume.volume) * (curr_volume);
++ cmdline.set_volume.volume = (curr_volume + delta);
++ }
++ if (cmdline.set_volume.volume < 0) {
++ cmdline.set_volume.volume = 0.0;
++ }
++
+ g_variant_builder_add (&b, "{sv}", "volume",
+ g_variant_new_double (cmdline.set_volume.volume));
+ variant = g_variant_builder_end (&b);
+@@ -1266,8 +1316,13 @@ static const struct subcommand {
+ },
+ {
+ .name = "set-volume",
+- .positional_args = "ID VOL",
+- .summary = "Sets the volume of ID to VOL (floating point, 1.0 is 100%%)",
++ .positional_args = "ID VOL[%%][-/+]",
++ .summary = "Sets the volume of ID from specified argument. "
++ "(floating point, 1.0 is 100%%)\n VOL%%[-/+] - "
++ "Step up/down volume by specified percent (Example:"
++ " 0.5%%+)\n VOL[-/+] - Step up/down volume by"
++ " specified value (Example: 0.5+)\n VOL - Set "
++ "volume as the specified value (Example: 0.5)",
+ .description = NULL,
+ .entries = {
+ { "pid", 'p', G_OPTION_FLAG_NONE, G_OPTION_ARG_NONE,
+--
+2.36.1
+
diff --git a/pkgs/python/notify-send.nix b/pkgs/python/notify-send.nix
new file mode 100644
index 0000000..8dfe953
--- /dev/null
+++ b/pkgs/python/notify-send.nix
@@ -0,0 +1,17 @@
+{ lib, buildPythonPackage, fetchPypi }:
+
+buildPythonPackage rec {
+ pname = "notify-send";
+ version = "0.0.20";
+
+ src = fetchPypi {
+ inherit pname version;
+ sha256 = "6fddbc5b201728984d2de809959bb6aecf9abb0de5cfa55c7324ca6f48f41e03";
+ };
+
+ meta = with lib; {
+ description = "Notify send";
+ homepage = "https://pypi.org/project/notify-send";
+ license = licenses.gpl3;
+ };
+}
diff --git a/pkgs/theme/background-lnxpcs.nix b/pkgs/theme/background-lnxpcs.nix
new file mode 100644
index 0000000..a3983af
--- /dev/null
+++ b/pkgs/theme/background-lnxpcs.nix
@@ -0,0 +1,41 @@
+{ lib, stdenvNoCC, fetchFromGitHub, imagemagick }:
+
+stdenvNoCC.mkDerivation rec {
+ pname = "background-lnxpcs";
+ version = "20190411";
+
+ src = fetchFromGitHub {
+ owner = "cynerd";
+ repo = "lnxpcs";
+ rev = "fd4487e1989fc040490fa437a2651d37afcde637";
+ sha256 = "vtyyG0EHRmgWlxHmHgeckwtOv7t3C+hsuTt/vBdrRQM=";
+ };
+
+ nativeBuildInputs = [ imagemagick ];
+
+ wallpapers = "bash cron gcc gnu gnu-linux iptables kernel kill python root su sudo vim";
+ buildPhase = ''
+ for img in $wallpapers; do
+ echo "Generating: $img"
+ ./makemywall 1920 1080 "cards/black/$img-card-black.png"
+ ./makemywall 2560 1440 "cards/black/$img-card-black.png"
+ ./makemywall 2560 1600 "cards/black/$img-card-black.png"
+ done
+ '';
+
+ installPhase = ''
+ mkdir -p $out
+ for img in $wallpapers; do
+ mv $img-card-black-1920x1080.png $out/
+ mv $img-card-black-2560x1440.png $out/
+ mv $img-card-black-2560x1600.png $out/
+ done
+ '';
+
+ meta = with lib; {
+ description = "Background pictures from lnxpcs and relevant scripts";
+ homepage = "https://mega.nz/#F!mXgW3apI!Tdikb01SoOaTmNLiaTRhMg";
+ license = licenses.gpl3Only;
+ platforms = platforms.linux;
+ };
+}
diff --git a/pkgs/theme/delft-icon-theme.nix b/pkgs/theme/delft-icon-theme.nix
new file mode 100644
index 0000000..08ed773
--- /dev/null
+++ b/pkgs/theme/delft-icon-theme.nix
@@ -0,0 +1,35 @@
+{ lib, stdenv, stdenvNoCC, fetchFromGitHub, gtk3, gnome-icon-theme, hicolor-icon-theme }:
+
+stdenv.mkDerivation rec {
+ pname = "delft-icon-theme";
+ version = "1.15";
+
+ src = fetchFromGitHub {
+ owner = "madmaxms";
+ repo = "iconpack-delft";
+ rev = "v${version}";
+ sha256 = "fluSh2TR1CdIW54wkUp1QRB0m9akFKnSn4d+0z6gkLA=";
+ };
+
+ nativeBuildInputs = [ gtk3 ];
+
+ propagatedBuildInputs = [ gnome-icon-theme hicolor-icon-theme ];
+
+ dontDropIconThemeCache = true;
+
+ installPhase = ''
+ mkdir -p $out/share/icons
+ cp -a Delft* $out/share/icons/
+
+ for theme in $out/share/icons/*; do
+ gtk-update-icon-cache $theme
+ done
+ '';
+
+ meta = with lib; {
+ description = "Delft icon theme";
+ homepage = "https://github.com/madmaxms/iconpack-delft";
+ license = licenses.gpl3Only;
+ platforms = platforms.linux;
+ };
+}
diff --git a/pkgs/theme/myswaylock.nix b/pkgs/theme/myswaylock.nix
new file mode 100644
index 0000000..6b74ce1
--- /dev/null
+++ b/pkgs/theme/myswaylock.nix
@@ -0,0 +1,19 @@
+{ lib, stdenvNoCC, makeWrapper
+, bash, jq, sway, swaylock
+, background-lnxpcs
+}:
+
+stdenvNoCC.mkDerivation {
+ pname = "myswaylock";
+ version = "1.0";
+
+ nativeBuildInputs = [ makeWrapper ];
+ phases = [ "installPhase" ];
+ installPhase = ''
+ mkdir -p $out/bin
+ cp ${./myswaylock.sh} $out/bin/myswaylock
+ wrapProgram $out/bin/myswaylock \
+ --prefix PATH : ${lib.makeBinPath [ bash jq sway swaylock ]} \
+ --prefix BACKGROUND_LNXPCS : ${ background-lnxpcs }
+ '';
+}
diff --git a/pkgs/theme/myswaylock.sh b/pkgs/theme/myswaylock.sh
new file mode 100755
index 0000000..c204a57
--- /dev/null
+++ b/pkgs/theme/myswaylock.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+# Switch to the US keyboard (to make sure that we have the correct one)
+swaymsg input type:keyboard xkb_layout us
+
+resolution="$(swaymsg -t get_outputs \
+ | jq -r '.[0].rect | [.width,.height] | join("x")')"
+case "$resolution" in
+ 1920x1080|2560x1440|2560x1600)
+ ;;
+ *)
+ resolution="1920x1080"
+ ;;
+esac
+
+exec swaylock -f \
+ -n -c 000000 \
+ -i "$(shuf -n1 -e "$BACKGROUND_LNXPCS"/*"$resolution.png")" \
+ -s fill
diff --git a/pkgs/theme/swaybackground.nix b/pkgs/theme/swaybackground.nix
new file mode 100644
index 0000000..856d774
--- /dev/null
+++ b/pkgs/theme/swaybackground.nix
@@ -0,0 +1,19 @@
+{ lib, stdenvNoCC, makeWrapper
+, bash, jq, sway
+, background-lnxpcs
+}:
+
+stdenvNoCC.mkDerivation {
+ pname = "swaybackground";
+ version = "1.0";
+
+ nativeBuildInputs = [ makeWrapper ];
+ phases = [ "installPhase" ];
+ installPhase = ''
+ mkdir -p $out/bin
+ cp ${./swaybackground.sh} $out/bin/swaybackground
+ wrapProgram $out/bin/swaybackground \
+ --prefix PATH : ${lib.makeBinPath [ bash jq sway ]} \
+ --prefix BACKGROUND_LNXPCS : ${ background-lnxpcs }
+ '';
+}
diff --git a/pkgs/theme/swaybackground.sh b/pkgs/theme/swaybackground.sh
new file mode 100755
index 0000000..0999943
--- /dev/null
+++ b/pkgs/theme/swaybackground.sh
@@ -0,0 +1,43 @@
+#!/usr/bin/env bash
+
+_background() {
+ local resolution="${1:-1920x1080}"
+ case "$resolution" in
+ 1920x1080|2560x1440|2560x1600)
+ ;;
+ *)
+ resolution="1920x1080"
+ ;;
+ esac
+ find "$BACKGROUND_LNXPCS" -type f -name "*-$resolution.png" | shuf -n 1
+}
+
+background() {
+ local width="$1"
+ local height="$2"
+ local res
+ res="$(_background "${width}x${height}")"
+ if [ -n "$res" ]; then
+ res="$(_background)"
+ fi
+ echo "$res"
+}
+
+set_backgrounds() {
+ local ipc="$1"
+ swaymsg -t get_outputs | jq -r '.[] | [.name,.rect.width,.rect.height] | join(",")' \
+ | while IFS=, read -r name width height; do
+ swaymsg $ipc \
+ output "$name" \
+ background "$(background "$width" "$height")" fill
+ done
+}
+
+if [ -n "$WAYLAND_DISPLAY" ]; then
+ set_backgrounds
+else
+ find "/run/user/$(id -u)/" -name "sway-ipc*" \
+ | while read -r ipc; do
+ set_backgrounds "-s '$ipc'"
+ done
+fi