他丫的广电Cable猫上网又必须用Win-only客户端了,多次交涉无果,准备换电信联通的。

不开客户端只能随机地上一小部分网站,可喜的是包括google、is-programmer。开着网页代理能维持基本上网需要。

 

周末了无聊,就设计conky。连不上网缺乏素材啊缺乏素材~~~,所以也没设计啥高端功能:

 

下面是conkyrc,严重依赖我的硬件:

own_window yes
own_window_type desktop
own_window_transparent yes
own_window_argb_visual true
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
out_to_console no
use_xft yes
override_utf8_locale yes
xftfont Droid Sans Mono:size=10
update_interval 2
double_buffer yes
draw_shades no
draw_outline no
draw_borders no
stippled_borders 10
border_width 1
default_color white
default_shade_color white
default_outline_color white
alignment top_right
gap_x 12
gap_y 37
use_spacer left
no_buffers yes

TEXT
${image /usr/share/icons/Faenza/places/48/distributor-logo-archlinux.png -s 40x40 -p 0 0}         ${color gray}${font Comic Sans MS:size=12}Welcome to use ${color #35a3da}Arch Linux${color} ^_-${font}${color}
      ${font Claire Hand:size=16}${color white}${nodename}${font}${alignr} ${color pink}${time %F %a %R}
${font where stars shine the brightest:size=32}${color white}Sensors ${hr}${font}${color grey}
 CPU: ${execi 2000 cat /sys/bus/pci/drivers/k8temp/0000:00:18.3/temp1_input | head -c -4}/${execi 2000 cat /sys/bus/pci/drivers/k8temp/0000:00:18.3/temp3_input | head -c -4}°C ${alignr} Freq: ${freq}MHz
 GPU:${nvidia temp}°C ${alignr} VCore:  ${execi 2000 ~/.conky/getnum /tmp/.conky/hwmon/in0_input 3 1000}V
 MB:  ${execi 2000 ~/.conky/getnum /tmp/.conky/hwmon/temp2_input 0 1000}°C ${alignr} CPUFAN: ${execi 2000 cat /tmp/.conky/hwmon/fan2_input}RPM
${font where stars shine the brightest:size=32}${color white}CPU ${hr}${font}
 ${font Monaco:size=10}${color yellow}Load: ${loadavg} ${alignr} Usage: ${cpu 0}%${font}
 ${color grey}NAME              PID     CPU%   TIME${color grey}
 ${top name 1} ${top pid 1}  ${top cpu 1} ${top time 1}
 ${top name 2} ${top pid 2}  ${top cpu 2} ${top time 2}
 ${top name 3} ${top pid 3}  ${top cpu 3} ${top time 3}
 ${top name 4} ${top pid 4}  ${top cpu 4} ${top time 4}
${font where stars shine the brightest:size=24}${color white}Memory & Swap ${hr}${font}
${font Monaco:size=10}${color yellow}$mem/$memmax($memperc%)${alignr}$swap/$swapmax($swapperc%)${font}
 ${color grey}NAME              PID     MEM%   TIME${color grey}
 ${top_mem name 1} ${top_mem pid 1}  ${top_mem mem 1} ${top time 1}
 ${top_mem name 2} ${top_mem pid 2}  ${top_mem mem 2} ${top time 2}
 ${top_mem name 3} ${top_mem pid 3}  ${top_mem mem 3} ${top time 3}
 ${top_mem name 4} ${top_mem pid 4}  ${top_mem mem 4} ${top time 4}
${font where stars shine the brightest:size=30}${color white}Disk ${hr}${font}
 ${font Monaco:size=10}${color yellow}Read: ${diskio_read} ${alignr} Write: ${diskio_write} ${color grey}${font}
 LABEL      FREE         TOTAL${alignr}USED
   /      ${fs_free /}       ${fs_size /}${alignr}${fs_used_perc /}%
  VHD     ${fs_free /mnt/VHD}       ${fs_size /mnt/VHD}${alignr}${fs_used_perc /mnt/VHD}%
  tmp     ${fs_free /tmp}       ${fs_size /tmp}${alignr}${fs_used_perc /tmp}%
${font where stars shine the brightest:size=30}${color white}Network ${hr}${font}
   ${font Monaco:size=10}${color yellow}IP - ${addr eth0}${color grey}${font}
 Down: ${downspeed} (${totaldown})
   Up: ${upspeed} (${totalup})
   

 

我的系统上有两个hwmon(监控硬件状态)设备,开机时内核分配的编号不确定,所以无法用conky的hwmon解决。就写了个脚本,在运行conky前先调用这个脚本,选择适当hwmon链接到一个固定目录:

#!/bin/sh

mkdir -p /tmp/.conky
rm -rf /tmp/.conky/hwmon
if [ -e "/sys/class/hwmon/hwmon0/name" ]; then
    ln -s "/sys/class/hwmon/hwmon0" /tmp/.conky/hwmon
else
    ln -s "/sys/class/hwmon/hwmon1" /tmp/.conky/hwmon
fi

 

工具getnum是用来从文本文件中读取数字的,用法是:getnum 文件 A B,最后输出的结果是文件中读取的浮点数字N/B,保留A位输出。

在网上看到的例子是用cat和echo解决的,但我怕效率低,就自己写了个:

#include <stdio.h>
#include <stdlib.h>

int main (int argc, char *argv[])
{
    freopen(argv[1], "r", stdin);

    if (argc != 4)
        exit(1);

    float num;
    scanf("%f", &num);
    num /= atoi(argv[3]);

    char fm[8];
    snprintf(fm, 8, "%%.%sf", argv[2]);
    printf(fm, num);

    return 0;
}