From c5d884ccb57d68ca63d6ddff53af7d6d408f3360 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sat, 25 Sep 2021 06:59:26 -0500 Subject: [PATCH] make nyxt sleeker --- alacritty/alacritty.yml | 2 +- fish/functions/sway-getwindowinfo.fish | 17 ++ nyxt/auto-config.lisp | 2 + nyxt/init.lisp | 206 +++++++++++++------------ rofi/launchers-git/laptop-rbw.rasi | 4 +- scripts/nyxtlof | 4 +- scripts/plasma-rofi-rbw.sh | 71 +++++++++ scripts/swayprop | 32 ++++ sway/config | 16 +- waybar/config | 2 +- 10 files changed, 247 insertions(+), 109 deletions(-) create mode 100644 fish/functions/sway-getwindowinfo.fish create mode 100755 scripts/plasma-rofi-rbw.sh create mode 100755 scripts/swayprop diff --git a/alacritty/alacritty.yml b/alacritty/alacritty.yml index 7b25c31..93b7a61 100644 --- a/alacritty/alacritty.yml +++ b/alacritty/alacritty.yml @@ -318,7 +318,7 @@ colors: # # Window opacity as a floating point number from `0.0` to `1.0`. # The value `0.0` is completely transparent and `1.0` is opaque. -background_opacity: 1.0 +background_opacity: 0.75 #selection: #semantic_escape_chars: ",│`|:\"' ()[]{}<>\t" diff --git a/fish/functions/sway-getwindowinfo.fish b/fish/functions/sway-getwindowinfo.fish new file mode 100644 index 0000000..6f092f6 --- /dev/null +++ b/fish/functions/sway-getwindowinfo.fish @@ -0,0 +1,17 @@ +function sway-getwindowinfo + slurp -p -f "%x %y" | read x_sel y_sel + or return 1 + + # TODO: this returns everything when there is only one container open in the workspace + # need to fix the logic + for rect in (swaymsg -t get_tree | jq -r '.. | select(.pid? and .visible?) | .rect | "\(.x) \(.width) \(.y) \(.height)"') + echo $rect | read x1 w y1 h + set x2 (math $x1 + $w) + set y2 (math $y1 + $h) + if test \( $x_sel -ge $x1 \) -a \( $x_sel -le $x2 \) + and test \( $y_sel -ge $y1 \) -a \( $y_sel -le $y2 \) + #swaymsg --type get_tree | jq ".. | objects | select(.rect.x == $x1 and .rect.y == $y1 and .rect.width == $w and .rect.height == $h) | .id, .name, .pid, .title, .app_id, .marks, .type" + swaymsg --type get_tree | jq ".. | objects | select(.rect.x == $x1 and .rect.y == $y1 and .rect.width == $w and .rect.height == $h)" +end +end +end diff --git a/nyxt/auto-config.lisp b/nyxt/auto-config.lisp index fd80d05..265fb88 100644 --- a/nyxt/auto-config.lisp +++ b/nyxt/auto-config.lisp @@ -10,3 +10,5 @@ ((VISIBLE-IN-STATUS-P NIL))) (DEFINE-CONFIGURATION NYXT/WEB-MODE:WEB-MODE ((VISIBLE-IN-STATUS-P NIL))) +(DEFINE-CONFIGURATION NYXT/VI-MODE:USER-VI-NORMAL-MODE + ((VISIBLE-IN-STATUS-P NIL))) diff --git a/nyxt/init.lisp b/nyxt/init.lisp index eace860..93ebd16 100644 --- a/nyxt/init.lisp +++ b/nyxt/init.lisp @@ -71,7 +71,7 @@ "J" 'switch-buffer-previous "b" 'switch-buffer "v" 'hint-mpv - "C-v v" 'hint-ytdl + "V" 'hint-ytdl "d" 'delete-current-buffer "D" 'delete-buffer "r" 'reload-current-buffer @@ -92,61 +92,67 @@ %slot-default%)))) (define-configuration buffer - ((search-engines - (list - (make-instance 'search-engine - :shortcut "s" - :search-url "https://search.tfcconnection.org/?q=~a" - :fallback-url "https://search.tfcconnection.org"))))) + ((search-engines + (list + (make-instance 'search-engine + :shortcut "s" + :search-url "https://search.tfcconnection.org/?q=~a" + :fallback-url "https://search.tfcconnection.org"))))) + +(define-configuration nyxt/vi-mode:vi-normal-mode + ((visible-in-status-p nil))) + +(define-configuration nyxt/vi-mode:vi-insert-mode + ((visible-in-status-p nil))) (define-configuration status-buffer - ((style - (str:concat - %slot-default% - (cl-css:css - '((body - :background "#282a36" - :color "#e2e4e5" - :line-height "1fr") - ("#container-vi" - :grid-template-columns "0px 30px 2fr 0px 240px") - ("#controls" - :background-color "#282a36" - :color "#f3f99d" - :width "0px" - :padding-left "0px" - :hidden) - ("#url" - :background-color "#282a36" - :color "#5af78e") - ("#modes" - :background-color "#282a36" - :color "#f3f99d") - ("#tabs" - :background-color "#282a36" - :color "#5af78e") - (".tab" - :background-color "#282a36" - :color "#9aedfe") - (".tab:hover" - :background-color "#282a36" - :color "#f1f1f0") - (".button" - :background-color "#282a36" - :color "#5af78e") - (".button:hover" - :background-color "#282a36" - :color "#f1f1f0") - (".arrow" - :width "0px" - :height "0px") - (".arrow-right" - :background-color "#282a36" - :color "#5af78e") - (".arrow-left" - :background-color "#282a36" - :color "#5af78e") - )))))) + ((style + (str:concat + %slot-default% + (cl-css:css + '((body + :background "#282a36" + :color "#e2e4e5" + :line-height "1fr") + ("#container-vi" + :grid-template-columns "0px 30px 2fr 0px 240px") + ("#controls" + :background-color "#282a36" + :color "#f3f99d" + :width "0px" + :padding-left "0px" + :hidden) + ("#url" + :background-color "#282a36" + :color "#5af78e") + ("#modes" + :background-color "#282a36" + :color "#f3f99d") + ("#tabs" + :background-color "#282a36" + :color "#5af78e") + (".tab" + :background-color "#282a36" + :color "#9aedfe") + (".tab:hover" + :background-color "#282a36" + :color "#f1f1f0") + (".button" + :background-color "#282a36" + :color "#5af78e") + (".button:hover" + :background-color "#282a36" + :color "#f1f1f0") + (".arrow" + :width "0px" + :height "0px") + (".arrow-right" + :background-color "#282a36" + :color "#5af78e") + (".arrow-left" + :background-color "#282a36" + :color "#5af78e") + )))))) (define-configuration internal-buffer ((style @@ -169,50 +175,54 @@ :color "#e2e4e5"))))))) (define-configuration prompt-buffer - ((style - (str:concat - %slot-default% - (cl-css:css - '((body - :background-color "#282a36" - :color "#e2e4e5") - ("#prompt-area" - :background-color "#282a36" - :color "#57c7ff") - ("#prompt" - :background-color "#282a36" - :color "#e2e4e5") - ("#input" - :background-color "#282a36" - :color "#e2e4e5") - ("#suggestions" - :background-color "#282a36" - :color "#e2e4e5") - (.source - :margin-left "5px") - (.source-name - :background-color "#282a36" - :color "#e2e4e5") - (.source-content - :background-color "#282a36" - :color "#e2e4e5") - ;; (".source-content td" - ;; :background-color "#282a36" - ;; :color "#e2e4e5") - (".source-content th" - :background-color "#43454f" - :color "#e2e4e5") - ("#selection" - :background-color "#57c7ff" - :color "#34353e") - (.marked - :background-color "#5af78e" - :color "#34353e") - (.selected - :background-color "#57c7ff" - :color "#34353e") - (.button - :color "#e2e4e5"))))))) + ((style + (str:concat + %slot-default% + (cl-css:css + '((body + :background-color "#282a36" + :color "#e2e4e5") + ("#prompt-area-vi" + :background-color "#282a36" + :color "#57c7ff") + ("#prompt" + :background-color "#282a36" + :color "#e2e4e5") + ("#input" + :background-color "#282a36" + :color "#e2e4e5") + ("#suggestions" + :background-color "#282a36" + :color "#e2e4e5") + (.vi-insert-mode + :background-color "#282a36") + (.vi-normal-mode + :background-color "#282a36") + (.source + :margin-left "5px") + (.source-name + :background-color "#282a36" + :color "#e2e4e5") + (.source-content + :background-color "#282a36" + :color "#e2e4e5") + ;; (".source-content td" + ;; :background-color "#282a36" + ;; :color "#e2e4e5") + (".source-content th" + :background-color "#43454f" + :color "#e2e4e5") + ("#selection" + :background-color "#57c7ff" + :color "#34353e") + (.marked + :background-color "#5af78e" + :color "#34353e") + (.selected + :background-color "#57c7ff" + :color "#34353e") + (.button + :color "#e2e4e5"))))))) diff --git a/rofi/launchers-git/laptop-rbw.rasi b/rofi/launchers-git/laptop-rbw.rasi index 9c29e82..fcb817d 100644 --- a/rofi/launchers-git/laptop-rbw.rasi +++ b/rofi/launchers-git/laptop-rbw.rasi @@ -2,7 +2,7 @@ configuration { - font: "VictorMono Nerd Font 22.0"; + font: "VictorMono Nerd Font 12.0"; show-icons: false; } -@import "/home/chris/.config/rofi/config.rasi" \ No newline at end of file +@import "/home/chris/.config/rofi/config.rasi" diff --git a/scripts/nyxtlof b/scripts/nyxtlof index 018ca55..6a7d5e3 100755 --- a/scripts/nyxtlof +++ b/scripts/nyxtlof @@ -1,7 +1,7 @@ -#!/bin/sh +#!/bin/bash # Check to see if nyxt is running -if [ -n $(pgrep -c nyxt) ]; then +if pgrep -x nyxt > /dev/null; then echo running if [ $XDG_SESSION_TYPE = "x11" ]; then diff --git a/scripts/plasma-rofi-rbw.sh b/scripts/plasma-rofi-rbw.sh new file mode 100755 index 0000000..82244cd --- /dev/null +++ b/scripts/plasma-rofi-rbw.sh @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# Very basic interface for rbw using rofi + +if [ $(hostname) = "syl" ]; then + style="laptop-rbw" + #echo "this is hidpi" +else + style="desktop-rbw" + #echo "this is not hidpi" +fi + +# Get all password files and create an array +root=~/.password-store +CACHE=~/.local/tmp/pass_rofi +seat=seat0 + +rbw sync +rbw list + +list_passwords() { + rbw list +} + +passwords=$(rbw list) + +prompt='search for passwords...' +SECRET=$(list_passwords | rofi -i -p="${prompt}" -dmenu -theme ~/.config/rofi/launchers-git/$style.rasi) + +# Ask whether pass, user or both are required + +options=("Password" \ + "User" \ + "User and password" \ + "QR-Code" \ + "OTP") + +option=$(printf '%s\n' "${options[@]%}" | rofi -i -dmenu -width 400 -lines 4 -prompt="..." -theme ~/.config/rofi/launchers-git/$style.rasi) + +echo $option + +case ${option} in + Password ) + echo "${SECRET}" + ydotool type $(rbw get "${SECRET}") + ;; + User ) + ydotool type $(rbw get --full "${SECRET}" | rg Username: | awk '{$1 = ""; print $0}') + ;; + "User and password" ) + ydotool type $(rbw get --full "${SECRET}" | rg Username: | awk '{$1 = ""; print $0}') + ydotool key Tab + ydotool type $(rbw get "${SECRET}") + ;; + "QR-Code" ) + if [[ $SECRET =~ wifi$ ]]; then + # Produce a valid wifi QR-code + WIFISSID=$(pass get_user ${SECRET}) + WIFIPASS=$(pass get_pass ${SECRET}) + WIFIQR="WIFI:T:WPA;S:${WIFISSID};P:${WIFIPASS};;" + qrencode -s 8 -o - $WIFIQR | feh --title "pass: QR-WIFI" - + else + # Only password + pass show -q1 ${SECRET} + fi + ;; + "OTP" ) + ydotool type $(rbw code ${SECRET}) + ;; +esac + +# wl-copy -o -s ${seat} ${PASSWD_PASS} diff --git a/scripts/swayprop b/scripts/swayprop new file mode 100755 index 0000000..8a382d1 --- /dev/null +++ b/scripts/swayprop @@ -0,0 +1,32 @@ +#!/bin/bash + +ALL_NODES='recurse(.nodes[]?, .floating_nodes[]?) | select(.pid and .visible)' +WINDOW_NAME='(.app_id // .window_properties.class)' +ID_PREFIX='"\(.id):"' +WINDOW_PROTOCOL='(if .shell == "xwayland" then "X11" else "wayland" end)' +WINDOW_GEOMETRY='(.rect | "\(.x),\(.y) \(.width)x\(.height) ")' +WINDOW_PID='(.pid | tostring)' + +# Output format, e.g. "1234 - 12:firefox (wayland)" or "5678 - 17:discord (X11)" +FORMAT="$WINDOW_PID + \" - \" + $ID_PREFIX + $WINDOW_NAME + \" (\" + $WINDOW_PROTOCOL + \")\"" +FILT="$ALL_NODES | $WINDOW_GEOMETRY + $FORMAT" + +function getprop() { + typeset -A views + local selected + + while read POS GEOM INFO; do + views["$POS $GEOM"]="$INFO" + done + + selected="$(printf "%s\n" "${!views[@]}" | slurp)" + if [[ -n "$selected" ]]; then + printf '%s\n' "${views[${selected}]}" + fi +} + +if [[ "$1" == "wait" ]]; then + swaymsg -t subscribe '["workspace"]' | jq -r ".current | $FILT" | getprop +else + swaymsg -t get_tree | jq -r "$FILT" | getprop +fi \ No newline at end of file diff --git a/sway/config b/sway/config index b663ace..0d6a8cc 100644 --- a/sway/config +++ b/sway/config @@ -54,10 +54,10 @@ gaps inner 10 default_border none -# border_images.focused /home/chris/.config/sway/rounded_and_shadows_custom.png -# border_images.focused_inactive /home/chris/.config/sway/rounded_and_shadows_custom.png -# border_images.unfocused /home/chris/.config/sway/rounded_and_shadows_custom.png -# border_images.urgent /home/chris/.config/sway/rounded_and_shadows_custom.png +border_images.focused /home/chris/.config/sway/rounded_and_shadows_custom.png +border_images.focused_inactive /home/chris/.config/sway/rounded_and_shadows_custom.png +border_images.unfocused /home/chris/.config/sway/rounded_and_shadows_custom.png +border_images.urgent /home/chris/.config/sway/rounded_and_shadows_custom.png font pango: VictorMono Nerd Font 10 show_marks yes @@ -253,6 +253,8 @@ bar { workspace_buttons yes } +workspace 9 output DP-4 +workspace 3 output eDP-1 for_window [title="org-agenda"] floating enable, move scratchpad for_window [app_id="mpv"] floating enable @@ -262,9 +264,13 @@ for_window [app_id="pulsemixer"] floating enable for_window [app_id="__focused__"] opacity set 1 for_window [app_id="qutebrowser"] move container to workspace number 2, opacity set 1 for_window [app_id="nyxt"] move container to workspace number 2, opacity set 1 -for_window [title="Display Window"] move container to workspace number 9, fullscreen enable, move workspace to output right +for_window [title="Display Window"] move window to workspace number 9, fullscreen enable +for_window [title="OpenLP"] move window to workspace number 9, floating enable +for_window [title="VLC media player"] move window to workspace number 9, fullscreen enable # for_window [app_id="emacs"] opacity set 0.90 +focus_follows_mouse no + ### Locking screen bindsym $mod+Ctrl+l exec swaylock-blur --blur-sigma 80 diff --git a/waybar/config b/waybar/config index 02d6707..3fd7d78 100644 --- a/waybar/config +++ b/waybar/config @@ -4,7 +4,7 @@ "height": 30, // Waybar height (to be removed for auto height) // "width": 1280, // Waybar width // Choose the order of the modules "custom/wintitle", - "modules-left": ["sway/workspaces", "river/tags", "custom/wintitle", "sway/mode", "sway/window"], + "modules-left": ["sway/workspaces", "river/tags", "sway/mode", "sway/window"], "modules-center": ["clock"], "modules-right": ["pulseaudio", "network", "memory", "cpu", "battery", "battery#bat2", "tray"], "margin-top": 0,