1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

感熱紙プリンター QL700 を Ubuntu で使う

Last updated at Posted at 2021-03-14

感熱紙プリンター QL700 を Ubuntu で使います。

インストールと起動(単体)

cd
git clone https://github.com/pklaus/brother_ql_web.git
cd brother_ql_web/
pip3 install -r requirements.txt

# フォントのインストール
sudo apt install -y fonts-ipa*
sudo apt install -y ttf-mikachan ttf-aoyagi* ttf-takao* ttf-kochi-gothic ttf-kochi-mincho ttf-sazanami* ttf-vlgothic
sudo apt install -y otf-yozvox-yozfont

ls -al /dev/usb/lp0 # ラベルプリンタのメンテナンスランプが点灯してないこと。していたら長押しで解除
chmod 777 /dev/usb/lp0
cp config.example.json config.json 
gedit config.json # ラベルプリンタの型番とプリンタの場所を指定
python3 brother_ql_web.py 

上記で起動できたらブラウザで http://localhost:8013 にアクセス

USBを常に権限 777 モードにする

プリンタのベンダーIDやシリアル番号は下記で調べておきます。

ls -al /dev/usb/lp0 
lsusb
dmesg 
sudo gedit /etc/udev/rules.d/49-printer.brother.rules ;

QL700 であれば idVendor と idProduct は一緒かと思います。serial だけ dmesg から得られる情報で適宜修正を行います。

49-printer.brother.rules
SUBSYSTEMS=="usb", ATTRS{idVendor}=="04f9", ATTRS{idProduct}=="2042", ATTRS{serial}=="XXXXXXXXXXXX", MODE="0777", GROUP="www-data",  SYMLINK+="/dev/usb/lp0"

USB ルールの再読込と起動

sudo /etc/init.d/udev stop
sudo /etc/init.d/udev start
# sudo udevadm control --reload-rules && udevadm trigger

# ラベルプリンタの USB を抜き差ししてみる
ls -al /dev/usb/lp0 
python3 brother_ql_web.py 

Webサービス化

毎回 python とコマンドを打つのが面倒なのでサービス化します。

gedit ql_web.service
# which python3
# gedit brother_ql_web.py 

下記 ql_web.service ファイルの USERNAME の部分を適宜修正します。

ql_web.service
[Unit]
Description = ql_web

[Service]
ExecStart = /bin/bash -c '/usr/bin/python3 /home/USERNAME/brother_ql_web/brother_ql_web.py'
Restart = always
Type = simple

[Install]
WantedBy = multi-user.target

保存をしたら、必要なライブラリを sudo でインストールして(ここ重要)サービスの登録と起動を行います。

sudo pip3 install -r requirements.txt
sudo cp ql_web.service /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl start ql_web.service
sudo systemctl status ql_web.service
sudo systemctl enable ql_web.service

これ何気に画像にも対応したものがあったりとおもしろいプリンターになります。

参考リンク

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?