Skip to content

Commit

Permalink
hyprland
Browse files Browse the repository at this point in the history
  • Loading branch information
suderman committed Jul 18, 2024
1 parent a997429 commit 70f563a
Show file tree
Hide file tree
Showing 12 changed files with 167 additions and 195 deletions.
4 changes: 0 additions & 4 deletions modules/hyprland/bin/focus.sh

This file was deleted.

55 changes: 55 additions & 0 deletions modules/hyprland/bin/hypr-cyclefloatingpos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
dir="${1:-forward}" # forward or reverse
if [[ "$(hyprctl activewindow -j | jq -r .floating)" == "true" ]]; then

# Get the cache directory and active window name
cache_dir="$XDG_RUNTIME_DIR/hypr/cyclefloating"
window_address="$(hyprctl activewindow -j | jq -r .address)"

mkdir -p $cache_dir
touch $cache_dir/$window_address

# top_left top_center top_right
# middle_left middle_right
# bottom_left bottom_center bottom_right
pos="$(cat $cache_dir/$window_address)"
next_pos="top_left"


if [[ "$pos" == "top_left" ]]; then
hyprctl --batch "dispatch movewindow u ; dispatch movewindow l"
[[ "$dir" == "forward" ]] && next_pos="top_center" || next_pos="middle_left"

elif [[ "$pos" == "top_center" ]]; then
hyprctl --batch "dispatch centerwindow 1; dispatch movewindow u"
[[ "$dir" == "forward" ]] && next_pos="top_right" || next_pos="top_left"

elif [[ "$pos" == "top_right" ]]; then
hyprctl --batch "dispatch movewindow u ; dispatch movewindow r"
[[ "$dir" == "forward" ]] && next_pos="middle_right" || next_pos="top_center"

elif [[ "$pos" == "middle_right" ]]; then
hyprctl --batch "dispatch centerwindow 1 ; dispatch movewindow r"
[[ "$dir" == "forward" ]] && next_pos="bottom_right" || next_pos="top_right"

elif [[ "$pos" == "bottom_right" ]]; then
hyprctl --batch "dispatch movewindow d ; dispatch movewindow r"
[[ "$dir" == "forward" ]] && next_pos="bottom_center" || next_pos="middle_right"

elif [[ "$pos" == "bottom_center" ]]; then
hyprctl --batch "dispatch centerwindow 1 ; dispatch movewindow d"
[[ "$dir" == "forward" ]] && next_pos="bottom_left" || next_pos="bottom_right"

elif [[ "$pos" == "bottom_left" ]]; then
hyprctl --batch "dispatch movewindow d ; dispatch movewindow l"
[[ "$dir" == "forward" ]] && next_pos="middle_left" || next_pos="bottom_center"

elif [[ "$pos" == "middle_left" ]]; then
hyprctl --batch "dispatch centerwindow 1 ; dispatch movewindow l"
[[ "$dir" == "forward" ]] && next_pos="top_left" || next_pos="bottom_left"
fi

# Save the next position to file
echo "$next_pos" > $cache_dir/$window_address

fi
9 changes: 9 additions & 0 deletions modules/hyprland/bin/hypr-movewindoworgrouporactive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash
is_floating="$(hyprctl activewindow -j | jq -r .floating)"
dir="${1-l}" # [l]eft [d]own [u]p [r]ight
x="${2-0}" y="${3-0}" # distance to move window
if [[ "$is_floating" == "true" ]]; then
hyprctl dispatch moveactive $x $y
else
hyprctl dispatch movewindoworgroup $dir
fi
50 changes: 50 additions & 0 deletions modules/hyprland/bin/hypr-screenshot.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env bash
flag="${1-rc}"

# r: region
# s: screen
# c: clipboard
# f: file
# i: interactive
# p: pixel

# Region to clipboard
if [[ $flag == rc ]]; then
grim -g "$(slurp -b '#000000b0' -c '#00000000')" - | wl-copy
notify-send 'Copied to Clipboard' Screenshot

# Region to file
elif [[ $flag == rf ]]; then
mkdir -p ~/Pictures/Screenshots
filename=~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%M-%S).png
grim -g "$(slurp -b '#000000b0' -c '#00000000')" $filename
notify-send 'Screenshot Taken' $filename

# Region to interactive
elif [[ $flag == ri ]]; then
grim -g "$(slurp -b '#000000b0' -c '#00000000')" - | tee >(wl-copy) | swappy -f -
# grim -g "$(slurp -b '#000000b0' -c '#00000000')" - | swappy -f -

# Screen to clipboard
elif [[ $flag == sc ]]; then
filename=~/Pictures/Screenshots/%Y-%m-%d_%H-%M-%S.png
grim - | wl-copy
notify-send 'Copied to Clipboard' Screenshot

# Screen to file
elif [[ $flag == sf ]]; then
mkdir -p ~/Pictures/Screenshots
filename=~/Pictures/Screenshots/$(date +%Y-%m-%d_%H-%M-%S).png
grim $filename
notify-send 'Screenshot Taken' $filename

# Screen to interactive
elif [[ $flag == si ]]; then
grim - | swappy -f -

# Colour to clipboard
elif [[ $flag == p ]]; then
color=$(hyprpicker -a)
wl-copy $color
notify-send 'Copied to Clipboard' $color
fi
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

# Stack of hyprland client windows
STACK="$XDG_RUNTIME_DIR/supertab"
touch $STACK
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

# Cache found names/icons
CACHE="$XDG_RUNTIME_DIR/hyprwindow"
mkdir -p $CACHE
Expand Down
3 changes: 1 addition & 2 deletions modules/hyprland/bin/rofi-toggle.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env bash
if $(pidof -q rofi >/dev/null); then
kill $(pidof -s rofi)
else
if [[ -n "${@-}" ]]; then
# keyd bind super.j=down super.k=up super.h=left super.l=right
# keyd bind super.enter=enter super.space=space
rofi "${@}"
fi
fi
23 changes: 4 additions & 19 deletions modules/hyprland/programs/rofi.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,15 @@

cfg = config.programs.rofi;
ini = pkgs.formats.ini {};
inherit (lib) getExe mkIf mkShellScript;

hyprwindow = mkShellScript {
inputs = with pkgs; [ hyprland jq gawk gettext ];
text = ../bin/hyprwindow.sh;
};

# Toggle
rofi-toggle = mkShellScript {
inputs = with pkgs; [ cfg.finalPackage procps keyd ];
text = ../bin/rofi-toggle.sh;
};
inherit (lib) getExe mkIf;

in {

config = mkIf config.wayland.windowManager.hyprland.enable {

wayland.windowManager.hyprland.settings = {
bindr = [ "super, Super_L, exec, ${rofi-toggle} -show combi" ];
bind = [
"super, space, exec, ${rofi-toggle} -show combi"
# ''alt, tab, exec, ${rofi-toggle} -show combi -kb-accept-entry "!Alt-Tab,!Alt+Alt_L" -kb-row-down "Alt+Tab" -selected-row 1''
# ''super, tab, exec, ${rofi-toggle} -show combi -kb-accept-entry "!Super-Tab,!Super+Super_L" -kb-row-down "Super+Tab" -selected-row 1''
];
bindr = [ "super, Super_L, exec, rofi-toggle -show combi" ];
bind = [ "super, space, exec, rofi-toggle -show combi" ];
};

services.keyd.layers = {
Expand Down Expand Up @@ -63,7 +48,7 @@ in {
# "run"
];
combi-modes = [
"hyprwindow:${hyprwindow}"
"hyprwindow:rofi-hyprwindow"
"drun"
"ssh"
];
Expand Down
13 changes: 8 additions & 5 deletions modules/hyprland/programs/waybar/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ in {
# modules config
"custom/launcher" = {
on-click = "${rofi} -show combi";
format = "";
format = "";
};

"custom/expo" = {
Expand Down Expand Up @@ -159,15 +159,18 @@ in {
};

cpu = {
format = " {load} / {usage}%";
# format = " {load} / {usage}%";
format = " {usage}%";
on-click = "${kitty} htop";
};

temperature = {
thermal-zone = 1; # 2
critical-threshold = 80;
format-critical = "{temperatureC}°C ";
format = "{temperatureC}°C ";
# format-critical = "{temperatureC}°C ";
# format = "{temperatureC}°C ";
format-critical = "{temperatureC}°C";
format = "{temperatureC}°C";
};

"wlr/taskbar" = {
Expand All @@ -184,7 +187,7 @@ in {
};

tray = {
icon-size = 14;
icon-size = 16;
spacing = 6;
};

Expand Down
4 changes: 2 additions & 2 deletions modules/hyprland/programs/waybar/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/* color: #6481d0; */
color: #ffffff;
margin: 0px;
padding: 5px 8px;
padding: 5px 8px 5px 10px;
/* padding: 5px 9px 5px 12px; */
font-size: 18px;
transition: all 0.3s;
Expand Down Expand Up @@ -130,7 +130,7 @@

#tray {
margin: 0;
padding: 5px 20px;
padding: 5px 20px 5px 15px;
}


Expand Down
Loading

0 comments on commit 70f563a

Please sign in to comment.