scripts for sway

This commit is contained in:
tavo-wasd 2024-02-04 19:01:27 -06:00
parent fc5c2fac9f
commit 9f7aa08519
10 changed files with 178 additions and 43 deletions

View file

@ -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" &&

View file

@ -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"

View file

@ -2,4 +2,4 @@
# Increases mic volume by 5%
amixer set Capture 5%+
kill -45 "$(pidof dwmblocks)"
kill -45 "$(pidof dwmblocks)" 2>/dev/null

View file

@ -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%"

View file

@ -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

118
scripts/status/sway Executable file
View file

@ -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

View file

@ -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

View file

@ -3,4 +3,4 @@
# then restarts statusbar module
amixer set Master 5%+ unmute
kill -44 "$(pidof dwmblocks)"
kill -44 "$(pidof dwmblocks)" 2>/dev/null

View file

@ -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
}
}

15
tofi/config Normal file
View file

@ -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