As of 2016-02-26, there will be no more posts for this blog. s/blog/pba/
Showing posts with label system. Show all posts

Few days ago, I posted about using dzen for system status. Within these days, I made more changes. Now it looks like

http://farm6.static.flickr.com/5204/5243206767_2706e0ea6c_b.jpg

It updates the content 5 times/s, so the volume changes when you adjust. In my old Conky, I set it to update every 6 seconds, its kind of weird after you press volume up button. Even before, 1 time/second, its still too long. When battery runs too low, the icon will blink. What can I say, I love my scripts.

Let me tell you whats in it, from left to right:

  • The first two parts are CPU utilization and Memory usage. If you click on icon, you will get a popup window like in this screenshot. It lists processes use most resource first. I was wanting to add kill button with -9 and -15 options, but ^ca() only supported in title area. I didnt want to adjust positions, that would require too much work and no scrolling in title area. Those red or pink color are reflecting the resource usage, if it consumed more, it gets redder.
  • Next one is root filesystem / usage. Nothing special this one, clicking on the icon brings up output of df.
  • Then the network transfer rate, fixed with interface ppp0.
  • The temperature.
  • Battery remaining capacity. This one has more colors than others. Icon color indicates different states. Green is the battery is charged, using AC source. Yellow is for discharging, if capacity goes too low, it will blink with red color. Blue means the battery is charging.
  • The music note is for MPD. It shows artist name and track name. If the text is too long, it scrolls for you to read all text! If you click on icon, it brings up a window like this.
  • Sound volume.
  • Date and time. Clicking on the clock brings up a 3-month calendar.
  • The last information box. I stuff update, load average, processes count, and weather in a window, you will see after you click on that icon.

You can get my configurations.

I think I have everything I need, but I wont stop tweaking it.

I wanted to know how I could monitor file system changes, especially activities on my home directory, and this was about this thread. I was thinking the issue could be solved by generating a snapshot of files using find, then watching changes and making changes to the snapshot file. Using grep to do the search.

But, thats simply stupid. Just using find would do that OP wants since that program OP uses only search for file names and folder names. For the first run of find it might be slower, 31000 more files took about six seconds. Well its not really slow. The consecutive runs only take about 0.1 seconds even after you add or delete files.

Anyway, its still fun to know how to monitor files. I installed inotify-tools package for inotifywait program.

http://farm6.static.flickr.com/5087/5205625460_60c806f25a.jpg

Here is the script I use:

inotifywait -m -r --format $'%T %e %w%f' --timefmt '%H:%M:%S' --exclude ~/'(\.mozilla|Documents/KeepNote)' -e modify -e move -e create -e delete ~ 2>&1 | awk '/^[0-9]/ {
sub(/'"${HOME//\//\\/}"'/, "~", $0)
split($0, a, " ")
len=length(a[1])+length(a[2])+1
printf "%-20s %s\n", substr($0, 0, len), substr($0, len+2)
// flush stdout
system("")
next
}
{print ; system("")}
' | tee -a /tmp/home_monitor

-m and -r are for recursively monitoring on files. I set up the output format and timestamp format. I exclude two things from being listed, one is ~/.mozilla and another is KeepNotes files. You can only have one --exclude supplied, if you have more than one, then only the last one would be effective. You have to group them up. -e specify events you want to monitor.

I use awk to do format adjustment, column alignment. Also replacing the literal of your home directory, /home/username, with just ~. Then I pipe the output to tee, so I can see on screen and write output to file at the same time. This way, Conky can ${tail /tmp/home_monitor 10} the file.

I was planning to use named pipe:

% MPIPE=/tmp/home_monitor
$ mkfifo $MPIPE
$ inotifywait ... | awk ... >$MPIPE
$ tail -f $MPIPE

It will save some disk space, but it doesnt work with Conky.

If you want to clean up /tmp/home_monitor when it gets too big, just do echo '' > /tmp/home_monitor. An important note for you, when you tail a file in Conky, make sure it exists. If you remove the file, Conky exits. I was hoping there was a Conky variable would run program in a thread and do similar task as $tail does, only the input is the standard output of that thread not a file.

By the way, I had never thought even in my own home directory would have many activities.

I tried to make JACK running on my Gentoo for a day or two, but I kept getting this:

% jackd -v -R -d alsa
jackd 0.118.0
Copyright 2001-2009 Paul Davis, Stephane Letz, Jack O'Quinn, Torben Hohn and others.
jackd comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details

getting driver descriptor from /usr/lib64/jack/jack_dummy.so
getting driver descriptor from /usr/lib64/jack/jack_net.so
getting driver descriptor from /usr/lib64/jack/jack_alsa.so
JACK compiled with System V SHM support.
server `default' registered
registered builtin port type 32 bit float mono audio
registered builtin port type 8 bit raw midi
clock source = system clock via clock_gettime
loading driver ..
start poll on 3 fd's
new client: alsa_pcm, id = 1 type 1  0x608fc0 fd = -1
creating alsa driver ... hw:0|hw:0|1024|2|48000|0|0|nomon|swmeter|-|32bit
control device hw:0
configuring for 48000Hz, period = 1024 frames (21.3 ms), buffer = 2 periods
ALSA: final selected sample format for capture: 32bit integer little-endian
ALSA: use 2 periods for capture
ALSA: final selected sample format for playback: 32bit integer little-endian
ALSA: use 2 periods for playback
new buffer size 1024
registered port system:capture_1, offset = 4096
registered port system:capture_2, offset = 8192
registered port system:playback_1, offset = 0
registered port system:playback_2, offset = 0
++ jack_sort_graph
++ jack_rechain_graph():
+++ client is now alsa_pcm active ? 1
client alsa_pcm: internal client, execution_order=0.
-- jack_rechain_graph()
-- jack_sort_graph
5485 waiting for signals
[Ten seconds later]
6624 waiting for signals
jackd watchdog: timeout - killing jackd

I googled it and found a lot are about realtime, but its not my case. After many tries, I still couldnt solve my problem so I asked for help, and someones reply helped me indirectly.

By default, JACK would try to open two ports, one for playback, the other for capture. The problem was with capture, I guess jackd couldnt receive data, so it timed out. I have to enable Capture in alsamixer or only use the playback by specifying -P. If I dont do either, the timeout always occurs.

I also tried to use TiMidity++ to create a virtual MIDI device, but there is a problem:

% timidity -iA -Oj -B2,7
TiMidity starting in ALSA server mode
ALSA lib seq_hw.c:457:(snd_seq_hw_open) open /dev/snd/seq failed: No such file or directory
error in snd_seq_open

modprobe snd-seq loads the kernel module TiMidity++ needs. Put it into /etc/modules.autoload.d/kernel-2.6 would be helpful for loading at boot time.