忍者ブログ
  • 2019.09
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 2019.11
TSURUGIを入れてみた
令和SECCONに参加するのでTSURUGI Linuxを入れてみました。

fluxboxに切り替えて「fbmenugen」を使ったら「Other」に「TSURUGI」メニューが全て入ってカテゴリが分からなくなってしまいました。
fluxboxを入れた直後
仕方がないのでpythonでmateからfluxboxのmenuに変換するプログラムを作成、すっきりしましたとさ。
menuを修正後
■変換用python
import sys
from xml.dom import minidom
from os import path
from collections import OrderedDict

APP_Directory = None
DIR_Directory = None
def main():
    global APP_Directory
    global DIR_Directory

    if len(sys.argv)!=2:
        print("Using: {} mate.conf".format(sys.argv[0]))
        return
    fileName = sys.argv[1]
    APP_Directory = path.abspath(path.dirname(fileName)+"/../applications")
    DIR_Directory = path.abspath(path.dirname(fileName)+"/../desktop-directories")
    print(fileName)

    with open(fileName, "r", True, "UTF-8") as r:
        x = "\n".join(r.readlines())
    myDom = minidom.parseString(x)
    
    recurseDict(myDom, 0, [])

def recurseDict(dic, layer, stack):
    #dic = minidom.parseString("")
    layer+=1
    if sum(1 for x in dic.childNodes if not isinstance(x, minidom.Text)):
        if dic.nodeName != "Layout":
            for d in dic.childNodes:
                if not isinstance(d, minidom.Text):
                    recurseDict(d, layer, stack)

    else:
        if dic.nodeName == "Directory":
            lidx = 0
            for lidx in range(len(stack), 0, -1):
                if layer > stack[lidx-1][0]:
                    break
            for _ in range(lidx, len(stack)):
                stack.pop()
                print("{}[end]".format(" "*(len(stack)*2)))
            
            v = readFile(DIR_Directory+"/"+dic.childNodes[0].nodeValue)
            print("{}[submenu] ({}) <{}>".format(" "*(len(stack)*2), v["Name"], v["Icon"]))
            stack.append((layer, v))

        if dic.nodeName == "Filename":
            v = readFile(APP_Directory+"/"+dic.childNodes[0].nodeValue)
            print("{}[exec] ({}) {{{}}} <{}>".format(" "*(len(stack)*2), v["Name"], v["Exec"], v["Icon"]))

    if layer==1:
        for _ in range(len(stack)):
            stack.pop()
            print("{}[end]".format(" "*(len(stack)*2)))

def readFile(fileName):
    with open(fileName, "r", True, "UTF-8") as r:
        rec=dict()
        while True:            
            line = r.readline()
            if line=="":
                break
            line = line[:-1]

            pos = line.find("=")
            if pos >=0:
                key = line[0:pos]

                if ["Icon", "Name", "Exec"].count(key):
                    rec[key] = line[pos+1:]

        return rec


if __name__ == "__main__":
    main()
■fbmenugenにinclude機能を追加
diff --git a/fbmenugen b/fbmenugen
index 84e268b..fa5e784 100755
--- a/fbmenugen
+++ b/fbmenugen
@@ -401,6 +401,14 @@ ITEM_WITH_ICON
 ITEM
 }

+sub prepare_include {
+    my $path= shift() =~ s/\)/\\)/gr;
+
+    return <<"EOF"
+  [include] ($path)
+EOF
+}
+
 sub begin_category {
     $with_icons
       ? <<"MENU_WITH_ICON"
@@ -479,6 +487,9 @@ foreach my $schema (@$SCHEMA) {
     elsif (exists $schema->{item}) {
         $generated_menu .= prepare_item(@{$schema->{item}});
     }
+    elsif (exists $schema->{include}) {
+        $generated_menu .= prepare_include(@{$schema->{include}});
+    }
     elsif (exists $schema->{sep}) {
         $generated_menu .= "[separator]\n";
     }
diff --git a/schema.pl b/schema.pl
index 18a824a..50ae0dd 100644
--- a/schema.pl
+++ b/schema.pl
@@ -5,6 +5,7 @@
 =for comment

     item:      add an item inside the menu               {item => ["command", "label", "icon"]},
+    include:   add include another file               {include => ["path"]},
     cat:       add a category inside the menu             {cat => ["name", "label", "icon"]},
     sep:       horizontal line separator                  {sep => undef}, {sep => "label"},
     raw:       any valid Fluxbox menu entry               {raw => q(...)},
PR
【2019/04/25 22:29 】 | linux | 有り難いご意見(4)
                                    
レスキューディスクでのリカバリ
リカバリの仕方
# mount -t /dev/mapper/VG-LV root
# mount --bind /dev root/dev
# mount -t tmpfs tmpfs root/run
# mount -t proc proc root/proc
# mount -t sysfs sysfs root/sys
# chroot root
■参考文献 http://www.linuxfromscratch.org/lfs/view/stable-systemd/chapter06/kernfs.html
【2018/12/10 21:23 】 | linux | 有り難いご意見(0)
                                    
GTKのフォント
それぞれの形式でファイルに設定する。
■gtk-3.0
~/.config/gtk-3.0/settings.ini
[Settings]
gtk-font-name = IPAPGothic 14

■gtk-2.0
style "default" {
    font_name = "IPAPGothic 14"
}
class "GtkWidget"    style "default"
【2018/12/10 21:07 】 | linux | 有り難いご意見(0)
                                    
LVMを試してみる
もうパーティションの開始アドレスとかを気にしなくても良くなるLVMを試してみた。

LVMは物理ボリュームをグローバルボリュームとしてまとめ、論理ボリュームとして切り出して使うイメージだ。
これの使い道はkvmのディスク等いろいろ使えそう
PV(=物理ボリューム) ⊆ GV(=グローバルボリューム) ⊇ LV(論理ボリューム)
(1)物理ボリュームを作成
※lvmに使うパーティションはpartedでset n lvm onをしておく。
# pvcreate /dev/sda1
(2)ボリュームグループを作成
# vgcreate VG_SDA /dev/sda1
(3)論理ボリュームを作成
# lvcreate -L 40G -n home.cur VG_SDA
確認例
# vgdisplay -v
  --- Volume group ---
  VG Name               VG_SDA
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <1.82 TiB
  PE Size               4.00 MiB
  Total PE              476932
  Alloc PE / Size       111216 / <434.44 GiB
  Free  PE / Size       365716 / <1.40 TiB
  VG UUID               GKpSTs-Mwtn-KBYo-ieDQ-XhFa-3ZVh-oY8x5G
   
  --- Logical volume ---
  LV Path                /dev/VG_SDA/home.cur
  LV Name                home.cur
  VG Name                VG_SDA
  LV UUID                MRDH1I-KKj7-YcVO-ztDI-bfcO-I8yz-eh6GOv
  LV Write Access        read/write
  LV Creation host, time pc001, 2018-12-02 19:06:34 +0900
  LV Status              available
  # open                 1
  LV Size                40.00 GiB
  Current LE             10240
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
  --- Logical volume ---
  LV Path                /dev/VG_SDA/win10.img
  LV Name                win10.img
  VG Name                VG_SDA
  LV UUID                EEdeJ1-SZWa-YaqP-SJLK-vd4n-wVjh-ASrj85
  LV Write Access        read/write
  LV Creation host, time pc001, 2018-12-08 08:10:55 +0900
  LV Status              available
  # open                 0
  LV Size                <94.44 GiB
  Current LE             24176
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/VG_SDA/work
  LV Name                work
  VG Name                VG_SDA
  LV UUID                Z3vbrP-G9sc-7OLk-oTsV-CheY-Wy45-QT6z1b
  LV Write Access        read/write
  LV Creation host, time pc001, 2018-12-08 08:13:21 +0900
  LV Status              available
  # open                 1
  LV Size                200.00 GiB
  Current LE             51200
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
   
  --- Logical volume ---
  LV Path                /dev/VG_SDA/win_work.img
  LV Name                win_work.img
  VG Name                VG_SDA
  LV UUID                5AC5rm-eo20-jNL3-b9XH-BfFe-yusp-adobt8
  LV Write Access        read/write
  LV Creation host, time pc001, 2018-12-08 10:43:29 +0900
  LV Status              available
  # open                 1
  LV Size                100.00 GiB
  Current LE             25600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3
   
  --- Physical volumes ---
  PV Name               /dev/sda1     
  PV UUID               4QkoE0-5YNL-LOi7-qwci-jJE6-yAvh-8fnv0Q
  PV Status             allocatable
  Total PE / Free PE    476932 / 365716
   
【2018/12/08 12:16 】 | linux | 有り難いご意見(0)
                                    
期待できないExpect
Expectを使えるか試してみようと「sed」と対話するスクリプトを作った結果・・・
●スクリプト
#!/bin/expect -f
 
spawn sed -e "s/Q/A/g"
set timeout 1
 
send -raw "Q\n"
expect {
        -re "A" {puts "OK!"}
}

send -raw "Q\n"
expect {
        -re "Q" {puts "No Change!"}
}
 
send -raw "Q\n"
expect {
        -re "B" {puts "Wrong!"}
}
 
close
 
exit
●結果
spawn sed -e s/Q/A/g
Q
A
OK!
Q
No Change!
A
Q
A
なぜに、sendした文字も拾ってるんだーーーー。orz
【2015/05/05 16:49 】 | linux | 有り難いご意見(2)
                                    
| ホーム | 次ページ>>