From 1682bed87f9103459c9ea6495a2f6b5dcf298e23 Mon Sep 17 00:00:00 2001 From: Michel Fedde Date: Fri, 3 Oct 2025 17:35:48 +0200 Subject: [PATCH] adds rofi as styling --- .config/hypr/config/Keybinds.conf | 2 + .config/rofi/config.rasi | 5 ++- .config/rofi/scripts/2fa.sh | 43 ++++++++++++++++++++ .config/rofi/scripts/_lib.sh | 5 +++ .config/rofi/scripts/calc.sh | 20 +++++++++ .config/rofi/scripts/pactl.sh | 15 +++++++ .config/rofi/scripts/system.sh | 25 ++++++++++++ .config/theming/applications/rofi/style.scss | 15 ++++--- .gitignore | 2 + 9 files changed, 124 insertions(+), 8 deletions(-) create mode 100755 .config/rofi/scripts/2fa.sh create mode 100644 .config/rofi/scripts/_lib.sh create mode 100755 .config/rofi/scripts/calc.sh create mode 100755 .config/rofi/scripts/pactl.sh create mode 100755 .config/rofi/scripts/system.sh diff --git a/.config/hypr/config/Keybinds.conf b/.config/hypr/config/Keybinds.conf index 8cfc16e..dc1db99 100644 --- a/.config/hypr/config/Keybinds.conf +++ b/.config/hypr/config/Keybinds.conf @@ -111,3 +111,5 @@ bind = $mainMod, O, exec, killall -USR1 waybar # Master Layout Keybinds bind = $mainMod, A, layoutmsg,swapwithmaster master + +bind = $mainMod, F10, exec, rofi -modes "pactl" -show pactl diff --git a/.config/rofi/config.rasi b/.config/rofi/config.rasi index e2b874e..0bc56f1 100644 --- a/.config/rofi/config.rasi +++ b/.config/rofi/config.rasi @@ -1,5 +1,5 @@ configuration { - modes: "window,drun,calc,system"; + modes: "window,drun,calc,system,pactl"; /* font: "mono 12";*/ /* location: 0;*/ /* yoffset: 0;*/ @@ -79,6 +79,7 @@ configuration { display-system: "System"; display-calc: "Calculator"; display-2fa: "2FA Codes"; + display-pactl: "Audio"; /* ml-row-left: "ScrollLeft";*/ /* ml-row-right: "ScrollRight";*/ /* ml-row-up: "ScrollUp";*/ @@ -109,7 +110,7 @@ configuration { @theme "./style.rasi" window { - width: calc(50% max 1080); + width: calc(50% min 786); } listview { diff --git a/.config/rofi/scripts/2fa.sh b/.config/rofi/scripts/2fa.sh new file mode 100755 index 0000000..065543c --- /dev/null +++ b/.config/rofi/scripts/2fa.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +set -o pipefail + +source "$HOME/.config/rofi/scripts/_lib.sh" + +KEYRING_NAME="2fauth" +KEYRING_VALUE="token" +DOMAIN="https://auth.iedsoftworks.com" + +getApiToken() { + token=$(secret-tool lookup "$KEYRING_NAME" "$KEYRING_VALUE") + if [[ $? == 0 ]]; then + return 0 + fi + + token=$(zenity --forms --add-multiline-entry="API Key" --text="Provide a valid API key") + if [[ $token == "" ]]; then + return 1 + fi + + echo "$token" | secret-tool store --label "2FAuth API Key" "$KEYRING_NAME" "$KEYRING_VALUE" +} + +getApiToken + +setOption no-custom true +case $ROFI_RETV in +0) + echo -en $(curl --oauth2-bearer "$token" "$DOMAIN/api/v1/twofaccounts" | jq -r '.[] | "\(.id)\\0display\\x1f\(.service) - \(.account)\\x1finfo\\x1f\(.)\\n"') + ;; +1) + id=$@ + + curl --oauth2-bearer "$token" "$DOMAIN/api/v1/twofaccounts/$id/otp" | + jq ".password" -r | + wl-copy + + $(echo $ROFI_INFO | jq -r '"\(.service) - \(.account)"') + + notify-send -i "lock" "2FA Code copied" "Copied code for '$(echo $ROFI_INFO | jq -r '"\(.service) - \(.account)"')'" + ;; +esac diff --git a/.config/rofi/scripts/_lib.sh b/.config/rofi/scripts/_lib.sh new file mode 100644 index 0000000..61071c6 --- /dev/null +++ b/.config/rofi/scripts/_lib.sh @@ -0,0 +1,5 @@ +#!/bin/env sh + +setOption() { + echo -en "\0$1\x1f$2\n" +} diff --git a/.config/rofi/scripts/calc.sh b/.config/rofi/scripts/calc.sh new file mode 100755 index 0000000..a625c42 --- /dev/null +++ b/.config/rofi/scripts/calc.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +case $ROFI_RETV in +1) + wl-copy "$@" + ;; +2) + + result=$(rink "$@" | grep -v '^>') + NUMBERS=$(echo "$result "tr '\n' ' ' | sed -e 's/[^0-9]/ /g' -e 's/^ *//g' -e 's/ *$//g') + + IFS=' ' + + for number in $NUMBERS; do + echo $number + done + echo -en "$result\0non-selectable\x1ftrue\n" + ;; + +esac diff --git a/.config/rofi/scripts/pactl.sh b/.config/rofi/scripts/pactl.sh new file mode 100755 index 0000000..67a8e00 --- /dev/null +++ b/.config/rofi/scripts/pactl.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +source "$HOME/.config/rofi/scripts/_lib.sh" + +setOption no-custom true +case $ROFI_RETV in +0) + defaultSink=$(pactl get-default-sink) + echo -en $(pactl --format=json list sinks | jq --arg default "$defaultSink" -r 'map("\(.name)\\0display\\x1f\(.description)\\x1fmeta\\x1fsinks,output,\(.description)\\x1factive\\x1f\(.name == $default)\\n") | add') + ;; +1) + name=$@ + pactl set-default-sink "$name" + ;; +esac diff --git a/.config/rofi/scripts/system.sh b/.config/rofi/scripts/system.sh new file mode 100755 index 0000000..4df411b --- /dev/null +++ b/.config/rofi/scripts/system.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +source "$HOME/.config/rofi/scripts/_lib.sh" + +SCRIPTS_DIR="$HOME/.config/scripts" + +declare -A scripts +scripts["Shutdown"]="systemctl poweroff" +scripts["Reboot"]="systemctl reboot" +scripts["Logout"]="logout terminate-user $USER" +scripts["Lock"]="$SCRIPTS_DIR/LockScreen.sh" +scripts["Notification Center (SwayNC)"]="swaync-client -t -sw" + +setOption no-custom true +setOption use-hot-keys true +case $ROFI_RETV in +0) + printf "%s\n" "${!scripts[@]}" + ;; +1) + command="${scripts[$@]}" + coproc ($command >/dev/null 2>&1) + exit 0 + ;; +esac diff --git a/.config/theming/applications/rofi/style.scss b/.config/theming/applications/rofi/style.scss index 9ac2716..9aea64d 100644 --- a/.config/theming/applications/rofi/style.scss +++ b/.config/theming/applications/rofi/style.scss @@ -13,10 +13,9 @@ $transparentBackground: rgba(128,128,128, 0.6); window { transparency: "real"; - } -inputbar, listview { +inputbar, listview, textbox { border-radius: $border-radius; border: 1px solid; border-color: $border-color; @@ -30,18 +29,20 @@ inputbar, listview, message, element { } inputbar { + orientation: vertical; children: [mode-switcher, entry] } +textbox { + padding: $input-padding; +} + prompt { border: 0 1px 0 0; border-color: $border-color; } entry { - border: 0 0 0 1px; - border-color: $border-color; padding: $input-padding; - margin: 0 0 0 4px; } listview { @@ -65,10 +66,12 @@ element-icon { } mode-switcher { + border: 0 0 1px 0; + border-color: $border-color; enabled: true; } -button { +button { border-radius: $border-radius; expand: false; margin: 4px; diff --git a/.gitignore b/.gitignore index 71cb9af..21d60f7 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,8 @@ !/.config/yazi/ /.config/yazi/plugins/* +!/.config/rofi/ +/.config/rofi/style.rasi !/.config/hypr/ !/.config/ghostty/ !/.config/nvim/