From c2e17fbf15f326f2b1cf66a60c5393e671e8ca17 Mon Sep 17 00:00:00 2001 From: Tyler Kelley Date: Mon, 17 Feb 2025 14:23:57 -0600 Subject: [PATCH] Improve rofi scripts and the theme --- modules/home/rofi/config-emoji.nix | 11 ----- modules/home/rofi/config-long.nix | 47 ++++++++++++++++-- modules/home/rofi/config-wide.nix | 10 ++++ modules/home/rofi/default.nix | 6 +-- modules/home/scripts/emopicker9000.nix | 32 ++++++------ modules/home/scripts/web-search.nix | 67 +++++++++++++------------- 6 files changed, 105 insertions(+), 68 deletions(-) delete mode 100644 modules/home/rofi/config-emoji.nix create mode 100644 modules/home/rofi/config-wide.nix diff --git a/modules/home/rofi/config-emoji.nix b/modules/home/rofi/config-emoji.nix deleted file mode 100644 index 71b5da4..0000000 --- a/modules/home/rofi/config-emoji.nix +++ /dev/null @@ -1,11 +0,0 @@ -{ ... }: - -{ - home.file.".config/rofi/config-emoji.rasi".text = '' - @import "~/.config/rofi/config-long.rasi" - entry { - width: 45%; - placeholder: "🔎 Search Emoji's 👀"; - } - ''; -} diff --git a/modules/home/rofi/config-long.nix b/modules/home/rofi/config-long.nix index 14bf233..1f66be5 100644 --- a/modules/home/rofi/config-long.nix +++ b/modules/home/rofi/config-long.nix @@ -1,12 +1,49 @@ {...}: { home.file.".config/rofi/config-long.rasi".text = '' @import "~/.config/rofi/config.rasi" - entry { - placeholder: "🔎 Search "; + window { + width: 600px; + border-radius: 20px; } - listview { - columns: 1; - lines: 10; + mainbox { + orientation: vertical; + children: [ "inputbar", "listbox" ]; + } + inputbar { + padding: 75px 40px; + background-color: transparent; + background-image: url("~/Pictures/Wallpapers/Rainnight.jpg", width); + text-color: @foreground; + children: [ "textbox-prompt-colon", "entry" ]; + } + textbox-prompt-colon { + padding: 12px 20px; + border-radius: 100%; + background-color: @bg-alt; + text-color: @foreground; + } + entry { + expand: true; + padding: 12px 16px; + border-radius: 100%; + background-color: @bg-alt; + text-color: @foreground; + } + button { + padding: 12px; + border-radius: 100%; + } + element { + spacing: 10px; + padding: 12px; + border-radius: 100%; + } + textbox { + padding: 12px; + border-radius: 100%; + } + error-message { + border-radius: 0px; } ''; } diff --git a/modules/home/rofi/config-wide.nix b/modules/home/rofi/config-wide.nix new file mode 100644 index 0000000..ef83251 --- /dev/null +++ b/modules/home/rofi/config-wide.nix @@ -0,0 +1,10 @@ +{...}: { + home.file.".config/rofi/config-wide.rasi".text = '' + @import "~/.config/rofi/config-long.rasi" + window { + width: 100%; + location: south; + anchor: south; + } + ''; +} diff --git a/modules/home/rofi/default.nix b/modules/home/rofi/default.nix index 9acb480..18e457f 100644 --- a/modules/home/rofi/default.nix +++ b/modules/home/rofi/default.nix @@ -1,9 +1,7 @@ -{ ... }: - -{ +{...}: { imports = [ - ./config-emoji.nix ./config-long.nix + ./config-wide.nix ./rofi.nix ]; } diff --git a/modules/home/scripts/emopicker9000.nix b/modules/home/scripts/emopicker9000.nix index 36a2f53..e4d908f 100644 --- a/modules/home/scripts/emopicker9000.nix +++ b/modules/home/scripts/emopicker9000.nix @@ -1,18 +1,22 @@ -{ pkgs }: - +{pkgs}: pkgs.writeShellScriptBin "emopicker9000" '' - # Get user selection via wofi from emoji file. - chosen=$(cat $HOME/.config/.emoji | ${pkgs.rofi-wayland}/bin/rofi -i -dmenu -config ~/.config/rofi/config-emoji.rasi | awk '{print $1}') + # check if rofi is already running + if pidof rofi > /dev/null; then + pkill rofi + fi - # Exit if none chosen. - [ -z "$chosen" ] && exit + # Get user selection via wofi from emoji file. + chosen=$(cat $HOME/.config/.emoji | ${pkgs.rofi-wayland}/bin/rofi -i -dmenu -config ~/.config/rofi/config-long.rasi | awk '{print $1}') - # If you run this command with an argument, it will automatically insert the - # character. Otherwise, show a message that the emoji has been copied. - if [ -n "$1" ]; then - ${pkgs.ydotool}/bin/ydotool type "$chosen" - else - printf "$chosen" | ${pkgs.wl-clipboard}/bin/wl-copy - ${pkgs.libnotify}/bin/notify-send "'$chosen' copied to clipboard." & - fi + # Exit if none chosen. + [ -z "$chosen" ] && exit + + # If you run this command with an argument, it will automatically insert the + # character. Otherwise, show a message that the emoji has been copied. + if [ -n "$1" ]; then + ${pkgs.ydotool}/bin/ydotool type "$chosen" + else + printf "$chosen" | ${pkgs.wl-clipboard}/bin/wl-copy + ${pkgs.libnotify}/bin/notify-send "'$chosen' copied to clipboard." & + fi '' diff --git a/modules/home/scripts/web-search.nix b/modules/home/scripts/web-search.nix index a80d671..8b1e3e9 100644 --- a/modules/home/scripts/web-search.nix +++ b/modules/home/scripts/web-search.nix @@ -1,43 +1,42 @@ -{ pkgs }: - +{pkgs}: pkgs.writeShellScriptBin "web-search" '' - declare -A URLS + declare -A URLS - URLS=( - ["🌎 Search"]="https://search.brave.com/search?q=" - ["❄️ Unstable Packages"]="https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=" - ["🎞️ YouTube"]="https://www.youtube.com/results?search_query=" - ["🦥 Arch Wiki"]="https://wiki.archlinux.org/title/" - ["🐃 Gentoo Wiki"]="https://wiki.gentoo.org/index.php?title=" - ) + URLS=( + ["🌎 Search"]="https://search.brave.com/search?q=" + ["❄️ Unstable Packages"]="https://search.nixos.org/packages?channel=unstable&from=0&size=50&sort=relevance&type=packages&query=" + ["🎞️ YouTube"]="https://www.youtube.com/results?search_query=" + ["🦥 Arch Wiki"]="https://wiki.archlinux.org/title/" + ["🐃 Gentoo Wiki"]="https://wiki.gentoo.org/index.php?title=" + ) - # List for rofi - gen_list() { - for i in "''${!URLS[@]}" - do - echo "$i" - done - } + # List for rofi + gen_list() { + for i in "''${!URLS[@]}" + do + echo "$i" + done + } - main() { - # Pass the list to rofi - platform=$( (gen_list) | ${pkgs.rofi-wayland}/bin/rofi -dmenu ) + main() { + # Pass the list to rofi + platform=$( (gen_list) | ${pkgs.rofi-wayland}/bin/rofi -dmenu -config ~/.config/rofi/config-long.rasi ) - if [[ -n "$platform" ]]; then - query=$( (echo ) | ${pkgs.rofi-wayland}/bin/rofi -dmenu ) + if [[ -n "$platform" ]]; then + query=$( (echo ) | ${pkgs.rofi-wayland}/bin/rofi -dmenu -config ~/.config/rofi/config-long.rasi ) - if [[ -n "$query" ]]; then - url=''${URLS[$platform]}$query - xdg-open "$url" - else - exit - fi - else - exit - fi - } + if [[ -n "$query" ]]; then + url=''${URLS[$platform]}$query + xdg-open "$url" + else + exit + fi + else + exit + fi + } - main + main - exit 0 + exit 0 ''