forked from zynthian/zynthian-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzynthian.sh
executable file
·162 lines (140 loc) · 4.47 KB
/
zynthian.sh
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/bash
#******************************************************************************
# ZYNTHIAN PROJECT: Zynthian Start Script
#
# Start all services needed by zynthian and the zynthian UI
#
# Copyright (C) 2015-2016 Fernando Moyano <[email protected]>
#
#******************************************************************************
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# For a full copy of the GNU General Public License see the LICENSE.txt file.
#
#******************************************************************************
#export ZYNTHIAN_LOG_LEVEL=10 # 10=DEBUG, 20=INFO, 30=WARNING, 40=ERROR, 50=CRITICAL
#export ZYNTHIAN_RAISE_EXCEPTIONS=0
#------------------------------------------------------------------------------
# Some Functions
#------------------------------------------------------------------------------
function load_config_env() {
if [ -d "$ZYNTHIAN_CONFIG_DIR" ]; then
source "$ZYNTHIAN_CONFIG_DIR/zynthian_envars.sh"
else
source "$ZYNTHIAN_SYS_DIR/scripts/zynthian_envars.sh"
fi
if [ ! -z "$ZYNTHIAN_SCRIPT_MIDI_PROFILE" ]; then
source "$ZYNTHIAN_SCRIPT_MIDI_PROFILE"
else
source "$ZYNTHIAN_MY_DATA_DIR/midi-profiles/default.sh"
fi
if [ -f "$ZYNTHIAN_CONFIG_DIR/zynthian_custom_config.sh" ]; then
source "$ZYNTHIAN_CONFIG_DIR/zynthian_custom_config.sh"
fi
}
function backlight_on() {
# Turn On Display Backlight
#echo 0 > /sys/class/backlight/soc:backlight/bl_power
#echo 0 > /sys/class/backlight/fb_ili9486/bl_power
echo 0 > /sys/class/backlight/*/bl_power
}
function backlight_off() {
# Turn Off Display Backlight
#echo 1 > /sys/class/backlight/soc:backlight/bl_power
#echo 1 > /sys/class/backlight/fb_ili9486/bl_power
echo 1 > /sys/class/backlight/*/bl_power
}
function screensaver_off() {
# Don't activate screensaver
xset s off
# Disable DPMS (Energy Star) features.
xset -dpms
# Don't blank the video device
xset s noblank
}
function splash_zynthian() {
if [ -c $FRAMEBUFFER ]; then
cat $ZYNTHIAN_CONFIG_DIR/img/fb_zynthian_boot.raw > $FRAMEBUFFER
fi
}
function splash_zynthian_error() {
if [ -c $FRAMEBUFFER ]; then
#Get the IP
#zynthian_ip=`ip route get 1 | awk '{print $NF;exit}'`
zynthian_ip=`ip route get 1 | sed 's/^.*src \([^ ]*\).*$/\1/;q'`
#Generate an error image with the IP ...
img_fpath="$ZYNTHIAN_CONFIG_DIR/img/fb_zynthian_error.png"
img_w=`identify -format '%w' $img_fpath`
img_h=`identify -format '%h' $img_fpath`
pos_x=$(expr $img_w \* 100 / 266)
pos_y=$(expr $img_h \* 100 / 110)
font_size=$(expr $img_w / 24)
convert -pointsize $font_size -fill white -draw "text $pos_x,$pos_y \"IP: $zynthian_ip\"" $img_fpath $ZYNTHIAN_CONFIG_DIR/img/fb_zynthian_error_ip.png
#Display error image
xloadimage -fullscreen -onroot $ZYNTHIAN_CONFIG_DIR/img/fb_zynthian_error_ip.png
#cat $ZYNTHIAN_CONFIG_DIR/img/fb_zynthian_error.raw > $FRAMEBUFFER
fi
}
#------------------------------------------------------------------------------
# Main Program
#------------------------------------------------------------------------------
cd $ZYNTHIAN_UI_DIR
backlight_on
screensaver_off
while true; do
#Load Config Environment
load_config_env
# Start Zynthian GUI & Synth Engine
export QT_QUICK_CONTROLS_MOBILE=1
export QT_QUICK_CONTROLS_STYLE=Zynthian-Plasma
export QT_FILE_SELECTORS=Plasma
export QT_QUICK_CONTROLS_STYLE_PATH=./qtquick-controls-style
#export QT_SCALE_FACTOR=1.2
#Qt5.11 didn't support this var yet
#export QT_QPA_SYSTEM_ICON_THEME=breeze
#workaround for the old kirigami version
export XDG_CURRENT_DESKTOP=kde
export QT_QPA_PLATFORMTHEME=generic
export XDG_DATA_DIRS=/usr/share
#HACK
rm ../config/keybinding.yaml
#cp zynthian_envars.sh ../config
./zynthian_qt_gui.py
status=$?
# Proccess output status
case $status in
0)
splash_zynthian
poweroff
break
;;
100)
splash_zynthian
reboot
break
;;
101)
splash_zynthian
backlight_off
break
;;
102)
splash_zynthian
sleep 1
;;
*)
splash_zynthian_error
sleep 3
;;
esac
done
#------------------------------------------------------------------------------