Run Hyprland on Riva

This commit is contained in:
Thomas Avé 2024-10-01 22:55:37 +02:00
parent 84b400bb6d
commit fa9e9e25af
3 changed files with 91 additions and 73 deletions

View File

@ -2,8 +2,7 @@
{
imports = [
(import ./utils/common.nix { inherit inputs config pkgs; })
./ssh
(import ./utils/desktop.nix { inherit inputs config pkgs; })
];
programs.ssh.matchBlocks."*".identityFile = "/home/user/.secrets/SSH/Riva/id_ed25519";
@ -13,4 +12,19 @@
jq
evince
];
wayland.windowManager.hyprland.settings = {
"$mainMod" = pkgs.lib.mkForce "ALT_L";
"$altMod" = pkgs.lib.mkForce "SUPER";
monitor = [
"Virtual-1,2000x1200@60,0x0,1"
];
general.gaps_out = 1;
};
services.hyprpaper = {
settings = {
wallpaper = [
"Virtual-1,${./hyprland/files/wallpaper.png}"
];
};
};
}

View File

@ -2,7 +2,6 @@
let
playerctl = "${pkgs.playerctl}/bin/playerctl";
wl-paste = "${pkgs.wl-clipboard}/bin/wl-paste";
ags = "${pkgs.ags}/bin/ags";
nautilus = "${pkgs.nautilus}/bin/nautilus";
gnome-calendar = "${pkgs.gnome-calendar}/bin/gnome-calendar";
wpctl = "${pkgs.wireplumber}/bin/wpctl";
@ -11,12 +10,12 @@ let
rofi = "${pkgs.rofi}/bin/rofi";
jq = "${pkgs.jq}/bin/jq";
rofi-ykman = pkgs.writeShellScriptBin "rofi-ykman" ''
accounts=$(${pkgs.yubikey-manager}/bin/ykman oath accounts list)
prompt="YubiKey OATH"
account=$(echo "''${accounts/, TOTP/\n}" | awk '{ print $0 "\0icon\x1fyubioath"; }' | ${rofi} -dmenu -i -p "$prompt" ''${shortcuts[@]})
code=$(${pkgs.yubikey-manager}/bin/ykman oath accounts code "$account")
IFS=', ' read -r -a code <<< "$code"
echo -n "''${code[-1]}" | ${pkgs.wl-clipboard}/bin/wl-copy;
accounts=$(${pkgs.yubikey-manager}/bin/ykman oath accounts list)
prompt="YubiKey OATH"
account=$(echo "''${accounts/, TOTP/\n}" | awk '{ print $0 "\0icon\x1fyubioath"; }' | ${rofi} -dmenu -i -p "$prompt" ''${shortcuts[@]})
code=$(${pkgs.yubikey-manager}/bin/ykman oath accounts code "$account")
IFS=', ' read -r -a code <<< "$code"
echo -n "''${code[-1]}" | ${pkgs.wl-clipboard}/bin/wl-copy;
'';
workspace_command_prefix = "split-";
@ -27,47 +26,47 @@ let
# hyprland_plugins = [];
launch_alacritty = pkgs.writeShellScriptBin "launch_alacritty" ''
function find_leaf_pid(){
local PID=$1
local CHILD_PID=$(pgrep -P "$PID")
if [ "$CHILD_PID" != "" ]; then
local RET=$(find_leaf_pid "$CHILD_PID")
if [ "$RET" != "" ]; then
PID=$RET
fi
fi
local NAME=$(ps -p "$PID" -o comm=)
if [ "$NAME" == "zsh" ]; then
echo "$PID"
elif [ "$NAME" == "ssh" ]; then
echo "$PID"
fi
}
function find_leaf_pid(){
local PID=$1
local CHILD_PID=$(pgrep -P "$PID")
if [ "$CHILD_PID" != "" ]; then
local RET=$(find_leaf_pid "$CHILD_PID")
if [ "$RET" != "" ]; then
PID=$RET
fi
fi
local NAME=$(ps -p "$PID" -o comm=)
if [ "$NAME" == "zsh" ]; then
echo "$PID"
elif [ "$NAME" == "ssh" ]; then
echo "$PID"
fi
}
LEAF_PID=$(find_leaf_pid "$1")
if [ "$(ps -p "$LEAF_PID" -o comm=)" == "ssh" ]; then
SSH_COMMAND=$(ps -p "$LEAF_PID" -o args --no-headers)
if [[ "$SSH_COMMAND" == *"waypipe"* ]]; then
CLIENT=$(echo "$SSH_COMMAND" | awk '{ print $5 }')
PREVIOUS_SESSION_ID=$(grep -z "SSH_SESSION_ID" "/proc/$LEAF_PID/environ" | xargs -0 -n 1 | grep -oP "[0-9]*")
SSH_SESSION_ID=$RANDOM
${alacritty} -e zsh -c "SSH_SESSION_ID=$SSH_SESSION_ID waypipe ssh -t \"$CLIENT\" env SSH_SESSION_ID=\"$SSH_SESSION_ID\" PREVIOUS_SESSION_ID=\"$PREVIOUS_SESSION_ID\" \"zsh --login\""
else
${alacritty} -e zsh -c "ssh -t \"$(echo "$SSH_COMMAND" | awk '{ print $2 }')\""
fi
LEAF_PID=$(find_leaf_pid "$1")
if [ "$(ps -p "$LEAF_PID" -o comm=)" == "ssh" ]; then
SSH_COMMAND=$(ps -p "$LEAF_PID" -o args --no-headers)
if [[ "$SSH_COMMAND" == *"waypipe"* ]]; then
CLIENT=$(echo "$SSH_COMMAND" | awk '{ print $5 }')
PREVIOUS_SESSION_ID=$(grep -z "SSH_SESSION_ID" "/proc/$LEAF_PID/environ" | xargs -0 -n 1 | grep -oP "[0-9]*")
SSH_SESSION_ID=$RANDOM
${alacritty} -e zsh -c "SSH_SESSION_ID=$SSH_SESSION_ID waypipe ssh -t \"$CLIENT\" env SSH_SESSION_ID=\"$SSH_SESSION_ID\" PREVIOUS_SESSION_ID=\"$PREVIOUS_SESSION_ID\" \"zsh --login\""
else
${alacritty} -e zsh -c "ssh -t \"$(echo "$SSH_COMMAND" | awk '{ print $2 }')\""
fi
else # Not an ssh session
if [ "$(ps -p "$1" -o comm=)" == "alacritty" ]; then
CWD=$(readlink -e /proc/"$LEAF_PID"/cwd)
if [ "$CWD" != "" ]; then
${alacritty} --working-directory "$CWD"
else
${alacritty}
fi
else
${alacritty}
fi
fi
else # Not an ssh session
if [ "$(ps -p "$1" -o comm=)" == "alacritty" ]; then
CWD=$(readlink -e /proc/"$LEAF_PID"/cwd)
if [ "$CWD" != "" ]; then
${alacritty} --working-directory "$CWD"
else
${alacritty}
fi
else
${alacritty}
fi
fi
'';
in {
home.packages = [
@ -96,7 +95,8 @@ in {
package = inputs.hyprland.packages.${pkgs.system}.hyprland;
plugins = [ ] ++ hyprland_plugins;
settings = {
"$mainMod" = "SUPER";
"$mainMod" = pkgs.lib.mkDefault "SUPER";
"$altMod" = pkgs.lib.mkDefault "ALT_L";
exec-once = [
"hyprpaper"
"ags"
@ -130,7 +130,7 @@ in {
input = {
kb_layout = "us";
follow_mouse = 1;
kb_options = pkgs.lib.mkDefault "compose:rctrl";
kb_options = pkgs.lib.mkDefault "compose:rctrl, shift:both_capslock, caps:ctrl_modifier";
numlock_by_default = true;
};
binds = { scroll_event_delay = 1; };
@ -162,8 +162,7 @@ in {
workspace_swipe_invert = false;
};
bindr = [
"$mainMod, SUPER_L, exec, pkill rofi || ${rofi} -show drun"
"$mainMod, SUPER_R, exec, pkill rofi || ${rofi} -show drun"
"$mainMod, $mainMod, exec, pkill rofi || ${rofi} -show drun"
];
bindm = [
"$mainMod, mouse:272, movewindow"
@ -181,14 +180,10 @@ in {
"$mainMod, F, togglefloating,"
"$mainMod, SPACE, togglesplit, # dwindle"
"CONTROL_L ALT_L, L, exec, ${swaylock}"
''
$mainMod, C, exec, cliphist list | awk '{print $0, "\0icon\x1fcom.github.davidmhewitt.clipped"; }' | ${rofi} -dmenu -display-columns 2 | cliphist decode | wl-copy''
''$mainMod, C, exec, cliphist list | awk '{print $0, "\0icon\x1fcom.github.davidmhewitt.clipped"; }' | ${rofi} -dmenu -display-columns 2 | cliphist decode | wl-copy''
"$mainMod, Y, exec, ${rofi-ykman}/bin/rofi-ykman"
"$mainMod, N, exec, ${./files/rofi-ssh.sh}"
"$mainMod, Escape, exec, ${rofi} -show power-menu -modi power-menu:${
./files/rofi-power-menu.sh
}"
"$mainMod, Escape, exec, ${rofi} -show power-menu -modi power-menu:${ ./files/rofi-power-menu.sh }"
",XF86MonBrightnessUp, exec, ${pkgs.brightnessctl}/bin/brightnessctl set +10%"
",XF86MonBrightnessDown, exec, ${pkgs.brightnessctl}/bin/brightnessctl set 10%-"
@ -217,26 +212,27 @@ in {
"$mainMod SHIFT, L, movewindow, r"
"$mainMod SHIFT, K, movewindow, u"
"$mainMod SHIFT, J, movewindow, d"
"$mainMod ALT, L, resizeactive, 20 0"
"$mainMod ALT, H, resizeactive, -20 0"
"$mainMod ALT, K, resizeactive, 0 -20"
"$mainMod ALT, J, resizeactive, 0 20"
"$mainMod $altMod, L, resizeactive, 20 0"
"$mainMod $altMod, H, resizeactive, -20 0"
"$mainMod $altMod, K, resizeactive, 0 -20"
"$mainMod $altMod, J, resizeactive, 0 20"
"$mainMod SHIFT, T, ${workspace_command_prefix}movetoworkspace, empty"
"$mainMod, T, ${workspace_command_prefix}workspace, empty"
"$mainMod, TAB, ${workspace_command_prefix}workspace, m+1"
"$mainMod SHIFT, TAB, ${workspace_command_prefix}workspace, m-1"
"$mainMod, Caps_Lock, ${workspace_command_prefix}workspace, m+1"
"$mainMod SHIFT, Caps_Lock, ${workspace_command_prefix}workspace, m-1"
] ++ (
# workspaces
# binds $mod + [shift +] {1..10} to [move to] workspace {1..10}
builtins.concatLists (builtins.genList
(x:
let
ws = let c = (x + 1) / 10; in builtins.toString (x + 1 - (c * 10));
in
[
"$mainMod, ${ws}, ${workspace_command_prefix}workspace, ${toString (x + 1)}"
"$mainMod SHIFT, ${ws}, ${workspace_command_prefix}movetoworkspace, ${toString (x + 1)}"
]) 10));
# workspaces
# binds $mod + [shift +] {1..10} to [move to] workspace {1..10}
builtins.concatLists (builtins.genList (x:
let
ws = let c = (x + 1) / 10; in builtins.toString (x + 1 - (c * 10));
in
[
"$mainMod, ${ws}, ${workspace_command_prefix}workspace, ${toString (x + 1)}"
"$mainMod SHIFT, ${ws}, ${workspace_command_prefix}movetoworkspace, ${toString (x + 1)}"
]) 10));
};
};
}

View File

@ -4,6 +4,7 @@ let
in {
imports = [
(import ../Common/default.nix { inherit inputs config pkgs; })
(import ../Common/desktop.nix { inherit inputs pkgs config; })
(import ../Common/nfs.nix { inherit pkgs serverIP; })
];
@ -24,4 +25,11 @@ in {
}];
};
};
services.sunshine = {
enable = true;
autoStart = true;
capSysAdmin = true;
openFirewall = true;
};
}