Signed-off-by: Marcin Wozniak <y0rune@aol.com>
This commit is contained in:
Marcin Woźniak 2020-05-09 14:47:58 +02:00 committed by Marcin Wozniak
parent 0cb164ea95
commit 72a5897919
3 changed files with 17 additions and 174 deletions

View File

@ -25,7 +25,7 @@ static const char *tags[] = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
static const Rule rules[] = {
{ "Gimp", NULL, NULL, 0, True, -1 },
{ "pulsemixer", NULL, NULL, 0, True, -1 },
{ "qutebrowser", NULL, NULL, 1 << 1, False, 0 },
{ "Google-chrome", NULL, NULL, 1 << 1, False, 0 },
{ "Firefox", NULL, NULL, 1 << 1, False, 0 },
{ "Thunderbird", NULL, NULL, 1 << 2, False, 0 },
{ "Steam", NULL, NULL, 1 << 3, False, 0 },

27
dwm.c
View File

@ -472,10 +472,16 @@ buttonpress(XEvent *e)
}
if (ev->window == selmon->barwin) {
i = x = 0;
do
x += TEXTW(tags[i]);
while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
unsigned int occ = 0;
for(c = m->clients; c; c = c->next)
occ |= c->tags;
do {
/* do not reserve space for vacant tags */
if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
x += TEXTW(tags[i]);
} while (ev->x >= x && ++i < LENGTH(tags));
if (i < LENGTH(tags)) {
click = ClkTagBar;
arg.ui = 1 << i;
} else if (ev->x < x + blw)
@ -808,19 +814,18 @@ drawbar(Monitor *m)
resizebarwin(m);
for (c = m->clients; c; c = c->next) {
occ |= c->tags;
if (c->isurgent)
occ |= c->tags == 255 ? 0 : c->tags;
if (c->isurgent)
urg |= c->tags;
}
x = 0;
for (i = 0; i < LENGTH(tags); i++) {
w = TEXTW(tags[i]);
/* do not draw vacant tags */
if(!(occ & 1 << i || m->tagset[m->seltags] & 1 << i))
continue;
w = TEXTW(tags[i]);
drw_setscheme(drw, scheme[m->tagset[m->seltags] & 1 << i ? SchemeSel : SchemeNorm]);
drw_text(drw, x, 0, w, bh, lrpad / 2, tags[i], urg & 1 << i);
if (occ & 1 << i)
drw_rect(drw, x + boxs, boxs, boxw, boxw,
m == selmon && selmon->sel && selmon->sel->tags & 1 << i,
urg & 1 << i);
x += w;
}
w = blw = TEXTW(m->ltsymbol);

View File

@ -1,162 +0,0 @@
#!/bin/bash
xset s off -dpms&
xset b off&
xset s off&
xset -dpms&
compton&
feh --bg-fill $HOME/.wall.jpg &
#redshift -l 52.2327:18.3036 -t 6500:3200&
nm-applet --sm-disable&
#/usr/local/bin/st -e /bin/sh -c "tmux new-session -s BASE -n HOME '/bin/zsh'\; split-window -h \; split-window 'htop'\; new-window -n IRC 'irssi'\; new-window -n MUSIC 'cmus'"&
/usr/local/bin/st -e /bin/sh -c "tmux new-session -s BASE -n HOME '/bin/zsh'\; split-window -h \; split-window 'htop'\; new-window -n MUSIC 'cmus'"&
firefox&
#export QT_SCALE_FACTOR=1; qutebrowser&
thunderbird&
sudo keepassxc&
#megasync&
dunst -config&
/usr/bin/ibus-daemon -d&
transmission-daemon&
#teamviewer&
#pl&
#(sleep 30 && getforecast)&
sudo /usr/bin/rdate -s -l ntp.task.gda.pl && sudo /sbin/hwclock --systohc
/opt/MEGAcmd/mega-cmd-server --debug-full > /var/log/megacmd/megacmd.log&
print_torrent(){
transmission-remote -l | grep % |
sed " # This first sed command is to ensure a desirable order with sort
s/.*Stopped.*/A/g;
s/.*Seeding.*/Z/g;
s/.*100%.*/N/g;
s/.*Idle.*/B/g;
s/.*Uploading.*/L/g;
s/.*%.*/M/g" |
sort -h | uniq -c | sed " # Now we replace the standin letters with icons.
s/A//g;
s/B//g;
s/L//g;
s/M//g;
s/N//g;
s/Z//g" | awk '{print $2, $1}' | sed -e "s/ $//g"
}
testweather() {
[ "$(stat -c %y "/home/yorune/.weatherreport" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] && curl -s "wttr.in/$location" > "/home/yorune/.weatherreport"
printf "%s " "$(sed '16q;d' "/home/yorune/.weatherreport" | grep -wo "[0-9]*%" | sort -n | sed -e '$!d' | sed -e "s/^/ /g" | tr -d '\n')" && sed '13q;d' "/home/yorune/.weatherreport" | grep -o "m\\(-\\)*[0-9]\\+" | sort -n -t 'm' -k 2n | sed -e 1b -e '$!d' | tr '\n|m' ' ' | awk '{print " ",$1 "°","",$2 "°"}'
}
print_volume() {
[ "$(pulsemixer --get-mute)" = "1" ] && printf "" && exit
vol=$(pulsemixer --get-volume | awk '{print $1}')
printf "%s%%\\n" " $vol"
}
print_wifi()
{
[ "$(cat /sys/class/net/w*/operstate)" = 'down' ] && wifiicon=""
[ ! -n "${wifiicon+var}" ] && wifiicon=$(grep "^\s*w" /proc/net/wireless | awk '{ print "", int($3 * 100 / 70) "%" }')
printf "%s %s" "$wifiicon" "$(cat /sys/class/net/e*/operstate | sed "s/down//;s/up//")"
}
print_temp(){
echo -e " $(sensors | awk '/Core 0/ {print $3}') +$(sudo nvidia-smi -q -d temperature | grep -i "GPU Current" |sed -r 's/GPU Current Temp ://'| sed -r 's/ C//' |sed -e 's/^[ \t]*//').0°C"
}
print_date(){
echo -e " $(date +"%d/%m %H:%M")"
}
print_mail(){
RESULT=$(echo "$(du -a ~/.mailbox/*/inbox/new/* 2>/dev/null | sed -n '$=')$(cat /tmp/imapsyncicon_$USER 2>/dev/null)")
if [ -z $RESULT ]; then
echo "0"
else
echo "$(du -a ~/.mailbox/*/inbox/new/* 2>/dev/null | sed -n '$=')$(cat /tmp/imapsyncicon_$USER 2>/dev/null)"
fi
}
batLevel() {
# Find the battery level
hash acpi || return 0
onl="$(acpi -V | grep "on-line")"
charge="$(cat /sys/class/power_supply/BAT*/capacity)"
time="$(awk '{print $5}' <(acpi))"
# Determine battery glyph by percentage range
if [[ -z $onl && ${charge} -gt 80 ]]; then
echo -e " ${charge}% ${time}"
elif [[ -z $onl && ${charge} -le 80 && ${charge} -gt 60 ]]; then
echo -e " ${charge}% ${time}"
elif [[ -z $onl && ${charge} -le 60 && ${charge} -gt 40 ]]; then
echo -e " ${charge}% ${time}"
elif [[ -z $onl && ${charge} -le 40 && ${charge} -gt 20 ]]; then
echo -e " ${charge}% ${time}"
elif [[ -z $onl && ${charge} -le 20 ]]; then
echo -e " ${charge}% ${time}"
# If charging, use animated glyph
else
echo -e ""
fi
}
usageData() {
read cpu a b c pi rest < /proc/stat
pt=$((a+b+c+pi))
sleep 0.1
read cpu a b c i rest < /proc/stat
t=$((a+b+c+i))
cpuUse=$((100*( (t-pt) - (i-pi) ) / (t-pt) ))
ramUseA=$(free -m -h | grep Mem | awk '{print $3"/"$2}')
ramPer=$(free -m | grep Mem | awk '{print 100*($3/$2)}')
ramUseB="${ramPer%.*}"
echo -e " $cpuUse%  $ramUseB%"
}
playerCmus(){
cmus=$(cmus-remote -Q | grep status)
case "$cmus" in
"status stop"*)
echo ""
;;
"status paused"*)
echo ""
;;
'status playing'*)
INFO_CMUS=$(cmus-remote -Q 2>/dev/null)
if [[ $? -eq 0 ]]; then
INFO_TITLE=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*title//p' | head -n 1)
INFO_ALBUM=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*album//p' | head -n 1)
INFO_ARTIST=$(echo "${INFO_CMUS}" | sed -n -e 's/^.*artist//p' | head -n 1)
else
exit
fi
if [[ "${INFO_ARTIST}" ]] && [[ "${INFO_TITLE}" ]]; then
OUT_TEXT="${INFO_ARTIST} -${INFO_TITLE}"
elif [[ "${INFO_TITLE}" ]]; then
OUT_TEXT="${INFO_TITLE}"
fi
echo -e ""
#echo -e "${OUT_TEXT}"
;;
"")
echo ""
;;
esac
}
while true
do
xsetroot -name "$(print_temp) | $(print_wifi) | $(batLevel) | $(print_volume) | $(print_date)"
#xsetroot -name "$(print_temp) | $(usageData) | $(print_wifi) | $(testweather) | $(batLevel) | $(print_volume) | $(print_date)"
#xsetroot -name "$(print_wifi) | $(batLevel) | $(print_volume) | $(print_date)"
sleep 2
done