feat: various changes

This commit is contained in:
Pavel Korytov 2021-01-10 12:36:32 +03:00
parent 5a3f3fa4d6
commit f5db638843
12 changed files with 135 additions and 10 deletions

View file

@ -215,7 +215,7 @@ media_library_albums_split_by_date = yes
#
#lines_scrolled = 2
#
lyrics_fetchers = lyricwiki, azlyrics, genius, sing365, lyricsmania, metrolyrics, justsomelyrics, jahlyrics, plyrics, tekstowo, internet
lyrics_fetchers = azlyrics, genius, musixmatch, sing365, metrolyrics, justsomelyrics, jahlyrics, plyrics, tekstowo, zeneszoveg, internet
#
#follow_now_playing_lyrics = no
#

View file

@ -76,6 +76,12 @@ type = custom/script
exec = /home/pavel/bin/polybar/ipstack.sh
interval = 1200
[module/weather]
type = custom/script
exec = /home/pavel/bin/polybar/weather.sh
format-underline = ${colors.red}
interval = 1200
[module/ipstack-vpn]
type = custom/script
exec = /home/pavel/bin/polybar/ipstack-vpn.sh

View file

@ -944,6 +944,18 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
;; Hightlight line
(global-hl-line-mode 1)
#+end_src
** Frame title
#+begin_src emacs-lisp
(setq frame-title-format
'(""
"emacs"
(:eval
(let ((project-name (projectile-project-name)))
(if (not (string= "-" project-name))
(format ":%s@%s" project-name (system-name))
(format "@%s" (system-name)))))
))
#+end_src
** Tab bar
#+begin_src emacs-lisp
(general-define-key
@ -1271,10 +1283,9 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
#+end_src
** JavaScript
#+begin_src emacs-lisp
(add-hook 'javascript-mode-hook #'smartparens-mode)
(my/set-smartparens-indent 'javascript-mode)
(add-hook 'js-mode-hook #'smartparens-mode)
(my/set-smartparens-indent 'js-mode)
#+end_src
** Vue.js
#+begin_src emacs-lisp
(use-package vue-mode
@ -1317,6 +1328,11 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
(add-hook 'svelte-mode-hook
'set-flycheck-eslint)
#+end_src
** SCSS
#+begin_src emacs-lisp
(add-hook 'scss-mode-hook #'smartparens-mode)
(my/set-smartparens-indent 'scss-mode)
#+end_src
** PHP
#+begin_src emacs-lisp
(use-package php-mode
@ -1375,11 +1391,15 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
(add-hook 'LaTeX-mode-hook
#'(lambda ()
(lsp)
(unless (string-match "\.hogan\.tex$" (buffer-name))
(lsp))
(setq-local lsp-diagnostic-package :none)
(setq-local flycheck-checker 'tex-chktex)))
(add-hook 'LaTeX-mode-hook #'rainbow-delimiters-mode)
(add-hook 'LaTeX-mode-hook #'smartparens-mode)
(my/set-smartparens-indent 'LaTeX-mode)
(general-nmap
:keymaps '(LaTeX-mode-map latex-mode-map)

View file

@ -800,6 +800,16 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
;; Hightlight line
(global-hl-line-mode 1)
(setq frame-title-format
'(""
"emacs"
(:eval
(let ((project-name (projectile-project-name)))
(if (not (string= "-" project-name))
(format ":%s@%s" project-name (system-name))
(format "@%s" (system-name)))))
))
(general-define-key
:keymaps 'override
:states '(normal emacs)
@ -1059,8 +1069,8 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
;; (add-hook 'typescript-mode-hook
;; #'set-flycheck-eslint)
(add-hook 'javascript-mode-hook #'smartparens-mode)
(my/set-smartparens-indent 'javascript-mode)
(add-hook 'js-mode-hook #'smartparens-mode)
(my/set-smartparens-indent 'js-mode)
(use-package vue-mode
:straight t)
@ -1098,6 +1108,9 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
(add-hook 'svelte-mode-hook
'set-flycheck-eslint)
(add-hook 'scss-mode-hook #'smartparens-mode)
(my/set-smartparens-indent 'scss-mode)
(use-package php-mode
:straight t)
@ -1145,11 +1158,15 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer."
(add-hook 'LaTeX-mode-hook
#'(lambda ()
(lsp)
(unless (string-match "\.hogan\.tex$" (buffer-name))
(lsp))
(setq-local lsp-diagnostic-package :none)
(setq-local flycheck-checker 'tex-chktex)))
(add-hook 'LaTeX-mode-hook #'rainbow-delimiters-mode)
(add-hook 'LaTeX-mode-hook #'smartparens-mode)
(my/set-smartparens-indent 'LaTeX-mode)
(general-nmap
:keymaps '(LaTeX-mode-map latex-mode-map)

View file

@ -8,5 +8,7 @@ if [ -d "$HOME/go" ] ; then
export PATH="$HOME/go/bin:$PATH"
fi
export PATH="/usr/local/texlive/2020/bin/x86_64-linux:$PATH"
[ -f "/home/pavel/.ghcup/env" ] && source "/home/pavel/.ghcup/env" # ghcup-env
emacs

View file

@ -23,8 +23,8 @@ declare -A BAR_HEIGHT=(
["HDMI-A-0"]="29"
)
declare -A BLOCKS=(
["DVI-D-0"]="pulseaudio SEP cpu ram-memory swap-memory SEP network ipstack-vpn SEP xkeyboard SEP sun aw-afk date TSEP"
["HDMI-A-0"]="pulseaudio mpd SEP cpu ram-memory swap-memory SEP network ipstack-vpn SEP xkeyboard SEP sun aw-afk date TSEP"
["DVI-D-0"]="pulseaudio SEP cpu ram-memory swap-memory SEP network ipstack-vpn SEP xkeyboard SEP weather SEP sun aw-afk date TSEP"
["HDMI-A-0"]="pulseaudio mpd SEP cpu ram-memory swap-memory SEP network ipstack-vpn SEP xkeyboard SEP weather SEP sun aw-afk date TSEP"
["eDP1"]="pulseaudio mpd SEP cpu ram-memory swap-memory SEP network ipstack-vpn SEP xkeyboard SEP battery SEP sun aw-afk date TSEP"
)

12
bin/polybar/aw_afk.sh Executable file
View file

@ -0,0 +1,12 @@
#!/bin/bash
afk_event=$(curl -s -X GET "http://localhost:5600/api/0/buckets/aw-watcher-afk_$(hostname)/events?limit=1" -H "accept: application/json")
status=$(echo ${afk_event} | jq -r '.[0].data.status')
afk_time=$(echo "${afk_event}" | jq -r '.[0].duration' | xargs -I ! date -u -d @! +"%H:%M")
uptime=$(datediff "$(uptime -s | xargs -I ! date -d ! -Iseconds)" "$(date -Iseconds)" -f '%H:%M' | xargs -I ! date -d ! +"%H:%M")
res="${afk_time} / ${uptime}"
if [[ $status == 'afk' ]]; then
echo "%{u#f07178}%{+u} [AFK] $res %{u-}"
else
echo "%{u#82aaff}%{+u} $res %{u-}"
fi

17
bin/polybar/ipstack-vpn.sh Executable file
View file

@ -0,0 +1,17 @@
#!/bin/bash
ip=$(dig +short +timeout=1 myip.opendns.com @resolver1.opendns.com 2> /dev/null)
API_KEY="8948d12cd68a3b7ac60d405ed4118b43"
if [[ -z $ip || $ip == *"timed out"* ]]; then
echo "%{u#f07178}%{+u} ?? %{u-}"
exit
fi
ip_info=$(curl -s http://api.ipstack.com/${ip}?access_key=${API_KEY})
# emoji=$(echo $ip_info | jq -r '.location.country_flag_emoji')
code=$(echo $ip_info | jq -r '.country_code')
vpn=$(pgrep -a openvpn$ | head -n 1 | awk '{print $NF }' | cut -d '.' -f 1)
if [ -n "$vpn" ]; then
echo "%{u#9cc4ff}%{+u}  $code %{u-}"
else
echo "%{u#f07178}%{+u}  $code %{u-}"
fi

11
bin/polybar/ipstack.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
ip=$(dig +short +timeout=1 myip.opendns.com @resolver1.opendns.com 2> /dev/null)
API_KEY="8948d12cd68a3b7ac60d405ed4118b43"
if [[ -z $ip || $ip == *"timed out"* ]]; then
echo "%{u#f07178}%{+u} ?? %{u-}"
exit
fi
ip_info=$(curl -s http://api.ipstack.com/${ip}?access_key=${API_KEY})
# emoji=$(echo $ip_info | jq -r '.location.country_flag_emoji')
code=$(echo $ip_info | jq -r '.country_code')
echo "%{u#9cc4ff}%{+u} $code $ip %{u-}"

22
bin/polybar/sun.sh Executable file
View file

@ -0,0 +1,22 @@
#1/bin/bash
LAT=59.9375N
LON=30.308611E
time=$(sunwait poll daylight rise ${LAT} $LON)
function send_report {
report="$(sunwait report ${LAT} ${LON} | sed 's/^[[:space:]]*//gm')"
notify-send "Sunwait report" "$report"
}
case $BLOCK_BUTTON in
1) send_report
esac
if [[ ${time} == 'DAY' ]]; then
sunset=$(sunwait list daylight set ${LAT} ${LON})
echo "%{u#ffcb6b}%{+u} $sunset %{u-}"
else
sunrise=$(sunwait list daylight rise ${LAT} ${LON})
echo "%{u#f07178}%{+u} $sunrise %{u-}"
fi

4
bin/polybar/tray-sep.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
if [ ! -z "$TRAY" ] && [ "$TRAY" != "none" ]; then
echo "| "
fi

14
bin/polybar/weather.sh Executable file
View file

@ -0,0 +1,14 @@
#/bin/sh
bar_format="${BAR_FORMAT:-"%t"}"
location="${LOCATION:-"Saint-Petersburg"}"
format_1=${FORMAT_1:-"qF"}
format_2=${FORMAT_1:-"format=v2n"}
bar_weather=$(curl -s wttr.in/${location}?format=${bar_format} || echo "??")
if [ -z ${bar_weather} ]; then
exit 1
elif [[ ${bar_weather} == *"Unknown"* ]]; then
echo "??"
exit 1
fi
echo ${bar_weather}