読者です 読者をやめる 読者になる 読者になる

落書きノート

ふと自分が気になった事を書いてます

Conkyの設定

Linuxのデスクトップで雑多な情報を載せるアプリです。

# Conky, a system monitor, based on torsmo
#
# Any original torsmo code is licensed under the BSD license
#
# All code written since the fork of torsmo is licensed under the GPL
#
# Please see COPYING for details
#
# Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
# Copyright (c) 2005-2010 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
# All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

alignment top_right
background no
border_width 0
cpu_avg_samples 4
default_color white
default_outline_color white
default_shade_color white
draw_borders no
draw_graph_borders no
draw_outline no
draw_shades no
double_buffer yes
use_xft yes
xftfont Noto Sans Mono CJK JP:size=12
gap_x 5
gap_y 60
maximum_width 1800
minimum_size 900 900
net_avg_samples 2
no_buffers yes
out_to_console no
out_to_stderr no
extra_newline no
own_window yes
own_window_class Conky
own_window_type override
own_window_transparent no
own_window_argb_visual yes
own_window_argb_value 160
stippled_borders 0
update_interval 1.0
uppercase no
use_spacer none
show_graph_scale no
show_graph_range no

lua_load ~/lib/1text.lua
lua_draw_hook_pre draw_text

TEXT
${scroll 50 $nodename - $sysname $kernel on $machine }
$hr
${color #00bfff}CPU1 ${cpu cpu1} %
${cpubar cpu1 10,500}
${color #00bfff}CPU2 ${cpu cpu2} %
${cpubar cpu2 10,500}
${color #00bfff}CPU3 ${cpu cpu3} %
${cpubar cpu3 10,500}
${color #00bfff}CPU4 ${cpu cpu4} %
${cpubar cpu4 10,500}
${color #ff00ff}mem ${mem}
${membar 10,500}
$hr
${color #40e0d0}天気予報
${color #40e0d0}${exec ~/bin/weathersh | nkf -w}
$hr
${color #00ff7f}${exec ~/bin/rss-itmediash}
$hr

weathersh

lynx -connect_timeout=5 -source "http://weather.livedoor.com/forecast/rss/area/260010.xml" | xsltproc --param showtitle "false()" ~/lib/erss.xsl - | grep -v "^ *\\[ PR \\]" | head -n 5 | sed "s/- //g" | awk '{printf "%-12s %s %s(%s)\n",$7,$4,$5,$6}'

rss-itmediash

lynx -connect_timeout=5 -source "http://rss.rssad.jp/rss/itmnews/2.0/news_bursts.xml" | xsltproc ~/lib/erss.xsl - | nkf -W -w | head -n 10

erss.xsl

<?xml version="1.0"?>
<!--
 Epian RSS Reader version 2.0
 Copyright (C) 2006,2009 epian <epian0@yahoo.com>
-->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text" encoding="UTF-8" indent="no"/>
  <xsl:param name="showtitle" select="true()"/>
  <xsl:param name="indent" select="'  '"/>

    <xsl:template match="/">
        <!-- RSS 1.0 -->
        <xsl:apply-templates select="rdf:RDF" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"/>

        <!-- RSS 2.0 -->
        <xsl:apply-templates select="rss"/>

    <!-- Atom -->
    <xsl:apply-templates select="atom:feed" xmlns:atom="http://www.w3.org/2005/Atom"/>
    </xsl:template>

    <!-- RSS 1.0 -->
    <xsl:template match="rdf:RDF" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rss1.0="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <xsl:if test="$showtitle">
      <xsl:value-of select="rss1.0:channel/rss1.0:title"/><xsl:text>&#xA;</xsl:text>
    </xsl:if>
        <xsl:for-each select="rss1.0:item">
      <xsl:value-of select="$indent"/>
      <xsl:value-of select="rss1.0:title"/>
      <xsl:text>&#xA;</xsl:text>
        </xsl:for-each>
    </xsl:template>

    <!-- RSS 2.0 -->
    <xsl:template match="rss">
    <xsl:if test="$showtitle">
      <xsl:value-of select="channel/title"/><xsl:text>&#xA;</xsl:text>
    </xsl:if>
        <xsl:for-each select="channel/item">
      <xsl:value-of select="$indent"/>
      <xsl:value-of select="title"/>
      <xsl:text>&#xA;</xsl:text>
        </xsl:for-each>
    </xsl:template>

  <!-- Atom -->
  <xsl:template match="atom:feed" xmlns:atom="http://www.w3.org/2005/Atom">
    <xsl:if test="$showtitle">
      <xsl:value-of select="atom:title"/><xsl:text>&#xA;</xsl:text>
    </xsl:if>
    <xsl:for-each select="atom:entry">
      <xsl:value-of select="$indent"/>
      <xsl:value-of select="atom:title"/>
      <xsl:text>&#xA;</xsl:text>
    </xsl:for-each>
  </xsl:template>
</xsl:stylesheet>

この設定は他サイトを参考にしながらやりました。スクレイピングについては、lynxテキストブラウザXSLT,コマンド,正規表現を駆使して目的の情報を取り出すというわけですね。ITMediaRSSから取り出す時にgrep -vを忘れてますね…。また後で修正します。

f:id:kh2n:20170406144516p:plain

f:id:kh2n:20170406144521p:plain