Còn một cách nữa đó là các bác tận dụng cái menu DISK USAGE ít ai dùng biến nó thành tính năng bật Roonbridge cho SMPD
1. Dùng WinSCP vào folder:
/opt/plugins/81-disk_usage
2. Sửa TITLE (copy pate)
Nằm trong file này: app.json
{
"menu": "ROON",
"icon": "data_usage",
"note": "df command"
}
3. Thay script stop start Roon trong file run.sh (copy pate)
#!/bin/bash
# Copyright © 2020 symphonic-mpd Research and Development Club
systemctl stop pipe
sleep 0.5
systemctl daemon-reload
systemctl restart roonbridge
# echo "<pre>"
# pstree -Uclntp
# echo "</pre><pre>"
# df -BM -T -xdevtmpfs -xtmpfs -l |sed -z 's/\n/<br>/g'
# echo "</pre>"
# used_root=` df -h | grep "/dev/root" | awk '{ print $5 }' | sed -e '$s/.$//' `
# if [ $used_root -gt 80 ];then
# echo "<div class='alert alert-danger' role='alert'>Disk utilization has exceeded 80%.</div>"
# fi
# exit 0
Save lại là xong, bấm vào menu Roon là roonbridge chạy.
------------------------------------------------------------------------
Nếu muốn Stop Roon và mở lại âm thanh Pipe thì chỉnh tiếp cái menu Support thành tính năng Stop Roon
Chỉnh app.json:
{
"menu": "PIPE",
"icon": "email",
"note": "Download system log files"
}
Chỉnh run.sh
Xóa hết nội dung bên trong, thay thế bằng:
systemctl daemon-reload
sleep 0.5
systemctl stop roonbridge
sleep 0.5
systemctl start pipe
Trên site S-MPD có 1 topic về vụ plug-in
https://www.symphonic-mpd.com/forum/topic/70/プラグイン機能の手引き-v0-9-3/2
Guide to plugin functions (v0.9.3~)
What is the plug-in function
The "plug-in function" of symphonic-mpd is a function that allows you to add a button that starts your own shell to the menu of Web UI.
For example, you can prepare a shell that switches the DAC digital filter and execute it from the Web UI menu.
In the Web UI menu, there are functions such as "REBOOT" and "SHUTDOWN" for restarting and shutting down Raspberry Pi, but these are also implemented as plugins.
Menu customization
From "PLUGINS" in the menu of Web UI, you can switch display/non-display of the plug-ins arranged in the menu.
If you hide the plugins you don't normally use, the menu will be refreshed and easier to use.
How to make a plugin
app.json
form.html
run.sh
Create a directory under /home/pi/plugins and create 3 files.
Under /home/pi/plugins/attach there are symlinks to each plugin. If you create a symbolic link to the directory you just created under attach , it will be displayed in the Web UI menu.
app.json
This file specifies the display name and icon.
{
"menu": "SAVE QUEUE",
"icon": "save",
"note": "MPD command"
}
The icon uses Google Material icons.
Check the icon name on the following site.
https://material.io/resources/icons/?style=baseline
It doesn't affect the operation, but it's a good idea to specify the outline of the plugin in note .
form.html
If you want to pass parameters to the shell, you can provide an input form.
The point is to specify class = " run "in the input field (input element) .
<input type="text" class="run" />
If there is at least one input field with class = " run " specified in this way, run.sh will be executed when you press OK on the input form, and the input value will be the argument of the shell.
There is another useful function. By specifying
class= " config ", you can create an input field specialized for reading and writing the configuration file.
<input type="text" class="config" uri="/boot/config.txt" key="dtoverlay />
Specify the path of the setting file for uri and the setting item name for key .
That's all. If you open the input form, the setting value of the setting file will be read and displayed as the initial value.
If you click the OK button on the input form, the input values will be reflected in the setting file.
You don't even need a shell if you just want to read and write configuration files.
If you don't need the input form, you don't need to create form.html .
run.sh
Save the shell to be executed as run.sh and give it execute permission.
#!/bin/bash
mpc rm "$1"
mpc save "$1"
exit $?
When processing is complete, the standard output contents are displayed in the dialog.
If there is no standard output, a message corresponding to the shell return value is displayed.
If the return value is 0 , it is success , otherwise it is error .
Other topics
form.html
<input type="text">
<input type="radio">
supports only two types of input fields.
Check boxes and select boxes are not supported.
If
<debug />
you write in form.html , the debug information column will be displayed.
Click on the debug info column to see the parameters passed to the shell.
Ruột thì giống bên trên, vỏ thì trông gọn phết