2020年08月29日

たかが曜日表示。されど曜日表示。conkyファイルをlua変換するスクリプト / sparkylinux-2020.08-amd64-xfce

使えるコンバータースクリプトが見つかりました。
旧書式からluaな新書式に変換できます。
そりゃ、若干の修正など、必要になりますが。

要件としては、luaパッケージが必要です。
sparkylinuxのluaには、各種のバージョンがあり、
指定しろ、といわれて、lua54というパッケージを
根拠なく選びました。数が一番大きかっただけ。

旧sparkyの跡地をフォーマットする前に、
もってこなければならなった
/opt/conky/week.shに気づかず、
取り返しのつかないことになりました。
カレンダー日付の当日が大きくなり、
前後の日付が小さくなるようにするための
プログラムが欠如したため、設定が正しく
変換されても、表示されなくなりました。

日付の日にちは、代替手段を講じて
それなりに処理しましたが、曜日だけは、
表示されないままです。英語にしても、日本語にしても。
%aにしても%Aに変えても。あと、字の緑の色については、
じぶんでモノトーンにしたように思います。

試しに、適正表示されるarchbangの使い回し用の
conkyの設定ファイルをもってきて、動作させたら、
最初の一瞬のみ、(%a)で、(土)って出ましたが、
英語表示などに変更している間に、英日どちらにしても、
sparkylinux-2020.08と同じ状況に陥りました。

どうやら、環境に、localeをむやみに変えさせない、
仕組みがシステム内をあるようです。
それがなにか、インストール後の初起動で促された
日本語補足プログラムのインストールだったら笑い話。
更新窓は小さな窓で、名前なんか見ていませんでした。
ログ見りゃわかるんでしょうけど。

変換の精度は、よくできていると思います。

スクリプトの取得先は、こちら。
https://github.com/brndnmtthws/conky/blob/master/extras/convert.lua

conversion.luaなどと名前をつけたテキストファイルに、
内容を貼り付け、chmod +xなどと実行権限を付加。

$ ./coversion.lua .conkyrc .conkyrc.new

などと同一階層内で実行し、
ファイルの名前を訂正し、.conkyrc(.cofing/conky/conky.confでも
同じ要領)を入れ替えればokです。
プログラムなど入れ込んでいない平易な設定ファイルなら、
手入れなしで即動くと思います、

作者が捨てちゃう(不要になる)時期が必ず来ますから、
以下にコピーしておきます。

----

#! /usr/bin/lua

local usage = [[
Usage: convert.lua old_conkyrc [new_conkyrc]
Tries to convert conkyrc from the old v1.x format to the new, lua-based format.
Keep in mind that there is no guarantee that the output will work correctly
with conky, or that it will be able to convert every conkyrc. However, it
should provide a good starting point.
Although you can use this script with only 1 arg and let it overwrite the old
config, it's suggested to use 2 args so that the new config is written in a new
file (so that you have backup if something went wrong).
Optional: Install dos2unix. We will attempt to use this if it is available
because Conky configs downloaded from Internet sometimes are created on DOS/Windows
machines with different line endings than Conky configs created on Unix/Linux.
For more information about the new format, read the wiki page

]];

local function quote(s)
if not s:find("[\n'\\]") then
return "'" .. s .. "'";
end;
local q = '';
while s:find(']' .. q .. ']', 1, true) do
q = q .. '=';
end;
return string.format('[%s[\n%s]%s]', q, s, q);
end;

local bool_setting = {
background = true, disable_auto_reload = true, double_buffer = true, draw_borders = true,
draw_graph_borders = true, draw_outline = true, draw_shades = true, extra_newline = true,
format_human_readable = true, no_buffers = true, out_to_console = true,
out_to_ncurses = true, out_to_stderr = true, out_to_x = true, override_utf8_locale = true,
own_window = true, own_window_argb_visual = true, own_window_transparent = true,
short_units = true, show_graph_range = true, show_graph_scale = true,
times_in_seconds = true, top_cpu_separate = true, uppercase = true, use_xft = true,
draw_blended = true, forced_redraw = true
};

local num_setting = {
border_inner_margin = true, border_outer_margin = true, border_width = true,
cpu_avg_samples = true, diskio_avg_samples = true, gap_x = true, gap_y = true,
imlib_cache_flush_interval = true, imlib_cache_size = true,
max_port_monitor_connections = true, max_text_width = true, max_user_text = true,
maximum_width = true, mpd_port = true, music_player_interval = true, net_avg_samples = true,
own_window_argb_value = true, pad_percents = true, stippled_borders = true,
text_buffer_size = true, top_name_width = true, total_run_times = true,
update_interval = true, update_interval_on_battery = true, xftalpha = true,
xinerama_head = true,
};

local split_setting = {
default_bar_size = true, default_gauge_size = true, default_graph_size = true,
minimum_size = true
};

local colour_setting = {
color0 = true, color1 = true, color2 = true, color3 = true, color4 = true, color5 = true,
color6 = true, color7 = true, color8 = true, color9 = true, default_color = true,
default_outline_color = true, default_shade_color = true, own_window_colour = true
};

local function alignment_map(value)
local map = { m = 'middle', t = 'top', b = 'bottom', r = 'right', l = 'left' };
if map[value] == nil then
return value;
else
return map[value];
end;
end;

local function handle(setting, value)
setting = setting:lower();
if setting == '' then
return '';
end;
if split_setting[setting] then
local x, y = value:match('^(%S+)%s*(%S*)$');
local ret = setting:gsub('_size', '_width = ') .. x .. ',';
if y ~= '' then
ret = ret .. ' ' .. setting:gsub('_size', '_height = ') .. y .. ',';
end;
return '\t' .. ret;
end;
if bool_setting[setting] then
value = value:lower();
if value == 'yes' or value == 'true' or value == '1' or value == '' then
value = 'true';
else
value = 'false';
end;
elseif not num_setting[setting] then
if setting == 'alignment' and value:len() == 2 then
value = alignment_map(value:sub(1,1)) .. '_' .. alignment_map(value:sub(2,2));
elseif colour_setting[setting] and value:match('^[0-9a-fA-F]+$') then
value = '#' .. value;
elseif setting == 'xftfont' then
setting = 'font';
end;
value = quote(value);
end;
return '\t' .. setting .. ' = ' .. value .. ',';
end;

local function convert(s)
local setting, comment = s:match('^([^#]*)#?(.*)\n$');
if comment ~= '' then
comment = '--' .. comment;
end;
comment = comment .. '\n';
return handle(setting:match('^%s*(%S*)%s*(.-)%s*$')) .. comment;
end;

local input;
local output;

if conky == nil then --> standalone program
-- 1 arg: arg is input and outputfile
-- 2 args: 1st is inputfile, 2nd is outputfile
-- 0, 3 or more args: print usage to STDERR and quit
if #arg == 1 or #arg == 2 then
if os.execute('command -v dos2unix 2>&1 >/dev/null') == 0 then
os.execute('dos2unix ' .. arg[1]);
end
input = io.input(arg[1]);
else
io.stderr:write(usage);
return;
end;
else
-- we are called from conky, the filename is the first argument
input = io.open(..., 'r');
end;


local config = input:read('*a');
input:close();

local settings, text = config:match('^(.-)TEXT\n(.*)$');

local converted = 'conky.config = {\n' .. settings:gsub('.-\n', convert) .. '};\n\nconky.text = ' ..
quote(text) .. ';\n';

if conky == nil then
if #arg == 2 then
output = io.output(arg[2]);
else
output = io.output(arg[1]);
end
output:write(converted);
output:close();
else
return assert(loadstring(converted, 'converted config'));
end;


----

ネット上、conkyの設定については、
意外なことに古いバージョンの話がまだ多いです。
しばらくは、このスクリプト、有用でしょう。

↓時間の下に曜日が入りますが、ほらこの通り。
例は英語の化け具合ですが、日本語表示に
しても、正しく表示されません。
設定ファイルの、override_utf8_locale = は、
false,にしたり、true,にしたり、

日本語フォントは、もちろん入っています。
その下の空きは、/opt/conky/week.shで、
表示されるはずだった日にちのところ。
splarky_orig_conkyfile_2020-08-29_18-21-45.jpg
オリジナルのcpuの表示は、cpu0のみのデータが
使われていたことを思い出しました。

元のsparkylinuxのconky表示については、
前投稿を参照してください。

↓  ↓  ↓  ↓
曜日の表示は、日本語で妥協しました。

conky-takao-appear_2020-08-29_20-01-05.jpg

conky.config = {
override_utf8_locale = true,
use_xft = true,
}
conky.text = [[
${goto 45}${font TakaoGothic:size=18}${color3}${time 〜%a〜}${color}
]]

takaoフォントを直接指定して、なんとかです。
conkyの起動は、LANG=C conkyを直さないで、表示できました。

フォントをいろいろ試しました。バグじゃないのかな。
conkyは、1.10.8-1
conky-allは、1.10.8-1+b1


posted by ブログ開設者 at 18:56| Comment(0) | linux | このブログの読者になる | 更新情報をチェックする

sparkylinux-3.2-amd64死して、sparkylinux-2020.08-amd64-xfceとなる。

sparkylinux-3.2-amd64をインストールしたのが、20140228で、
中身はdebian testingとunstableと独自repoからでした。
どちらかといえば、暴れん坊ディストロで、かまってあげないと
機嫌を損ねる系でした。紳士になったいまとは大違い。
sparky-s.png
上は、インストール当時のデスクトップの
スクリーンショットですが、
アイコンをグレースケールになおしたりして、
けっこう、俺が、俺が、俺が、の世界観で、
がんばっていましたね。

きのう、そのsparkylinuxを更新しましたら、
sparkyのrepoもdebianのrepoも、
testing部分がつながらず、接続を外して、更新しましたら、
最新状態にはなったはいいけれど、
autoremoveせよがいっぱい出て、そのとおりにしたら、
起動しなくなりました、testingが亡くなった
のではなく、urlが変わったとか、だったようですね。
足りないものがあって、使えないから、
捨てろ、ってことだったのかな、と想像しています。

諦めまして、同じsparkylinuxの、2020.08-amd64-xfceを
インストールしました。入れてみると、
とにかく、行き届いています。

30代で自信満タンだったのが、40代になり成熟した?みたいな。
まさに不惑の年代? 良い仕事をしているような。
archbangのgreen氏も、いずれそうなるのかな。

2020.08につながっているrepoは、
$ sudo apt update
ヒット:1 http://deb.debian.org/debian bullseye InRelease
ヒット:2 http://deb.debian.org/debian-security bullseye-security/updates InRelease
ヒット:3 http://deb-multimedia.org bullseye InRelease
ヒット:4 https://repo.sparkylinux.org unstable InRelease
ヒット:5 https://repo.sparkylinux.org core InRelease
ヒット:6 https://repo.sparkylinux.org potolo InRelease

パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています
状態情報を読み取っています... 完了
パッケージはすべて最新です。

unstableもありますね。ローリングと思われます。
インストール後の初起動では、アップデートしましょう。
言語パッケージを入れましょう、と提案してきます。
そのとおりにしましたら、firefoxの設定画面が
日本語になりました。

あ、いま気づきました。日本語入力を
インストールしていないのに、この記事が書けています。
fcitx-mozcです。顔つき的に、地味で愛想がないので、
短期間でネームバリューは上がってこないでしょうが、
ディストリビューションとしての整い具合は、
linuxmintに近いものが出始めているのではないかな、
と感じます。

とにかく、かつての開発姿勢とは、まったく変わっています。

カーネルも、5.7.0-2-amd64。安定志向に変身して?
ローリングにしては、ゆっくりぎみですね。

sparkylinux-2020.08-amd54-xfce_2020-08-29_08-50-30.jpg

メインメニューのアイコンに、かつての荒々しさの
片鱗が残されています。

死なせたsparkyのconkyの設定ファイルが取ってあります。
conkyをインストールしても、そのままでは、
おそらく動かないでしょう。
書式をluaに変換して動くか、やってみるともりです。
変換スクリプトを見つけたこともありましたが、
使い方がわからず、毎回手動で直しています。

sparkylinux-2020.08には、xfceのほかに、
lxqtとmate版があります。

ダウンロードする先は、
sparkylinuxで検索すれば、すぐ見つかると思います。


posted by ブログ開設者 at 09:10| Comment(0) | linux | このブログの読者になる | 更新情報をチェックする