Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
LibreOffice 用のパレットを作成するスクリプト/第一引数に HEX color が列挙されたファイル名を,第二引数に色名の prefix を設定する/第二引数は省略可能でそのときは "COLOR" が prefix になる
#!/bin/bash
cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<ooo:color-table xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ooo="http://openoffice.org/2004/office">
EOF
awk '{printf "<draw:color draw:name=\"COLOR-%02d\" draw:color=\"%s\" />\n",\
NR,$1}' ${1:?} | sed "s/COLOR/${2:-COLOR}/"
cat <<EOF
</ooo:color-table>
<!--
$(date)
this palette is created from the file: ${1}.
-->
EOF
<?xml version="1.0" encoding="UTF-8"?>
<ooo:color-table xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ooo="http://openoffice.org/2004/office">
<draw:color draw:name="sample-01" draw:color="#FFFFFF" />
<draw:color draw:name="sample-02" draw:color="#33332E" />
<draw:color draw:name="sample-03" draw:color="#274E13" />
<draw:color draw:name="sample-04" draw:color="#6AA84F" />
<draw:color draw:name="sample-05" draw:color="#B6D7A8" />
<draw:color draw:name="sample-06" draw:color="#A4A380" />
<draw:color draw:name="sample-07" draw:color="#BF343F" />
<draw:color draw:name="sample-08" draw:color="#8C2E2E" />
</ooo:color-table>
<!--
Mon Dec 8 15:44:21 JST 2014
this palette is created from the file: sample.src.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment