diff options
54 files changed, 737 insertions, 138 deletions
diff --git a/bin/batt b/bin/batt new file mode 100755 index 0000000..c99c3a3 --- /dev/null +++ b/bin/batt @@ -0,0 +1,18 @@ +#!/bin/env bash + +batt() { + batt="$(acpi | awk '{print $4}' | sed -e 's/%,//g')" + icon="" + + [ "$batt" -ge 90 ] && icon="" + + [ "$batt" -le 50 ] && icon="" + + [ "$batt" -le 20 ] && icon="" + + [ "$batt" -le 5 ] && icon="" + + printf "%s %d%%" "$icon" "$batt" +} + +batt diff --git a/bin/battery_check b/bin/battery_check new file mode 100755 index 0000000..af44108 --- /dev/null +++ b/bin/battery_check @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Simple script to monitor the battery's status + +# calls batt_status script +batt=$(acpi | awk '{print $4}' | sed -e 's/\%,//g') +state=$(acpi | awk '{print }' | sed -e 's/\,//g') + +if [[ $batt -ge 99 ]]; then + notify-send "Bateria" "Completamente carregada! (100%)" +elif [[ $batt -eq 20 ]] ; then + notify-send "Bateria descarregando" "Nível de bateria alcançou 20%" +elif [[ $batt -eq 10 ]] ; then + notify-send "Bateria descarregando" "Nível de bateria alcançou 10%" +elif [[ $batt -le 5 ]]; then + notify-send "Bateria crítica!" "Nível de bateria alcançou 5%" +fi diff --git a/bin/bspHide b/bin/bspHide new file mode 100755 index 0000000..c69182d --- /dev/null +++ b/bin/bspHide @@ -0,0 +1,13 @@ +#!/bin/env bash + +# hides focused window +# if there are any hidden windows in the current desktop, \ +# unhide them + +hidden=$(bspc query -N -n .hidden -d focused) + +if [ -z "$hidden" ]; then + bspc node focused -g hidden=on +else + bspc node "$hidden" -g hidden=off +fi diff --git a/bin/bspswallow b/bin/bspswallow new file mode 100755 index 0000000..35784a2 --- /dev/null +++ b/bin/bspswallow @@ -0,0 +1,53 @@ +#!/bin/sh + +# Get class of a wid +get_class() { + id=$1 + if [ -z "$id" ]; then + echo "" + else + xprop -id "$id" | sed -n '/WM_CLASS\|WM_COMMAND/s/.*"\(.*\)".*/\1/p' + fi +} + +swallow() { + addedtodesktop=$2 + lasttermdesktop=$(bspc query -D -n last) + + swallowerid=$1 + swallowingid=$(bspc query -N -n last) + + if [ "$addedtodesktop" = "$lasttermdesktop" ]; then + cat ~/.config/bspwm/noswallow ~/.config/bspwm/terminals | grep "^$(get_class "$swallowerid")$" && return + grep "^$(get_class "$swallowingid")$" ~/.config/bspwm/terminals || return + echo "$swallowerid $swallowingid" >> /tmp/swallowids + bspc node "$swallowingid" --flag hidden=on + fi +} + +spit() { + spitterid=$1 + spitterdesktop=$2 + grep "^$spitterid" /tmp/swallowids || return + spittingid=$(grep "^$spitterid" /tmp/swallowids | head -n1 | awk '{print $2}') + + bspc node "$spittingid" --flag hidden=off + + termdesktop=$(bspc query -D -n "$spittingid") + [ "$termdesktop" = "$spitterdesktop" ] || bspc node "$spittingid" -d "$spitterdesktop" + + bspc node "$spittingid" -f + sed -i "/^$spitterid/d" /tmp/swallowids +} + +bspc subscribe node_add node_remove | while read -r event +do + case $(echo "$event" | awk '{ print $1 }') in + node_add) + swallow $(echo "$event" | awk '{print $5 " " $3}') + ;; + node_remove) + spit $(echo "$event" | awk '{print $4 " " $3}') + ;; + esac +done diff --git a/bin/chardetect b/bin/chardetect new file mode 100755 index 0000000..09f9ed1 --- /dev/null +++ b/bin/chardetect @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from chardet.cli.chardetect import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) @@ -0,0 +1,11 @@ +#!/bin/env bash +# checks the amount of CPU being used + +cpu() { + cpu="$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1); }' \ + <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat))" + + printf " %.0f%%" "$cpu" +} + +cpu diff --git a/bin/customwiki2html.sh b/bin/customwiki2html.sh new file mode 100755 index 0000000..4818d02 --- /dev/null +++ b/bin/customwiki2html.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +# +# This script converts markdown into html, to be used with vimwiki's +# "customwiki2html" option. Experiment with the two proposed methods by +# commenting / uncommenting the relevant lines below. +# +# NEW! An alternative converter was developed by Jason6Anderson, and can +# be located at https://github.com/vimwiki-backup/vimwiki/issues/384 +# +# +# To use this script, you must have the Discount converter installed. +# +# http://www.pell.portland.or.us/~orc/Code/discount/ +# +# To verify your installation, check that the commands markdown and mkd2text, +# are on your path. +# +# Also verify that this file is executable. +# +# Then, in your .vimrc file, set: +# +# g:vimwiki_customwiki2html=$HOME.'/.vim/autoload/vimwiki/customwiki2html.sh' +# +# On your next restart, Vimwiki will run this script instead of using the +# internal wiki2html converter. +# + +MARKDOWN=markdown +MKD2HTML=mkd2html + + +FORCE="$1" +SYNTAX="$2" +EXTENSION="$3" +OUTPUTDIR="$4" +INPUT="$5" +CSSFILE="$6" + +FORCEFLAG= + +[ $FORCE -eq 0 ] || { FORCEFLAG="-f"; }; +[ $SYNTAX = "markdown" ] || { echo "Error: Unsupported syntax"; exit -2; }; + +OUTPUT="$OUTPUTDIR"/$(basename "$INPUT" .$EXTENSION).html + +# # Method 1: +# # markdown [-d] [-T] [-V] [-b url-base] [-C prefix] [-F bitmap] [-f flags] [-o file] [-s text] [-t text] [textfile] +# +# URLBASE=http://example.com +# $MARKDOWN -T -b $URLBASE -o $OUTPUT $INPUT + + +# Method 2: +# mkd2html [-css file] [-header string] [-footer string] [file] + +$MKD2HTML -css "$CSSFILE" "$INPUT" +OUTPUTTMP=$(dirname "$INPUT")/$(basename "$INPUT" ."$EXTENSION").html +mv -f "$OUTPUTTMP" "$OUTPUT" + + + diff --git a/bin/easy_install b/bin/easy_install new file mode 100755 index 0000000..bb83ac1 --- /dev/null +++ b/bin/easy_install @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from setuptools.command.easy_install import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/easy_install-3.8 b/bin/easy_install-3.8 new file mode 100755 index 0000000..bb83ac1 --- /dev/null +++ b/bin/easy_install-3.8 @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from setuptools.command.easy_install import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/f2py b/bin/f2py new file mode 100755 index 0000000..40ce6f8 --- /dev/null +++ b/bin/f2py @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from numpy.f2py.f2py2e import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/f2py3 b/bin/f2py3 new file mode 100755 index 0000000..40ce6f8 --- /dev/null +++ b/bin/f2py3 @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from numpy.f2py.f2py2e import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/f2py3.9 b/bin/f2py3.9 new file mode 100755 index 0000000..40ce6f8 --- /dev/null +++ b/bin/f2py3.9 @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from numpy.f2py.f2py2e import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/frame_spawn b/bin/frame_spawn new file mode 100755 index 0000000..5e6dfd3 --- /dev/null +++ b/bin/frame_spawn @@ -0,0 +1,18 @@ +#!/bin/env bash + +# Based on: +# https://github.com/herbstluftwm/herbstluftwm/issues/1164 + + +# The script compares the number of opened windows in the focused tiling frame, and then compares: +# 1) If the frame is not empty (!= 0), then it wll be split vertically by a ratio of 0.5 \ +# and the application will be opened in the new, empty frame +# 2) If the frame is empty, then the application will simply be spawned on it. + +herbstclient \ + chain \ + , and \ + : compare tags.focus.tiling.focused_frame.client_count != 0 \ + : split auto \ + , rule once index=e focus=on \ + , spawn "$1" @@ -0,0 +1,13 @@ +#!/bin/env bash + +sleep 1 +DISPLAY=":0.0" +HOME=/home/math/ +XAUTHORITY=$HOME/.Xauthority +export DISPLAY XAUTHORITY HOME + +kb_id=`xinput -list | grep -i 'sino wealth' | grep -o id=[0-9]. | grep -o [0-9]. | head -1` + +xset r rate 250 40 +setxkbmap -model abnt2 -layout br -variant abnt2 +xmodmap "/home/math/.Xmodmap" diff --git a/bin/kbd_udev b/bin/kbd_udev new file mode 100755 index 0000000..7c51dfa --- /dev/null +++ b/bin/kbd_udev @@ -0,0 +1,3 @@ +#!/bin/env bash + +/home/math/.local/bin/kbd & diff --git a/bin/launch_dwm b/bin/launch_dwm new file mode 100755 index 0000000..9868f00 --- /dev/null +++ b/bin/launch_dwm @@ -0,0 +1,18 @@ +#!/bin/env sh + +# relaunch DWM if the binary changes, otherwise bail +csum="" +new_csum=$(sha1sum $(which dwm)) +while true +do + if [ "$csum" != "$new_csum" ] + then + csum=$new_csum + dwm + else + exit 0 + fi + new_csum=$(sha1sum $(which dwm)) + sleep 0.5 +done + diff --git a/bin/markdown_py b/bin/markdown_py new file mode 100755 index 0000000..ca0b785 --- /dev/null +++ b/bin/markdown_py @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from markdown.__main__ import run +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(run()) @@ -0,0 +1,10 @@ +#!/bin/env bash + +# sends used memory to stdout +mem() { + mem="$(free | grep Mem | awk ' { print $3/$2 * 100 } ')" + + printf "%s %.0f%%" "" "$mem" +} + +mem diff --git a/bin/mic_check b/bin/mic_check new file mode 100755 index 0000000..19ce263 --- /dev/null +++ b/bin/mic_check @@ -0,0 +1,12 @@ +#!/bin/env bash + +# mutes the microphone and send a notification + +# microphone mute state +mute="$(pulsemixer --list-sources | grep -i default | awk '{print $10}' | sed -e 's/,//g')" + +[ "$mute" -eq 0 ] && notify-send "Microfone" "Mudo" + +[ "$mute" -eq 1 ] && notify-send "Microfone" "Reativado" + +pactl set-source-mute @DEFAULT_SOURCE@ toggle diff --git a/lemonbar/scripts/mpd_scroll b/bin/mpd_scroll index bbb6872..bbb6872 100755 --- a/lemonbar/scripts/mpd_scroll +++ b/bin/mpd_scroll diff --git a/bin/pip3.8 b/bin/pip3.8 new file mode 100755 index 0000000..b0625ed --- /dev/null +++ b/bin/pip3.8 @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from pip._internal.cli.main import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/pkgs b/bin/pkgs new file mode 100755 index 0000000..bb7e807 --- /dev/null +++ b/bin/pkgs @@ -0,0 +1,10 @@ +#!/bin/env bash + +# prints the number of current installed packages (pacman-based) +pkgs() { + pkgs="$(pacman -Q | wc -l)" + + printf "%s %d" "" "$pkgs" +} + +pkgs diff --git a/bin/print_tags b/bin/print_tags new file mode 100755 index 0000000..a5cd811 --- /dev/null +++ b/bin/print_tags @@ -0,0 +1,29 @@ +#!/bin/env bash + +# prints hlwm's tag names +print_tags() { + for tag in $(herbstclient tag_status); do + name=${tag#?} + state=${tag%$name} + + case "$state" in + '#') + printf '%%{B#656565}%%{F#ffffff}%%{U#e60053} %s %%{U-}%%{F-}%%{B-}' "$name" + ;; + '+') + printf '%%{U#101112}%%{F#ffffff}%%{R} %s %%{R-}%%{U-}%%{F-}' "$name" + ;; + '!') + printf '%%{R} %s! %%{R-}' "$name" + ;; + '.') + printf '%%{U#101112}%%{F#8b8b8b} %s %%{F-}%%{U-}' "$name" + ;; + *) + printf '%%{U#101112} %s %%{U-}' "$name" + esac + done + printf '\n' +} + +print_tags diff --git a/bin/temp b/bin/temp new file mode 100755 index 0000000..1270297 --- /dev/null +++ b/bin/temp @@ -0,0 +1,10 @@ +#!/bin/env bash + +# prints temperature +temp() { + temp="$(sensors | grep -i package | awk '{print $4}' | sed -e 's/+//g')" + + printf "%s %dºC" "" "$temp" +} + +temp diff --git a/bin/title b/bin/title new file mode 100755 index 0000000..137272c --- /dev/null +++ b/bin/title @@ -0,0 +1,10 @@ +#!/bin/env bash + +# prints window title +title(){ + title="$(xdotool getwindowfocus getwindowname)" + + printf "%.10s" "$title" +} + +title diff --git a/bin/transcode b/bin/transcode new file mode 100755 index 0000000..094c36e --- /dev/null +++ b/bin/transcode @@ -0,0 +1,9 @@ +#!/bin/env bash + +# Este script faz a transcodagem de um vídeo de um codec para outro, feito para reduzir em até 80% o tamanho do arquivo original. + +ORIG="$1" +NOME=$(basename "$ORIG" .mp4) +NOVO="${2:-"$NOME-trans.mp4"}" + +ffmpeg -i "$ORIG" -vf mpdecimate -vsync vfr -c:v libx265 -x265-params crf=32 -preset veryslow "$NOVO" diff --git a/bin/urlImage b/bin/urlImage new file mode 100755 index 0000000..21ff6f5 --- /dev/null +++ b/bin/urlImage @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +# Pipe images from URLs into sxiv + +# get image extension +EXT="${1##*.}" + +# download it into a tmp file +wget "$1" -O /tmp/img.$EXT + +# open in sxiv +sxiv /tmp/img.$EXT diff --git a/bin/vimwiki_markdown b/bin/vimwiki_markdown new file mode 100755 index 0000000..9b22d1a --- /dev/null +++ b/bin/vimwiki_markdown @@ -0,0 +1,8 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +import re +import sys +from vimwiki_markdown import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) @@ -0,0 +1,16 @@ +#!/bin/env bash + +# prints volume from pulseaudio +vol() { + vol="$(pulsemixer --get-volume | awk ' { print $2 } ')" + mute="$(pulsemixer --get-mute)" + + icon="" + + # if muted + [ "$mute" -eq 1 ] || [ "$vol" -eq 0 ] && icon="" && vol=0 + + printf "%s %d%%" "$icon" "$vol" +} + +vol diff --git a/bin/wallpaper b/bin/wallpaper new file mode 100755 index 0000000..0ae3e93 --- /dev/null +++ b/bin/wallpaper @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# Baseado no script do Luke Smith + +DIR="$HOME/Imagens/Wallpapers" +WAL="~/Imagens/Wallpapers/wall.png" + +# se o diretório existir, pegue um arquivo aleatoriamente +[[ -d "$DIR" ]] && IMG=$(find "$DIR"/* | shuf -n 1) + +# se a imagem for diferente do wallpaper atual, copie-a +[[ "$IMG" != "$WAL" ]] && cp $IMG ~/Imagens/Wallpapers/wall.png + +xwallpaper --stretch "$DIR"/wall.png && notify-send -i '"$DIR"/wall.png' 'Wallpaper alterado' diff --git a/bin/wheel b/bin/wheel new file mode 100755 index 0000000..90af11d --- /dev/null +++ b/bin/wheel @@ -0,0 +1,8 @@ +#!/sbin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from wheel.cli import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/bin/wlan b/bin/wlan new file mode 100755 index 0000000..fcd35e4 --- /dev/null +++ b/bin/wlan @@ -0,0 +1,10 @@ +#!/bin/env bash + +# prints connected SSID name +wlan() { + wlan="$(iwgetid | awk ' {print $2, $3, $4, $5, $6} ' | sed -e 's/ESSID://g' -e 's/"//g')" + + printf "%s %s" "" "$wlan" +} + +wlan diff --git a/bin/wmMove b/bin/wmMove new file mode 100755 index 0000000..6ee32a5 --- /dev/null +++ b/bin/wmMove @@ -0,0 +1,32 @@ +#!/bin/env sh + +# copied from: +# https://www.reddit.com/r/herbstluftwm/comments/j4oq4k/does_anyone_know_how_i_could_allign_a_frame_to/gaejwks/?utm_source=reddit&utm_medium=web2x&context=3 + +# get current window id, width and height +WID="$(pfw)" +WW="$(wattr w "$WID")" +WH="$(wattr h "$WID")" + +# get screen width and height +ROOT="$(lsw -r)" +SW="$(wattr w "$ROOT")" +SH="$(wattr h "$ROOT")" + +case $1 in + center) + xdotool getactivewindow windowmove "$(((SW - WW)/2))" "$(((SH - WH)/2))" + ;; + all-top) + xdotool getactivewindow windowmove x 0 + ;; + half-top) + xdotool getactivewindow windowmove x "$((SH - WH))" + ;; + all-left) + xdotool getactivewindow windowmove 0 y + ;; + half-left) + xdotool getactivewindow windowmove "$((SW - WW))" y + ;; +esac diff --git a/bin/xev_keys b/bin/xev_keys new file mode 100755 index 0000000..d370c49 --- /dev/null +++ b/bin/xev_keys @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }' diff --git a/bin/youtube-dl b/bin/youtube-dl new file mode 100755 index 0000000..569d3d0 --- /dev/null +++ b/bin/youtube-dl @@ -0,0 +1,8 @@ +#!/sbin/python3 +# -*- coding: utf-8 -*- +import re +import sys +from youtube_dl import main +if __name__ == '__main__': + sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0]) + sys.exit(main()) diff --git a/herbstluftwm/autostart b/herbstluftwm/autostart index c36e43b..3ca1970 100755 --- a/herbstluftwm/autostart +++ b/herbstluftwm/autostart @@ -10,7 +10,7 @@ hc emit_hook reload # adiciona padding nas bordas do monitor # monitor cima|direita|baixo|esquerda -hc pad 0 40 4 40 4 +hc pad 0 40 4 10 4 # inicializa o sxhkd com a configuração do hlwm pgrep -x sxhkd > /dev/null || sxhkd -c "$HOME/.config/sxhkd/hlwmKeys" & @@ -19,7 +19,8 @@ pgrep -x sxhkd > /dev/null || sxhkd -c "$HOME/.config/sxhkd/hlwmKeys" & hc set default_frame_layout 1 # tags -tag_names=( {1..6} ) +#tag_names=( {1..6} ) +tag_names=( "" "" "" "切" "" ) hc rename default "${tag_names[0]}" || true for i in "${!tag_names[@]}" ; do hc add "${tag_names[$i]}" @@ -76,22 +77,20 @@ hc rule floatplacement=center hc rule class~'Alacritty' focus=on # open applications in specific tags -hc rule class=Brave-browser tag=6 -hc rule class=LibreWolf tag=6 -hc rule class=Luakit tag=6 -hc rule class=TelegramDesktop tag=5 floating=on -hc rule class=zoom tag=5 -hc rule class=Steam tag=4 -hc rule class=Lutris tag=4 -hc rule class=dishonored.exe tag=4 +hc rule class=firefoxdeveloperedition tag= +hc rule class=LibreWolf tag= +hc rule class=Chromium tag= +hc rule class=TelegramDesktop tag=切 floating=on +hc rule class=zoom tag=切 +hc rule class=Steam tag= floating=on +hc rule class=dishonored.exe tag= hc rule class=Sxiv floating=on hc rule class=mpv floating=on hc rule class=Zathura floating=on hc rule class=Iwgtk floating=on -hc rule class=lightcord tag=5 -hc rule class=Virt-manager tag=4 -hc rule class=Pcmanfm tag=2 -hc rule class=obs tag=4 +hc rule class=lightcord tag=切 +hc rule class=Virt-manager tag= +hc rule class=obs tag= hc rule class=Galculator floating=on hc rule windowtype~'_NET_WM_WINDOW_TYPE_(DIALOG|UTILITY|SPLASH)' floating=on diff --git a/lemonbar/feeder b/lemonbar/feeder index 14060d9..7673854 100755 --- a/lemonbar/feeder +++ b/lemonbar/feeder @@ -9,4 +9,4 @@ while true; do printf "%s" "$info" sleep 1 -done +done & diff --git a/lemonbar/info b/lemonbar/info index b46973f..4ebdfe1 100755 --- a/lemonbar/info +++ b/lemonbar/info @@ -11,7 +11,7 @@ # prints the battery status to the stdout batt() { - batt=$(acpi | awk '{print $4}' | sed -e 's/%,//g') + batt="$(acpi | awk '{print $4}' | sed -e 's/,//g')" icon="" [ "$batt" -ge 98 ] && icon="" @@ -22,13 +22,13 @@ batt() { [ "$batt" -le 5 ] && icon="" - printf "%s %d" "$icon" "$batt" + printf "%s %d%%" "$icon" "$batt" } # prints the current time clock() { - time=$(date '+%H:%M') + time="$(date '+%H:%M')" printf "%s %s" "" "$time" } @@ -36,8 +36,8 @@ clock() { # checks the amount of CPU being used cpu() { - cpu=$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' \ - <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat)) + cpu="$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1) "%"; }' \ + <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat))" printf " %.0f%%" "$cpu" } @@ -51,48 +51,48 @@ mem() { # prints the number of current installed packages (pacman-based) pkgs() { - pkgs=$(pacman -Q | wc -l) + pkgs="$(pacman -Q | wc -l)" printf "%s %d" "" "$pkgs" } # prints current song playing in mpd song(){ - song=$(mpc current) + song="$(mpc current)" printf "%%{B#101112}%%{U#6EF38B} %s %%{U-}%%{B-}" "$song" } # prints temperature temp() { - temp=$(sensors | awk '(NR==4) { print $3 }' | sed -e 's/+//g') + temp="$(sensors | grep -i package | awk '{print $4}' | sed -e 's/+//g')" printf "%s %dºC" "" "$temp" } # prints window title title(){ - title=$(xdotool getwindowfocus getwindowname) + title="$(xdotool getwindowfocus getwindowname)" printf "%.10s" "$title" } # prints volume from pulseaudio vol() { - vol=$(pulsemixer --get-volume | awk ' { print $2 } ') - mute=$(pulsemixer --get-mute) + vol="$(pulsemixer --get-volume | awk ' { print $2 } ')" + mute="$(pulsemixer --get-mute)" icon="" # if muted - [ $mute -eq 1 ] || [ $vol -eq 0 ] && icon="" && vol="mute" - + [ "$mute" -eq 1 ] || [ "$vol" -eq 0 ] && icon="" && vol=0 + printf "%s %d%%" "$icon" "$vol" } # prints connected SSID name wlan() { - wlan=$(iwgetid | awk ' {print $2, $3, $4, $5, $6} ' | sed -e 's/ESSID://g' -e 's/"//g') + wlan="$(iwgetid | awk ' {print $2, $3, $4, $5, $6} ' | sed -e 's/ESSID://g' -e 's/"//g' -e 's/ //g')" printf "%s %s" "" "$wlan" } @@ -108,10 +108,10 @@ print_tags() { printf '%%{B#656565}%%{F#ffffff}%%{U#e60053} %s %%{U-}%%{F-}%%{B-}' "$name" ;; '+') - printf '%%{U#101112}%%{F#ffffff}%%{R} %s %%{U-}%%{R-}%%{F-}' "$name" + printf '%%{U#101112}%%{F#ffffff}%%{R} %s %%{R-}%%{U-}%%{F-}' "$name" ;; '!') - printf '%%{U#101112}%%{R} %s! %%{R-}%%{U-}' "$name" + printf '%%{R} %s! %%{R-}' "$name" ;; '.') printf '%%{U#101112}%%{F#8b8b8b} %s %%{F-}%%{U-}' "$name" @@ -127,7 +127,7 @@ print_tags() { # underline formatting clock="%{U${red}}$(clock)%{U-}" -batt="%{U${red}}$(batt)%{U-}" +batt="%{U${red}}$(batt)%%{U-}" cpu="%{U${yellow}}$(cpu)%%{U-}" mem="%{U${blue}}$(mem)%%{U-}" pkgs="%{U${blue}}$(pkgs)%{U-}" @@ -141,6 +141,6 @@ wlan="%{U${yellow}}$(wlan)%{U-}" sep="%{U${black}} " # --- Return --- # -echo -e "%{l}${sep}${batt}${sep}${mem}${sep}${cpu}${sep}${temp}\ +echo -e "%{+u}%{l}${sep}${batt}${sep}${mem}${sep}${cpu}${sep}${temp}\ %{c}${workspaces}\ - %{r}${vol}${sep}${wlan}${sep}${pkgs}${sep}${clock}${sep}" + %{r}${vol}${sep}${wlan}${sep}${pkgs}${sep}${clock}${sep}%{-u}" diff --git a/lemonbar/scripts/batt b/lemonbar/scripts/batt index bfccccd..c99c3a3 100755 --- a/lemonbar/scripts/batt +++ b/lemonbar/scripts/batt @@ -1,11 +1,18 @@ #!/bin/env bash -# prints the battery status to the stdout - batt() { - batt=$(acpi | awk '{print $4}' | sed -e 's/%,//g') + batt="$(acpi | awk '{print $4}' | sed -e 's/%,//g')" + icon="" + + [ "$batt" -ge 90 ] && icon="" + + [ "$batt" -le 50 ] && icon="" - echo " $batt" + [ "$batt" -le 20 ] && icon="" + + [ "$batt" -le 5 ] && icon="" + + printf "%s %d%%" "$icon" "$batt" } batt diff --git a/lemonbar/scripts/clock b/lemonbar/scripts/clock deleted file mode 100755 index 1dafb50..0000000 --- a/lemonbar/scripts/clock +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/env bash - -# prints the current time - -clock() { - time=$(date '+%H:%M') - - echo " $time" -} - -clock diff --git a/lemonbar/scripts/cpu b/lemonbar/scripts/cpu index c48dfc6..33c797e 100755 --- a/lemonbar/scripts/cpu +++ b/lemonbar/scripts/cpu @@ -1,11 +1,11 @@ #!/bin/env bash - # checks the amount of CPU being used cpu() { - cpu=$() + cpu="$(awk '{u=$2+$4; t=$2+$4+$5; if (NR==1){u1=u; t1=t;} else print ($2+$4-u1) * 100 / (t-t1); }' \ + <(grep 'cpu ' /proc/stat) <(sleep 1;grep 'cpu ' /proc/stat))" - echo " $cpu" + printf " %.0f%%" "$cpu" } cpu diff --git a/lemonbar/scripts/icons b/lemonbar/scripts/icons deleted file mode 100755 index 8bbf978..0000000 --- a/lemonbar/scripts/icons +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/env bash - -icons=" " -tag_num=$(herbstclient tag_status | awk '{print $NF}' | sed -e 's/') - -for i in {1..} diff --git a/lemonbar/scripts/mem b/lemonbar/scripts/mem index fb6688f..dab317d 100755 --- a/lemonbar/scripts/mem +++ b/lemonbar/scripts/mem @@ -1,14 +1,10 @@ #!/bin/env bash -# sends available memory to stdout - +# sends used memory to stdout mem() { - free=$(free -h | awk ' (NR==2) { print $3 }' | sed -e 's/Gi//g') - total=$(free -h | awk ' (NR==2) { print $2 }' | sed -e 's/Gi//g') - - percentage=$free + mem="$(free | grep Mem | awk ' { print $3/$2 * 100 } ')" - echo " $percentage" + printf "%s %.0f%%" "" "$mem" } mem diff --git a/lemonbar/scripts/pkgs b/lemonbar/scripts/pkgs index 1c8ed37..bb7e807 100755 --- a/lemonbar/scripts/pkgs +++ b/lemonbar/scripts/pkgs @@ -1,11 +1,10 @@ #!/bin/env bash # prints the number of current installed packages (pacman-based) - pkgs() { - pkgs=$(pacman -Q | wc -l) + pkgs="$(pacman -Q | wc -l)" - echo " $pkgs" + printf "%s %d" "" "$pkgs" } pkgs diff --git a/lemonbar/scripts/print_tags b/lemonbar/scripts/print_tags new file mode 100755 index 0000000..a5cd811 --- /dev/null +++ b/lemonbar/scripts/print_tags @@ -0,0 +1,29 @@ +#!/bin/env bash + +# prints hlwm's tag names +print_tags() { + for tag in $(herbstclient tag_status); do + name=${tag#?} + state=${tag%$name} + + case "$state" in + '#') + printf '%%{B#656565}%%{F#ffffff}%%{U#e60053} %s %%{U-}%%{F-}%%{B-}' "$name" + ;; + '+') + printf '%%{U#101112}%%{F#ffffff}%%{R} %s %%{R-}%%{U-}%%{F-}' "$name" + ;; + '!') + printf '%%{R} %s! %%{R-}' "$name" + ;; + '.') + printf '%%{U#101112}%%{F#8b8b8b} %s %%{F-}%%{U-}' "$name" + ;; + *) + printf '%%{U#101112} %s %%{U-}' "$name" + esac + done + printf '\n' +} + +print_tags diff --git a/lemonbar/scripts/song b/lemonbar/scripts/song new file mode 100755 index 0000000..e86b1a9 --- /dev/null +++ b/lemonbar/scripts/song @@ -0,0 +1,8 @@ +#!/bin/env bash + +# prints current song playing in mpd +song(){ + song="$(mpc current)" + + printf "%%{B#101112}%%{U#6EF38B} %s %%{U-}%%{B-}" "$song" +} diff --git a/lemonbar/scripts/temp b/lemonbar/scripts/temp index fb6a8e0..1270297 100755 --- a/lemonbar/scripts/temp +++ b/lemonbar/scripts/temp @@ -1,11 +1,10 @@ #!/bin/env bash -# prints CPU temperature - +# prints temperature temp() { - temp=$(sensors | awk '(NR==4) { print $3 }' | sed -e 's/+//g') + temp="$(sensors | grep -i package | awk '{print $4}' | sed -e 's/+//g')" - echo " $temp" + printf "%s %dºC" "" "$temp" } temp diff --git a/lemonbar/scripts/title b/lemonbar/scripts/title index af0d74f..137272c 100755 --- a/lemonbar/scripts/title +++ b/lemonbar/scripts/title @@ -1,3 +1,10 @@ #!/bin/env bash # prints window title +title(){ + title="$(xdotool getwindowfocus getwindowname)" + + printf "%.10s" "$title" +} + +title diff --git a/lemonbar/scripts/vol b/lemonbar/scripts/vol new file mode 100755 index 0000000..9bfbd2a --- /dev/null +++ b/lemonbar/scripts/vol @@ -0,0 +1,16 @@ +#!/bin/env bash + +# prints volume from pulseaudio +vol() { + vol="$(pulsemixer --get-volume | awk ' { print $2 } ')" + mute="$(pulsemixer --get-mute)" + + icon="" + + # if muted + [ "$mute" -eq 1 ] || [ "$vol" -eq 0 ] && icon="" && vol=0 + + printf "%s %d%%" "$icon" "$vol" +} + +vol diff --git a/lemonbar/scripts/volume b/lemonbar/scripts/volume deleted file mode 100755 index e59ca1c..0000000 --- a/lemonbar/scripts/volume +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/env bash - -# prints current volume - -vol() { - vol=$(pulsemixer --get-volume | awk ' { print $2 } ') - mute=$(pulsemixer --get-mute) - - icon="" - - # if muted - [ $mute -eq 1 ] || [ $vol -eq 0 ] && icon="" && vol="mute" - - echo "$icon $vol%" -} - -vol diff --git a/lemonbar/scripts/wlan b/lemonbar/scripts/wlan index 0dfc494..fcd35e4 100755 --- a/lemonbar/scripts/wlan +++ b/lemonbar/scripts/wlan @@ -1,11 +1,10 @@ #!/bin/env bash -# prints connected wi-fi SSID - +# prints connected SSID name wlan() { - wlan=$(iwgetid | awk ' {print $2, $3, $4, $5, $6} ' | sed -e 's/ESSID://g' -e 's/"//g') + wlan="$(iwgetid | awk ' {print $2, $3, $4, $5, $6} ' | sed -e 's/ESSID://g' -e 's/"//g')" - echo " $wlan" + printf "%s %s" "" "$wlan" } wlan diff --git a/lemonbar/scripts/workspaces b/lemonbar/scripts/workspaces deleted file mode 100755 index 2d28613..0000000 --- a/lemonbar/scripts/workspaces +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/env bash - -# prints window manager's tags/desktops - -# shamelessly copied from: -# https://gist.github.com/olmokramer/b28ff8ed5fd366e3ebb23b79915ec850 -# there are some alterations, though - -print_tags() { - for tag in $(herbstclient tag_status); do - name=${tag#?} - state=${tag%$name} - - case "$state" in - '#') - printf '%%{B#3f3f3f}%%{F#ffffff} %s %%{F}%%{B}' "$name" - ;; - '+') - printf '%%{F#ffffff}%%{R} %s %%{R}%%{F}' "$name" - ;; - '!') - printf '%%{R} %s! %%{R}' "$name" - ;; - '.') - printf '%%{F#8b8b8b} %s %%{F}' "$name" - ;; - *) - printf ' %s ' "$name" - esac - done - printf '\n' -} - -print_tags diff --git a/sxhkd/dwmKeys b/sxhkd/dwmKeys new file mode 100755 index 0000000..68e2a61 --- /dev/null +++ b/sxhkd/dwmKeys @@ -0,0 +1,114 @@ +#!/bin/env bash + +# Simple X Hotkey Daemon config for use with dwm +# All hotkeys related to dwm are defined in its own config file. +# You can check my fork of dwm at https://github.com/Pinoinha/dwm-meu + +# reload sxhkd +super + r + pkill -USR1 -x sxhkd ; notify-send 'sxhkd' 'Reloaded config' + +# spawn vim +super + v + $TERMINAL -e 'nvim' + +# run terminal applications +super + e ; {1, 2, 3, 4, 5, 6} + $TERMINAL -e {\ + lf, \ + ncmpcpp, \ + ncspot, \ + newsboat, \ + htop, \ + pulsemixer} + +# run graphical applications +super + g ; {1, 2} + {firefox-developer-edition, librewolf} + +# lock the screen +alt + shift + l + slock + +# dmenu based applications +super + d ; {1, 2} + {dmenu_run -l 6, passmenu2} + +# center a floating window +super + c + wmMove center + +# -- Screenshots -- # + +# print selection with scrot +@Print + scrot -s -f '%Y-%m-%d_$wx$h.png' -e 'mv $f /home/math/Imagens/Prints' + +# print current window with scrot +shift + @Print + scrot -u '%Y-%m-%d_$wx$h.png' -e 'mv $f /home/math/Imagens/Prints' + +# print entire screen with scrot +alt + @Print + scrot "%Y-%m-%d_$wx$h.png" -e 'mv $f /home/math/Imagens/Prints' + +# -- Audio Control -- # + +XF86AudioMute + pulsemixer --toggle-mute; pkill -RTMIN+10 dwmblocks + +shift + F1 + pulsemixer --toggle-mute; pkill -RTMIN+10 dwmblocks + +XF86AudioLowerVolume + pulsemixer --change-volume -5; pkill -RTMIN+10 dwmblocks + +shift + F2 + pulsemixer --change-volume -5; pkill -RTMIN+10 dwmblocks + +XF86AudioRaiseVolume + pulsemixer --change-volume +5; pkill -RTMIN+10 dwmblocks + +shift + F3 + pulsemixer --change-volume +5; pkill -RTMIN+10 dwmblocks + +XF86AudioMicMute + mic_check + +shift + F4 + mic_check + +shift + F5 + mpc stop + +XF86AudioPrev + mpc prev + +shift + F6 + mpc prev + +XF86AudioPlay + mpc toggle + +shift + F7 + mpc toggle + +XF86AudioNext + mpc next + +shift + F8 + mpc next + +# -- Brightness Control -- # + +XF86MonBrightnessDown + xbacklight -dec 10 + +shift + F11 + xbacklight -dec 10 + +XF86MonBrightnessUp + xbacklight -inc 10 + +shift + F12 + xbacklight -inc 10 diff --git a/sxhkd/hlwmKeys b/sxhkd/hlwmKeys index cd6c40a..1dcb9aa 100755 --- a/sxhkd/hlwmKeys +++ b/sxhkd/hlwmKeys @@ -12,6 +12,10 @@ super + r super + Return frame_spawn $TERMINAL +# spawn floating state +super + shift + Return + herbstclient chain , rule once index=e focus=on floating=on , spawn $TERMINAL + # spawn vim super + v $TERMINAL -e 'nvim' @@ -21,8 +25,8 @@ super + e ; {1, 2, 3, 4, 5, 6} $TERMINAL -e {lf, ncmpcpp, ncspot, newsboat, htop, pulsemixer} # run graphical applications -super + g ; {1, 2, 3} - {brave, librewolf, galculator} +super + g ; {1, 2} + {firefox-developer-edition, librewolf} # lock the screen alt + shift + l @@ -40,7 +44,7 @@ super + d ; {1, 2} # print current window with scrot shift + @Print - scrot -u "%Y-%m-%d_$wx$h.png" -e 'mv $f /home/math/Imagens/Prints' + scrot -u '%Y-%m-%d_$wx$h.png' -e 'mv $f /home/math/Imagens/Prints' # print entire screen with scrot alt + @Print @@ -67,10 +71,10 @@ shift + F3 pulsemixer --change-volume +5 XF86AudioMicMute - pactl set-source-mute @DEFAULT_SOURCE@ toggle + mic_check shift + F4 - pactl set-source-mute @DEFAULT_SOURCE@ toggle + mic_check shift + F5 mpc stop @@ -176,12 +180,12 @@ super + Tab herbstclient use_previous # switch to tag -super + {1-6} - herbstclient use {1-6} +super + {1-5} + herbstclient use {"", "", "", "切", ""} # send window to tag -super + shift + {1-6} - herbstclient move {1-6} +super + shift + {1-5} + herbstclient move {"", "", "", "切", ""} # send window to previous/next tag \ # and switch to tag @@ -195,8 +199,7 @@ super + {_, shift} + s herbstclient split {bottom, right} 0.5 # split-explode focused frame -# note: equivalent to creating \ -# two nodes in a tree +# note: equivalent to creating two nodes in a tree super + ctrl + s herbstclient split explode |
