General TC > Programming & Scripting - Unofficial
Freqmon - a minimalistic approach to monitor CPU frequency
tinypoodle:
--- Quote from: Rich on March 24, 2013, 03:08:42 PM ---I tried stripping the newline like this:
--- Code: ---watch -t grep M /proc/cpuinfo | tr -d '\n'
--- End code ---
and got no output.
--- End quote ---
OMG yes! :o
That does the job!
Well... approximately, it sort of cripples the last of the 4 digits, which doesn't occur if size is 5x1.
I had tried '\n' in many ways, e.g. with sed and awk, but never invoked tr.
EDIT:
I think I figured what is happening with last digit, there is still a cursor, even if pseudo-invisible (same color as bg).
Rich:
Hi tinypoodle
--- Code: ---it sort of cripples the last of the 4 digits, which doesn't occur if size is 5x1.
--- End code ---
Sorry, didn't notice that on my 863Mhz machine. This fixes it:
--- Code: ---aterm -fade 100 -title Freqmon -fg green -bg black -ib 0 -bl +sb -geometry 4x1+30+30 -e sh -c "echo -ne '\033[?25l'; while true; do echo -ne '\033[1K\033[1G'; echo -ne `grep MHz /proc/cpuinfo | cut -d: -f2 | cut -d. -f1`; sleep 2; done" &
--- End code ---
Added:
--- Code: ---echo -ne '\033[?25l';
--- End code ---
to hide the cursor and removed
--- Code: ----cr black
--- End code ---
which was the black cursor obscuring the last digit.
tinypoodle:
--- Quote from: Rich on March 24, 2013, 04:24:50 PM ---
--- Code: ---aterm -fade 100 -title Freqmon -fg green -bg black -ib 0 -bl +sb -geometry 4x1+30+30 -e sh -c "echo -ne '\033[?25l'; while true; do echo -ne '\033[1K\033[1G'; echo -ne `grep MHz /proc/cpuinfo | cut -d: -f2 | cut -d. -f1`; sleep 2; done" &
--- End code ---
--- End quote ---
This does not work for me at all, i.e. output will remain same as at the moment it is invoked.
--- Quote ---Added:
--- Code: ---echo -ne '\033[?25l';
--- End code ---
to hide the cursor
--- End quote ---
Wondering if and how this could be combined with 'watch', as I really have a preference for using watch for many purposes.
Either way, increasing geometry by 1 horizontally is not a biggie, I am most happy with the method of using 'tr' to remove newline which you provided :D
Rich:
Hi tinypoodle
--- Quote --- ... output will remain same as at the moment it is invoked.
--- End quote ---
You mean the numbers never change? Even if you make the machine do some work?
--- Quote ---Wondering if and how this could be combined with 'watch', ...
--- End quote ---
Even though it only needs to be executed once, adding it like this works:
--- Code: --- ... -e watch -t "echo -ne '\033[?25l'; grep M ...
--- End code ---
--- Quote ---I am most happy with the method of using 'tr' to remove newline which you provided
--- End quote ---
Could you show me how you got tr to work? When I tried, I got no output, like it wasn't even running:
--- Code: ---tc@box:~$ watch -t grep M /proc/cpuinfo | tr -d '\n'
^C
tc@box:~$ watch -t grep M /proc/cpuinfo | tr -d '\n'
^C
tc@box:~$
--- End code ---
tinypoodle:
--- Quote from: Rich on March 25, 2013, 11:54:37 AM ---You mean the numbers never change? Even if you make the machine do some work?
--- End quote ---
Exactly
--- Quote ---Even though it only needs to be executed once, adding it like this works:
--- Code: --- ... -e watch -t "echo -ne '\033[?25l'; grep M ...
--- End code ---
--- End quote ---
Ah, thanks, I didn't know how exactly to integrate it.
So, adding that results in:
- Without tr, 5x1 : does not work
- Without tr, 4x2 : works as desired
- With tr, 4x1 : works as desired, with a side effect of output blinking.
--- Quote ---Could you show me how you got tr to work? When I tried, I got no output, like it wasn't even running:
--- Code: ---tc@box:~$ watch -t grep M /proc/cpuinfo | tr -d '\n'
^C
tc@box:~$ watch -t grep M /proc/cpuinfo | tr -d '\n'
^C
tc@box:~$
--- End code ---
--- End quote ---
This command works for me, showing cursor positioned imminently after output.
Attached my version including tr, see at end of line. (working as desired with 4x1, side effect of last digit getting crippled by pseudo-invisible cursor).
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version