dracula / tmux

🧛🏻‍♂️ Dark theme for tmux
https://draculatheme.com/tmux
MIT License
633 stars 286 forks source link

Bug: Enabling Weather plugin causes my MBP fans to increase globle warming #94

Open devnolly opened 3 years ago

devnolly commented 3 years ago

Describe the bug

Hi Devs - When using the weather plugin the fans on my '19 MBP (using Catalina/zsh/oh-my-zsh) spin up and don't stop until I shut down tmux. A couple of things seem to have helped.

Setting the refresh to something more that 5 seems to help: set -g @dracula-refresh-rate 30

It looks like this statement in sleep_weather.sh produces an error because grep doesn't find anything. I can see that extra processes aren't getting killed: [ -f $LOCKFILE ] && ps -p "$(cat $LOCKFILE)" -o cmd= | grep -F " ${BASH_SOURCE[0]}" && kill "$(cat $LOCKFILE)"

Removing the leading space in " ${BASH_SOURCE[0]}" seems to produce the desired result on my system.

To Reproduce

Starting tmux with Dracula enable and using the weather/location plugin.

Expected behavior

I run tmux and my machine is quiet as a mouse.

System

ethancedwards8 commented 3 years ago

I'll need to test this, but it makes sense. Feel free to send in a PR.

xunoaib commented 3 years ago

@devnolly I couldn't replicate this on my system but you are probably right. Could you please share the output of ps -p "$(cat /tmp/.dracula-tmux-weather.lock)" -o cmd= on your system (in bash)? I'm curious if the output differs between OS's or ps versions. ps from procps-ng 3.3.17 on mine shows: bash /home/user/.tmux/plugins/tmux/scripts/sleep_weather.sh true true

Thanks

ethancedwards8 commented 3 years ago

@devnolly I couldn't replicate this on my system but you are probably right. Could you please share the output of ps -p "$(cat /tmp/.dracula-tmux-weather.lock)" -o cmd= on your system (in bash)? I'm curious if the output differs between OS's or ps versions. ps from procps-ng 3.3.17 on mine shows: bash /home/user/.tmux/plugins/tmux/scripts/sleep_weather.sh true true

Thanks

I get the same output actually.

devnolly commented 3 years ago

Thanks for taking a look. Here's the output.

` bash-3.2$ ps -p "$(cat /tmp/.dracula-tmux-weather.lock)" -o cmd= ps: cmd: keyword not found ps: no valid keywords; valid keywords: %cpu %mem acflag acflg args blocked caught comm command cpu cputime etime f flags gid group ignored inblk inblock jobc ktrace ktracep lim login logname lstart majflt minflt msgrcv msgsnd ni nice nivcsw nsignals nsigs nswap nvcsw nwchan oublk oublock p_ru paddr pagein pcpu pending pgid pid pmem ppid pri pstime putime re rgid rgroup rss ruid ruser sess sig sigmask sl start stat state stime svgid svuid tdev time tpgid tsess tsiz tt tty ucomm uid upr user usrpri utime vsize vsz wchan wq wqb wql wqr xstat

bash-3.2$ ps -p "$(cat /tmp/.dracula-tmux-weather.lock)" PID TTY TIME CMD 36697 ?? 0:00.35 bash /Users/ENoll5/.tmux/plugins/tmux/scripts/sleep_weather.sh true true bash-3.2$ `

devnolly commented 3 years ago

Not sure if this helps.

` ➜ scripts (master) ✗ cat lock.sh

!/usr/bin/env bash

LOCKFILE=/tmp/.dracula-tmux-weather.lock

echo "With leading space" printf "[ -f $LOCKFILE ] && ps -p "$(cat $LOCKFILE)" -o cmd= | grep -F " ${BASH_SOURCE[0]}" && kill "$(cat $LOCKFILE)"" echo echo "Without leading space" printf "[ -f $LOCKFILE ] && ps -p "$(cat $LOCKFILE)" -o cmd= | grep -F "${BASH_SOURCE[0]}" && kill "$(cat $LOCKFILE)"" ➜ scripts (master) ✗ ./lock.sh With leading space [ -f /tmp/.dracula-tmux-weather.lock ] && ps -p 36697 -o cmd= | grep -F Without leading space [ -f /tmp/.dracula-tmux-weather.lock ] && ps -p 36697 -o cmd= | grep -F ./lock.sh && kill 36697%

`

ethancedwards8 commented 3 years ago

So is there potentially a problem on MacOS? Because of the way MacOS ps works? That's what I'm assuming.

xunoaib commented 3 years ago

It looks like ps on OSX doesn't support the "cmd" keyword. It's an alias for "args", so we should probably just use that. Could you please see if this works for your sleep_weather.sh?

[ -f $LOCKFILE ] && ps -p "$(cat $LOCKFILE)" -o args= | grep -F " ${BASH_SOURCE[0]}" && kill "$(cat $LOCKFILE)"

tmigone commented 2 years ago

This worked on my machine with macOS Monterrey 12.5.1:

[ -f $LOCKFILE ] && ps -p "$(< $LOCKFILE)" -o args= | grep -F " ${BASH_SOURCE[0]}" && kill "$(< $LOCKFILE)"
es-tii commented 1 year ago

Hello, I dont have the same exact issue, but I saw on my Linux laptop that the weather one had also my fans going crazy. I found out that it was linked to the rev command, and some sleep maybe.

I dont have that issue on my OSX work laptop though.