This commit is contained in:
krizej 2024-08-06 13:41:05 +02:00
parent 35ae10e760
commit 2def094022
6 changed files with 90 additions and 23 deletions

View file

@ -52,6 +52,7 @@
};
home-manager.enable = true;
xdg.enable = true;
stuff = {
xserver.enable = true;
@ -67,6 +68,7 @@
documentation.enable = true;
theme.enable = true;
printing.enable = true;
mpd.enable = true;
autorandr = {
enable = true;

View file

@ -51,6 +51,7 @@
documentation.enable = true;
theme.enable = true;
printing.enable = true;
xdg.enable = true;
xserver = {
enable = true;

View file

@ -22,5 +22,7 @@
./stuff/gaming.nix
./stuff/other-desktop-programs.nix
./stuff/other-dev-programs.nix
./stuff/mpd.nix
./stuff/xdg.nix
];
}

View file

@ -68,14 +68,6 @@ in {
size = 10.0;
};
bars = [
{
inherit fonts;
trayOutput = "primary";
statusCommand = "${pkgs.i3status}/bin/i3status";
}
];
defaultWorkspace = "workspace number 1";
workspaceOutputAssign = lib.mapAttrsToList
@ -90,7 +82,6 @@ in {
startup = [
{ command = "autotiling &"; notification = false; }
# { command = "mpd &"; notification = false; }
]
++ optionals config.chuj.stuff.dunst.enable [{ command = "dunst &"; notification = false; }]
++ optionals config.chuj.stuff.flameshot.enable [{ command = "flameshot &"; notification = false; }]
@ -98,6 +89,16 @@ in {
{ command = "i3-msg \"workspace ${cfg.communicators.workspace}; append_layout ${../../files/i3_communicators_layout.json}\""; notification = false; }
{ command = "discord &"; notification = false; }
{ command = "element-desktop &"; notification = false; }
]
++ optionals config.chuj.stuff.mpd.enable [
{ command = "${pkgs.writeShellScriptBin "mpdstatus" ''
while true; do
status=$(mpc status | sed -n 2p | cut -d' ' -f1)
title=$(basename "$(mpc current -f '%file%')" .mp3)
echo "$status $title" > /tmp/i3-mpd-status-stuff
sleep 1
done
''}/bin/mpdstatus &"; notification = false; }
];
modes = let
@ -119,7 +120,7 @@ in {
mod = modifier;
execns = "exec --no-startup-id";
cmd_and_center = cmd: "${execns} i3-msg '${cmd}' && i3custom-center-mouse-on-focus";
in {
in mergeAttrs {
# Program keybinds
"${mod}+Return" = ''${execns} ${if config.chuj.stuff.alacritty.enable then "alacritty" else "i3-sensible-terminal"}'';
"${mod}+Shift+s" = mkIf config.chuj.stuff.flameshot.enable "${execns} flameshot gui";
@ -132,17 +133,6 @@ in {
"Ctrl+F10" = "${execns} pamixer --decrease 5";
"Ctrl+F11" = "${execns} pamixer --increase 5";
# MPD controls
# "Ctrl+F5" = "exec ~/music/select_music.sh";
# "Ctrl+F6" = "exec mpc prev";
# "Ctrl+F7" = "exec mpc toggle";
# "Ctrl+F8" = "exec mpc next";
# "Ctrl+Shift+F6" = "exec mpc seek -3";
# "Ctrl+Shift+F7" = "exec mpc clear";
# "Ctrl+Shift+F8" = "exec mpc seek +3";
# "Ctrl+Shift+F10" = ''exec mpc volume -5 && dunstify "mpc $(mpc volume)" -r 420'';
# "Ctrl+Shift+F11" = ''exec mpc volume +5 && dunstify "mpc $(mpc volume)" -r 420'';
# General i3 keybindings
"${mod}+f" = cmd_and_center "fullscreen toggle";
"${mod}+r" = "mode resize";
@ -189,7 +179,26 @@ in {
"${mod}+Shift+8" = cmd_and_center "move container to workspace number 8";
"${mod}+Shift+9" = cmd_and_center "move container to workspace number 9";
"${mod}+Shift+0" = cmd_and_center "move container to workspace number 10";
};
} (optionalAttrs config.chuj.stuff.mpd.enable {
# MPD controls
"Ctrl+F5" = "exec mpdfdial.sh";
"Ctrl+F6" = "exec mpc prev";
"Ctrl+F7" = "exec mpc toggle";
"Ctrl+F8" = "exec mpc next";
"Ctrl+Shift+F6" = "exec mpc seek -3";
"Ctrl+Shift+F7" = "exec mpc clear";
"Ctrl+Shift+F8" = "exec mpc seek +3";
"Ctrl+Shift+F10" = ''exec mpc volume -5 && dunstify "mpc $(mpc volume)" -r 420'';
"Ctrl+Shift+F11" = ''exec mpc volume +5 && dunstify "mpc $(mpc volume)" -r 420'';
});
bars = [
{
inherit fonts;
trayOutput = "primary";
statusCommand = "${pkgs.i3status}/bin/i3status";
}
];
};
};
@ -209,6 +218,15 @@ in {
modules = mergeAttrs {
# todo MPD module (using read_file most likely, or switch to i3blocks)
"read_file mpd" = {
position = -1;
settings = {
format = "%content";
path = "/tmp/i3-mpd-status-stuff";
color_good = "#ffffff";
};
};
"cpu_usage" = {
position = 0;
settings = {

42
modules/stuff/mpd.nix Normal file
View file

@ -0,0 +1,42 @@
{ lib, pkgs, config, ...}: let
inherit (lib) mkIf mkEnableOption mkOption;
cfg = config.chuj.stuff.mpd;
user = config.chuj.system.user;
in {
options.chuj.stuff.mpd = {
enable = mkEnableOption "mpd";
};
config = mkIf cfg.enable {
home-manager.users.${user} = {
services.mpd = {
enable = true;
extraConfig = ''
audio_output {
type "pulse"
name "PulseAudio Output"
}
'';
};
home.packages = let
yad = "${pkgs.yad}/bin/yad";
dunstify = "${pkgs.dunst}/bin/dunstify";
mpc = "${pkgs.mpc-cli}/bin/mpc";
cut = "${pkgs.coreutils}/bin/cut";
in [
pkgs.mpc-cli
(pkgs.writeShellScriptBin "mpdfdial.sh" ''
path=$(${yad} --file --directory | ${cut} -d "/" -f5-)
${dunstify} "playing from \"$path\""
${mpc} update
${mpc} rescan
${mpc} add "$path"
${mpc} random on
${mpc} repeat on
${mpc} play
'')
];
};
};
}

View file

@ -1,6 +1,7 @@
{ lib, pkgs, config, ...}: let
inherit (lib) mkIf mkEnableOption mkOption;
cfg = config.chuj.xdg;
user = config.chuj.system.user;
in {
options.chuj.xdg = {
enable = mkEnableOption "xdg";
@ -37,11 +38,12 @@ in {
};
};
home.sessionVariables = {
home.sessionVariables = let
XDG_DATA_HOME = hmCfg.xdg.dataHome;
XDG_CONFIG_HOME = hmCfg.xdg.configHome;
XDG_STATE_HOME = hmCfg.xdg.stateHome;
XDG_CACHE_HOME = hmCfg.xdg.cacheHome;
in {
ANDROID_USER_HOME = "${XDG_DATA_HOME}/android";
ANDROID_HOME = "${XDG_DATA_HOME}/android/sdk";
GRADLE_USER_HOME = "${XDG_DATA_HOME}/gradle";