1

Rofi: Update colorscheme + menus

This commit is contained in:
2024-10-14 15:00:53 +02:00
parent be282e0875
commit 9dac733319
8 changed files with 134 additions and 147 deletions

View File

@ -7,14 +7,134 @@
pkgs,
...
}: let
cfg = config.modules.rofi;
inherit (config.modules) rofi color;
in {
options.modules.rofi = import ./options.nix {inherit lib mylib;};
config = lib.mkIf cfg.enable {
home.packages = with pkgs; [
rofi-wayland
];
config = lib.mkIf rofi.enable {
programs.rofi = {
enable = true;
package = pkgs.rofi-wayland;
terminal = "kitty";
font = "${color.font} 14";
location = "center";
cycle = true;
extraConfig = {
modi = "run,drun,ssh,filebrowser";
show-icons = true;
icon-theme = "Papirus";
drun-display-format = "{icon} {name}";
disable-history = false;
hide-scrollbar = true;
display-drun = " apps ";
display-run = " run ";
display-filebrowser = " file ";
display-ssh = " ssh ";
sidebar-mode = false;
};
# bg-col: rgba(239, 241, 245, 60%);
theme = let
inherit (config.lib.formats.rasi) mkLiteral;
mkColor = color: mkLiteral "#{color}";
in {
"*" = {
bg = mkLiteral "rgba(239, 241, 245, 0.3)";
hl-lavender = mkLiteral "#${color.dark.lavender}";
hl-pink = mkLiteral "#${color.dark.pink}";
text = mkLiteral "#${color.dark.base}";
trans = mkLiteral "rgba(255, 255, 255, 0)";
};
"element-text,element-icon,mode-switcher" = {
background-color = mkLiteral "inherit";
text-color = mkLiteral "inherit";
};
"window" = {
height = 480;
width = 700;
# border-style = mkLiteral "solid";
border = mkLiteral "2 solid 2 solid 2 solid 2 solid";
border-radius = 6;
border-color = mkLiteral "@hl-lavender";
background-color = mkLiteral "@bg";
};
"mainbox" = {
background-color = mkLiteral "@trans";
};
"message" = {
background-color = mkLiteral "@trans";
};
"error-message" = {
background-color = mkLiteral "@trans";
margin = mkLiteral "0px 0px 20px 0px";
};
"textbox" = {
background-color = mkLiteral "@trans";
padding = 6;
margin = mkLiteral "20px 20px 0px 20px";
border-radius = 3;
};
"inputbar" = {
children = builtins.map mkLiteral ["prompt" "entry"];
background-color = mkLiteral "@trans";
};
"prompt" = {
background-color = mkLiteral "@hl-pink";
padding = 6;
text-color = mkLiteral "@text";
border-radius = 3;
margin = mkLiteral "20px 0px 0px 20px";
};
"entry" = {
padding = 6;
margin = mkLiteral "20px 20px 0px 10px";
text-color = mkLiteral "@text";
background-color = mkLiteral "@trans";
border = mkLiteral "2 solid 2 solid 2 solid 2 solid";
border-radius = 3;
border-color = mkLiteral "@hl-pink";
};
"listview" = {
# border = mkLiteral "0px 0px 0px";
padding = 0;
margin = mkLiteral "10px 20px 20px 20px";
columns = 1;
background-color = mkLiteral "@trans";
border = mkLiteral "2 solid 2 solid 2 solid 2 solid";
border-radius = 3;
border-color = mkLiteral "@hl-pink";
};
"element" = {
padding = 5;
margin = 0;
background-color = mkLiteral "@trans";
text-color = mkLiteral "@text";
border-radius = 3;
};
"element-icon" = {
size = 25;
};
"element selected" = {
background-color = mkLiteral "@hl-pink";
text-color = mkLiteral "@text";
};
};
};
modules.hyprland.keybindings = let
power-menu =
@ -26,15 +146,19 @@ in {
"Reload Hyprland" = "hyprctl reload";
"Exit Hyprland" = "hyprctl dispatch exit";
};
vpn-menu = pkgs.writeScript "rofi-menu-vpn" (builtins.readFile ./menus/vpn.fish);
keybinds-menu = pkgs.writeScript "rofi-menu-keybinds" (builtins.readFile ./menus/keybinds.fish);
# TODO: Expand on that
lectures-menu = pkgs.writeScript "rofi-menu-lectures" (builtins.readFile ./menus/lectures.fish);
in {
bindings = {
"$mainMod, escape" = ["exec, \"${power-menu}\""];
"$mainMod, O" = ["exec, \"${lectures-menu}\""];
"$mainMod, M" = ["exec, \"${keybinds-menu}\""];
"$mainMod, U" = ["exec, \"${vpn-menu}\""];
};
};
home.file = {
".config/rofi/config.rasi".source = ../../../config/rofi/rofi.rasi;
".config/rofi/colors.rasi".source = ../../../config/rofi/colors/${cfg.theme}.rasi;
};
};
}

View File

@ -0,0 +1,3 @@
#!/usr/bin/env fish
cat ~/.config/hypr/keybindings.info | rofi -dmenu -p " keys " -i

View File

@ -0,0 +1,15 @@
#!/usr/bin/env fish
# User chooses lecture
set LECTURE (eza -1 -D ~/Notes/TU | rofi -dmenu -p " lecture " -i)
if test -z $LECTURE
exit
end
# User chooses slides
set DECK (eza -1 ~/Notes/TU/$LECTURE/Lecture | grep ".pdf" | rofi -dmenu -p " deck " -i)
if test -z $DECK
exit
end
xdg-open ~/Notes/TU/$LECTURE/Lecture/$DECK

View File

@ -0,0 +1,40 @@
#!/usr/bin/env fish
# User chooses VPN server, running servers are marked in green
set SERVERS (cat /etc/rofi-vpns)
set PROMPT ""
for SERVER in $SERVERS
set SERVER_RUNNING "$(systemctl list-units $SERVER.service | grep $SERVER.service)"
if test -z $SERVER_RUNNING
set PROMPT $PROMPT$SERVER"\n"
else
set PROMPT $PROMPT"<span foreground=\"green\">$SERVER</span>\n"
end
end
set SERVER (echo -e $PROMPT | rofi -dmenu -p " vpn " -i -markup-rows)
set SERVER (echo -e $SERVER | sd "<.*?>" "")
if not contains $SERVER $SERVERS
exit
end
# User chooses action
set ACTIONS "start" "stop" "status"
set ACTION (echo -e (string join "\n" $ACTIONS) | rofi -dmenu -p " action " -i)
if not contains $ACTION $ACTIONS
exit
end
# Enable wireguard netdev
set COMMAND "systemctl $ACTION $SERVER.service"
set EVAL_RESULT "$(eval $COMMAND)"
if test $ACTION = "status" && test -n "$EVAL_RESULT"
# Display result if it exists
rofi -theme ~/NixFlake/config/rofi/rofi.rasi -e "$EVAL_RESULT"
else if test $ACTION = "start"
# Launch chromium in firejail
# NOTE: With a shared home directory, firejail uses the same instance, so it won't work to
# launch multiple browsers with different VPNs...
# firejail --noprofile --allusers --private="~/.firejail-home" --netns="wg0-$SERVER" chromium --incognito --new-window ipaddress.my &>/dev/null
firejail --noprofile --private --netns="$SERVER" chromium --incognito --new-window ipaddress.my &>/dev/null
end