add notice with 'Dunst'

This commit is contained in:
Xamora 2024-12-19 21:44:36 +01:00
parent 81ca9ac556
commit 5a89716567
5 changed files with 61 additions and 13 deletions

28
battery_notice.sh Normal file
View file

@ -0,0 +1,28 @@
#!/bin/bash
# Low battery notifier
# Kill already running processes
already_running="$(ps -fC 'grep' -N | grep 'battery_notice.sh' | wc -l)"
if [[ $already_running -gt 1 ]]; then
pkill -f --older 1 'battery_notice.sh'
fi
# Get path
path="$( dirname "$(readlink -f "$0")" )"
while [[ 0 -eq 0 ]]; do
battery_status="$(cat /sys/class/power_supply/BAT1/status)"
battery_charge="$(cat /sys/class/power_supply/BAT1/capacity)"
if [[ $battery_status == 'Discharging' && $battery_charge -le 40 ]]; then
if [[ $battery_charge -le 20 ]]; then
notify-send --replace-id=0 --icon=" " --urgency=critical "Battery critical!" "${battery_charge}% 🪫"
sleep 120
elif [[ $battery_charge -eq 40 ]]; then
notify-send --replace-id=1 --icon=" " --urgency=normal "Battery low!" "${battery_charge}% 🪫" --expire-time=30000
sleep 240
fi
else
sleep 60
fi
done

View file

@ -1,13 +1,18 @@
syntax on
set showmatch
set number set number
set relativenumber set relativenumber
set autoindent set autoindent
set smarttab
set expandtab
set smartindent
set shiftwidth=4
set softtabstop=4
set tabstop=4 set tabstop=4
set mouse=a
"set list "set list
"set listchars=tab:>. "set listchars=tab:>.
set shiftwidth=4
set smarttab
set softtabstop=4
set mouse=a
" tab is space in python, patch " tab is space in python, patch
autocmd FileType python setlocal noexpandtab autocmd FileType python setlocal noexpandtab
@ -34,12 +39,15 @@ Plug 'https://github.com/preservim/tagbar' " Tagbar for code navigation
Plug 'norcalli/nvim-colorizer.lua' "Color Hexadecimal Plug 'norcalli/nvim-colorizer.lua' "Color Hexadecimal
Plug 'https://github.com/chrisbra/unicode.vim' "For utf-8 emoji Plug 'https://github.com/chrisbra/unicode.vim' "For utf-8 emoji
call plug#end()
"Theme
colorscheme industry
" for vim-devicons " for vim-devicons
set encoding=UTF-8 set encoding=UTF-8
let g:airline_powerline_fonts = 1 let g:airline_powerline_fonts = 1
call plug#end()
" If there are only terminal and NerdTree, all close " If there are only terminal and NerdTree, all close
autocmd bufenter * if (winnr("$") == 2 && IsNerdTreeEnabled() && g:terminal_id != -1) | qa | endif autocmd bufenter * if (winnr("$") == 2 && IsNerdTreeEnabled() && g:terminal_id != -1) | qa | endif

View file

@ -1,7 +1,12 @@
#!/bin/sh #!/bin/sh
#sway
mkdir -p ~/.config/sway mkdir -p ~/.config/sway
cp -v sway-config ~/.config/sway/config cp -v sway-config ~/.config/sway/config
cp -v status.sh ~/.config/sway/status.sh cp -v status.sh ~/.config/sway/status.sh
cp -v battery_notice.sh ~/.config/sway/battery_notice.sh
#other
cp -v config.fish ~/.config/fish cp -v config.fish ~/.config/fish
cp -v bashrc ~/.bashrc cp -v bashrc ~/.bashrc
cp -v ssh-config ~/.ssh/config cp -v ssh-config ~/.ssh/config

View file

@ -11,9 +11,7 @@ battery_status=$(cat /sys/class/power_supply/BAT1/status)
battery_level=$(cat /sys/class/power_supply/BAT1/capacity) battery_level=$(cat /sys/class/power_supply/BAT1/capacity)
battery_symbol=🔋 battery_symbol=🔋
if [ "$battery_level" -ge 20 ]; then if [ "$battery_level" -lt 20 ]; then
battery_symbol=🔋
elif [ "$battery_level" -lt 20 ]; then
battery_symbol=🪫 battery_symbol=🪫
fi fi

View file

@ -23,7 +23,7 @@ set $menu dmenu_path | dmenu | xargs swaymsg exec --
### Output configuration ### Output configuration
# #
# Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/) # Default wallpaper (more resolutions are available in /usr/share/backgrounds/sway/)
output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill # output * bg /usr/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
# #
# Example configuration: # Example configuration:
# #
@ -220,10 +220,11 @@ mode "resize" {
bar { bar {
position top position top
mode hide mode hide
modifier $mod
# When the status_command prints a new line to stdout, swaybar updates. # When the status_command prints a new line to stdout, swaybar updates.
# The default just shows the current date and time. # The default just shows the current date and time.
status_command while bash ~/.config/sway/status.sh; do sleep 1; done status_command while bash ~/.config/sway/status.sh; do sleep 0; done
colors { colors {
statusline #ffffff statusline #ffffff
@ -251,7 +252,15 @@ bindsym XF86MonBrightnessUp exec brightnessctl set 2%+
bindsym $mod+XF86MonBrightnessUp exec brightnessctl set 100% bindsym $mod+XF86MonBrightnessUp exec brightnessctl set 100%
bindsym $mod+XF86MonBrightnessDown exec brightnessctl set 1 bindsym $mod+XF86MonBrightnessDown exec brightnessctl set 1
# Sound button
bindsym XF86AudioMute exec amixer sset Master toggle bindsym XF86AudioMute exec amixer sset Master toggle
bindsym XF86AudioLowerVolume exec amixer sset Master 5%- bindsym XF86AudioLowerVolume exec amixer sset Master 6%-
bindsym XF86AudioRaiseVolume exec amixer sset Master 5%+ bindsym XF86AudioRaiseVolume exec amixer sset Master 6%+
bindsym Ctrl+XF86AudioLowerVolume exec amixer sset Master 1%-
bindsym Ctrl+XF86AudioRaiseVolume exec amixer sset Master 1%+
bindsym $mod+XF86AudioLowerVolume exec amixer sset Master 6%-
bindsym $mod+XF86AudioRaiseVolume exec amixer sset Master 6%+
bindsym $mod+Ctrl+XF86AudioLowerVolume exec amixer sset Master 1%-
bindsym $mod+Ctrl+XF86AudioRaiseVolume exec amixer sset Master 1%+
exec_always bash /home/xamo/.config/sway/battery_notice.sh