From 9f7aa08519ba4f28b73c1bed4c49379a14f0af64 Mon Sep 17 00:00:00 2001 From: tavo-wasd Date: Sun, 4 Feb 2024 19:01:27 -0600 Subject: [PATCH] scripts for sway --- scripts/menu/menu | 16 ++++-- scripts/menu/menu-pass | 5 +- scripts/micup | 2 +- scripts/status/batstat | 15 ++---- scripts/status/micstat | 4 +- scripts/status/sway | 118 +++++++++++++++++++++++++++++++++++++++++ scripts/status/volstat | 4 +- scripts/volup | 2 +- sway/config | 40 +++++++------- tofi/config | 15 ++++++ 10 files changed, 178 insertions(+), 43 deletions(-) create mode 100755 scripts/status/sway create mode 100644 tofi/config diff --git a/scripts/menu/menu b/scripts/menu/menu index 0c1749d..b7e2f3d 100755 --- a/scripts/menu/menu +++ b/scripts/menu/menu @@ -4,10 +4,10 @@ PROMPT="$1" ; MODE="$2" # Configuration -MENU="bemenu" # Default to fzf +MENU="tofi" # Default to fzf col_nb="#121212" # Normal background col_nf="#665c54" # Normal foreground -col_sb="#d3869b" # Selected background +col_sb="#2e9ef4" # Selected background col_sf="#121212" # Selected foreground font="JetbrainsMono" font_size="10" @@ -63,7 +63,12 @@ DMENU_OPTS=" \ $DPASS \ " -# dmenu opts +# tofi opts +TOFI_OPTS=" \ + --prompt-text "$PROMPT" \ +" + +# fzf opts FZF_OPTS=" \ --cycle \ --reverse \ @@ -79,6 +84,11 @@ FZF_OPTS=" \ OPTS="$DMENU_OPTS" && RUN="_run" +# If chosen tofi, use this args +[ "$MENU" = "tofi" ] && + OPTS="$TOFI_OPTS" && + RUN="-run" + # If chosen fzf, use this args [ "$MENU" = "fzf" ] && OPTS="$FZF_OPTS" && diff --git a/scripts/menu/menu-pass b/scripts/menu/menu-pass index 0779718..20e368e 100755 --- a/scripts/menu/menu-pass +++ b/scripts/menu/menu-pass @@ -1,7 +1,8 @@ #!/bin/sh # menu for 'pass' -PASSWORD_STORE_DIR="$XDG_DATA_HOME/password-store" +PASSWORD_STORE_DIR="$HOME/.password-store" +MENU="$HOME/.config/scripts/menu/menu" -password="$(find "$PASSWORD_STORE_DIR" -type f -name '*.gpg' | sed "s@$PASSWORD_STORE_DIR/@@g ; s@.gpg@@g" | menu "Password:")" +password="$(find "$PASSWORD_STORE_DIR" -type f -name '*.gpg' | sed "s@$PASSWORD_STORE_DIR/@@g ; s@.gpg@@g" | $MENU "Pass:")" ! [ -z "$password" ] && printf '%s' "$password" diff --git a/scripts/micup b/scripts/micup index ef6c343..fc22300 100755 --- a/scripts/micup +++ b/scripts/micup @@ -2,4 +2,4 @@ # Increases mic volume by 5% amixer set Capture 5%+ -kill -45 "$(pidof dwmblocks)" +kill -45 "$(pidof dwmblocks)" 2>/dev/null diff --git a/scripts/status/batstat b/scripts/status/batstat index 46a6654..90237c9 100755 --- a/scripts/status/batstat +++ b/scripts/status/batstat @@ -28,20 +28,11 @@ case 1 in $((bat >= 40)) ) bar="━━━━──────" ;; $((bat >= 30)) ) bar="━━━───────" ;; $((bat >= 20)) ) bar="━━────────" ;; - $((bat >= 10)) ) bar="━!────────" ;; - $((bat >= 0)) ) bar="CHARGE NOW" ;; + $((bat >= 10)) ) bar="━─────────" ;; + $((bat >= 10)) ) bar="──────────" ;; esac + # Charging indicator if status file indicates such state [ "$stat" != "Charging" ] && icon="󰁹" || icon="" echo "$icon $bar" - -# Warning when battery is under 10% capacity and not charging -[ $((bat)) -lt 16 ] && [ $((bat)) -gt 14 ] && [ "$stat" != "Charging" ] && - notify-send --replace-id=15 "󰁹 Battery" "Capacity at $bat%" - -[ $((bat)) -lt 11 ] && [ $((bat)) -gt 9 ] && [ "$stat" != "Charging" ] && - notify-send --replace-id=15 "󰁹 Battery" "Capacity at $bat%" - -[ $((bat)) -lt 6 ] && [ "$stat" != "Charging" ] && - notify-send --replace-id=15 "󰁹 Battery" "Capacity at $bat%" diff --git a/scripts/status/micstat b/scripts/status/micstat index 7c9251d..dd0d37e 100755 --- a/scripts/status/micstat +++ b/scripts/status/micstat @@ -9,7 +9,7 @@ vol="${vol%\%*}" # Remove percentage sign # If device is off (muted), notify mute, print volume otherwise if amixer scontents | grep "Capture" | grep -q "\[off\]"; then echo " ──────────" - notify-send -u low --replace-id=11 " Microphone" "Mute" + notify-send -u low --replace-id=11 " Microphone" "Mute" 2>/dev/null exit fi @@ -30,4 +30,4 @@ esac # Print and notify echo " $bar" -notify-send -u low --replace-id=11 " Microphone" "$bar" +notify-send -u low --replace-id=11 " Microphone" "$bar" 2>/dev/null diff --git a/scripts/status/sway b/scripts/status/sway new file mode 100755 index 0000000..6775d2e --- /dev/null +++ b/scripts/status/sway @@ -0,0 +1,118 @@ +#!/bin/sh + +get_vol() { + vol=$(amixer | grep "Playback" | grep -o '[0-9]*[0-9]%' | head -n 1) + vol="${vol%\%*}" # Remove percentage sign + + if amixer scontents | grep "Playback" | grep -q "\[off\]"; then + echo "󰖁 ──────────" + exit + fi + + case 1 in + $((vol >= 100)) ) bar="━━━━━━━━━━" ;; + $((vol >= 90)) ) bar="━━━━━━━━━─" ;; + $((vol >= 80)) ) bar="━━━━━━━━──" ;; + $((vol >= 70)) ) bar="━━━━━━━───" ;; + $((vol >= 60)) ) bar="━━━━━━────" ;; + $((vol >= 50)) ) bar="━━━━━─────" ;; + $((vol >= 40)) ) bar="━━━━──────" ;; + $((vol >= 30)) ) bar="━━━───────" ;; + $((vol >= 20)) ) bar="━━────────" ;; + $((vol >= 10)) ) bar="━─────────" ;; + $((vol >= 0)) ) bar="──────────" ;; + esac + + echo "󰕾 $bar" +} + +get_mic() { + vol=$(amixer | grep "Capture" | grep -o '[0-9]*[0-9]%' | tail -n 1) + vol="${vol%\%*}" # Remove percentage sign + + if amixer scontents | grep "Capture" | grep -q "\[off\]"; then + echo " ──────────" + exit + fi + + case 1 in + $((vol >= 100)) ) bar="━━━━━━━━━━" ;; + $((vol >= 90)) ) bar="━━━━━━━━━─" ;; + $((vol >= 80)) ) bar="━━━━━━━━──" ;; + $((vol >= 70)) ) bar="━━━━━━━───" ;; + $((vol >= 60)) ) bar="━━━━━━────" ;; + $((vol >= 50)) ) bar="━━━━━─────" ;; + $((vol >= 40)) ) bar="━━━━──────" ;; + $((vol >= 30)) ) bar="━━━───────" ;; + $((vol >= 20)) ) bar="━━────────" ;; + $((vol >= 10)) ) bar="━─────────" ;; + $((vol >= 0)) ) bar="──────────" ;; + esac + + echo " $bar" +} + +get_bat() { + total=0 + batteries=0 + + for battery in /sys/class/power_supply/BAT?* ; do + capacity=$(cat $battery/capacity 2>/dev/null || break) + total=$((capacity+total)) + batteries=$(($batteries+1)) + done + + [ $total -gt 0 ] && bat=$(($total/$batteries)) || bat="󰚥" + [ "$bat" = "󰚥" ] && echo "$bat" && exit + grep -rq 'Charging' /sys/class/power_supply/BAT* 2>/dev/null && stat='Charging' + + case 1 in + $((bat >= 98)) ) bar="━━━━━━━━━━" ;; + $((bat >= 90)) ) bar="━━━━━━━━━─" ;; + $((bat >= 80)) ) bar="━━━━━━━━──" ;; + $((bat >= 70)) ) bar="━━━━━━━───" ;; + $((bat >= 60)) ) bar="━━━━━━────" ;; + $((bat >= 50)) ) bar="━━━━━─────" ;; + $((bat >= 40)) ) bar="━━━━──────" ;; + $((bat >= 30)) ) bar="━━━───────" ;; + $((bat >= 20)) ) bar="━━────────" ;; + $((bat >= 10)) ) bar="━─────────" ;; + $((bat >= 10)) ) bar="──────────" ;; + esac + + [ "$stat" != "Charging" ] && icon="󰁹" || icon="" + echo "$icon $bar" +} + +get_layout() { + layout="$( \ + setxkbmap -query | grep layout | awk '{print $2}' | + sed 's/latam/la/' \ + )" + + echo "󰌌 $layout" +} + +while true ; do + status="" + separator=" " + + volume="$(get_vol)" + ! [ -z "$volume" ] && status="$status$separator$volume" + + microphone="$(get_mic)" + ! [ -z "$microphone" ] && status="$status$separator$microphone" + + battery="$(get_bat)" + ! [ -z "$battery" ] && status="$status$separator$battery" + + layout="$(get_layout)" + ! [ -z "$layout" ] && status="$status$separator$layout" + + date_time="$(date "+%I:%M%p$separator%a %Y-%m-%d")" + ! [ -z "$date_time" ] && status="$status$separator$date_time" + + printf "%s \n" "$status" + # exit 0 # Testing + sleep 0.5 +done diff --git a/scripts/status/volstat b/scripts/status/volstat index 73b20c6..aadbaaa 100755 --- a/scripts/status/volstat +++ b/scripts/status/volstat @@ -9,7 +9,7 @@ vol="${vol%\%*}" # Remove percentage sign # If device is off (muted), notify mute, print volume otherwise if amixer scontents | grep "Playback" | grep -q "\[off\]"; then echo "󰖁 ──────────" - notify-send -u low --replace-id=10 "󰖁 Volume" "Mute" + notify-send -u low --replace-id=10 "󰖁 Volume" "Mute" 2>/dev/null exit fi @@ -30,4 +30,4 @@ esac # Print and notify echo "󰕾 $bar" -notify-send -u low --replace-id=10 "󰕾 Volume" "$bar" +notify-send -u low --replace-id=10 "󰕾 Volume" "$bar" 2>/dev/null diff --git a/scripts/volup b/scripts/volup index b121b77..66d8419 100755 --- a/scripts/volup +++ b/scripts/volup @@ -3,4 +3,4 @@ # then restarts statusbar module amixer set Master 5%+ unmute -kill -44 "$(pidof dwmblocks)" +kill -44 "$(pidof dwmblocks)" 2>/dev/null diff --git a/sway/config b/sway/config index 1673635..ca0684f 100644 --- a/sway/config +++ b/sway/config @@ -1,24 +1,24 @@ # Preferences +output * bg ~/Pictures/backgrounds/4.jpg fill +input "type:touchpad" natural_scroll enabled +input "type:pointer" accel_profile flat set $mod Mod4 set $left h set $down j set $up k set $right l + set $term foot -set $menu /home/tavo/.config/scripts/menu/menu "Run:" run -output * bg /home/tavo/Pictures/backgrounds/background.jpg fill +set $menu ~/.config/scripts/menu/menu "Run:" run | xargs swaymsg exec -- # Keybinds -input "type:pointer" accel_profile flat -input "type:touchpad" natural_scroll enabled bindsym $mod+Return exec $term bindsym $mod+c kill bindsym $mod+r exec $menu floating_modifier $mod normal bindsym $mod+q reload bindsym $mod+Shift+q exec swaymsg exit - -# Navigation +# - bindsym $mod+$left focus left bindsym $mod+$down focus down bindsym $mod+$up focus up @@ -36,8 +36,7 @@ bindsym $mod+Shift+Left move left bindsym $mod+Shift+Down move down bindsym $mod+Shift+Up move up bindsym $mod+Shift+Right move right - -# Workspaces +# - bindsym $mod+1 workspace " I " bindsym $mod+2 workspace " II " bindsym $mod+3 workspace " III " @@ -48,27 +47,28 @@ bindsym $mod+Shift+2 move container to workspace " II " bindsym $mod+Shift+3 move container to workspace " III " bindsym $mod+Shift+4 move container to workspace " IV " bindsym $mod+Shift+5 move container to workspace " V " - -# Layout +# - bindsym $mod+b splith bindsym $mod+v splitv bindsym $mod+Shift+t layout tabbed bindsym $mod+e layout toggle split bindsym $mod+f fullscreen bindsym $mod+Shift+f floating toggle -default_border pixel 2 -gaps inner 5 + +# Layout +client.focused #00000000 #2e9ef4 #00000000 +default_border pixel 1 +gaps inner 10 bar { - position top - - # When the status_command prints a new line to stdout, swaybar updates. - # The default just shows the current date and time. - status_command while date +'%Y-%m-%d %I:%M:%S %p'; do sleep 1; done + position bottom + font pango:JetBrainsMono Bold 9 + status_command ~/.config/scripts/status/sway colors { - statusline #ffffff - background #323232 - inactive_workspace #32323200 #32323200 #5c5c5c + background #00000000 + statusline #2e9ef4 + focused_workspace #2e9ef450 #2e9ef420 #ffffff + inactive_workspace #00000000 #00000000 #2e9ef4 } } diff --git a/tofi/config b/tofi/config new file mode 100644 index 0000000..7bfa144 --- /dev/null +++ b/tofi/config @@ -0,0 +1,15 @@ +font = /usr/share/fonts/truetype/jetbrains-mono/JetBrainsMono-Medium.ttf +font-size = 10 +text-color = #323232 +input-color = #ffffff +prompt-text = "run: " +prompt-padding = 0 +placeholder-text = "" +selection-color = #2e9ef4 +num-results = 0 +width = 30% +height = 30% +background-color = #121212 +outline-width = 0 +border-width = 1 +border-color = #2e9ef4