From 889d54298901bdac3e846486cc62f7a115d690ab Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Tue, 2 Jul 2019 19:50:14 +0200 Subject: [PATCH] #646 added touchscreen scripts --- home.admin/00infoLCDTK.py | 30 ++++++--- .../config.scripts/blitz.touchscreen.sh | 67 +++++++++++++++++++ 2 files changed, 88 insertions(+), 9 deletions(-) create mode 100644 home.admin/config.scripts/blitz.touchscreen.sh diff --git a/home.admin/00infoLCDTK.py b/home.admin/00infoLCDTK.py index 43e43e7ba..2d353a520 100644 --- a/home.admin/00infoLCDTK.py +++ b/home.admin/00infoLCDTK.py @@ -105,36 +105,48 @@ def main(): setup_logging() log.info("Starting 00infoLCDTK.py") + # LCD root root = tk.Tk() root.config(bg=COLOR) root.overrideredirect(1) root.geometry("480x320+0+0") - root.title("RaspiBlitz 1.x") + root.title("RaspiBlitz") + # but LCD on canvas entry = tk.Entry(root) entry.config(bg=COLOR, highlightbackground=COLOR) + entry.pack(side="bottom", fill="x") - frame1 = tk.Frame(entry, width=60, background="black") - frame2 = tk.Frame(entry, width=420, background="grey") + # button frame + frame1 = tk.Frame(entry, width=80, background="black") + frame1.pack(side="left", fill="both", expand=True) + # button 1 button1 = tk.Button(frame1, text='\u0397', fg='black', command=callback_b1) - button2 = tk.Button(frame1, text='\u0399', fg='black', command=callback_b2) - label3 = tk.Label(frame1, text='1.x', bg=COLOR, fg='white') - button4 = tk.Button(frame1, text='\N{BLACK CIRCLE}', fg='red', command=callback_b4) - button1.pack(pady=24) + + # button 2 + button2 = tk.Button(frame1, text='\u0399', fg='black', command=callback_b2) button2.pack(pady=24) + + # button 3 + label3 = tk.Label(frame1, text='1.3', bg=COLOR, fg='white') label3.pack(pady=24) + + # button 4 + button4 = tk.Button(frame1, text='\N{BLACK CIRCLE}', fg='red', command=callback_b4) button4.pack(pady=24) - entry.pack(side="bottom", fill="x") - frame1.pack(side="left", fill="both", expand=True) + # content frame + frame2 = tk.Frame(entry, width=400, background="grey") frame2.pack(side="right", fill="both", expand=True) + # run terminal in WINFO = frame2.winfo_id() if sys.platform != "win32": os.system("xterm -fn fixed -into %d +sb -hold /home/admin/00infoLCD.sh &" % WINFO) + # run root.mainloop() diff --git a/home.admin/config.scripts/blitz.touchscreen.sh b/home.admin/config.scripts/blitz.touchscreen.sh new file mode 100644 index 000000000..b4149c609 --- /dev/null +++ b/home.admin/config.scripts/blitz.touchscreen.sh @@ -0,0 +1,67 @@ +#!/bin/bash +# much thx to frennkie working the prototype on this +# based on https://gist.github.com/frennkie/4d99cb35a3c62033a535564220c11150 +# see issue: https://github.com/rootzoll/raspiblitz/issues/646 +# to work it needs to be based on Raspbian Desktop base image + +# command info +if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then + echo "STILL EXPERIMENTAL - NOT FINISHED" + echo "the touch screen feature" + echo "blitz.touchscreen.sh [on|off]" + exit 1 +fi + +# update install sources +echo "make sure dependencies are installed ..." +sudo apt-get install -y unclutter xterm +echo "" + +################### +# SWITCH ON +################### + +if [ "$1" = "1" ] || [ "$1" = "on" ]; then + + echo "Turn ON: Touchscreen" + sudo raspi-config nonint do_boot_behaviour B4 + + sudo sed -i s'/autologin-user=root/autologin-user=pi/' /etc/lightdm/lightdm.conf + sudo sed -i s'/--autologin root/--autologin pi/' /etc/systemd/system/getty@tty1.service.d/autologin.conf + + mv /etc/xdg/lxsession/LXDE-pi/autostart /etc/xdg/lxsession/LXDE-pi/autostart.bak + cat << EOF | sudo tee /etc/xdg/lxsession/LXDE-pi/autostart >/dev/null +@xscreensaver -no-splash +@unclutter -idle 0 +@sh /home/pi/autostart.sh +EOF + + # editing autostart.sh + cat << EOF | sudo tee /home/pi/autostart.sh >/dev/null +#!/bin/sh +sleep 1 +/usr/bin/python3 /home/admin/00infoLCDTK.py +EOF + sudo chmod a+x /home/pi/autostart.sh + sudo chown pi:pi /home/pi/autostart.sh + + # Remove 00infoLCD.sh from .bashrc of pi user + sudo sed -i s'/exec $SCRIPT/#exec $SCRIPT/' /home/pi/.bashrc + + echo "OK - a restart is needed: sudo shutdown -r now" + +fi + +################### +# SWITCH OFF +################### + +if [ "$1" = "0" ] || [ "$1" = "off" ]; then + + echo "Turn OFF: Touchscreen" + sudo raspi-config nonint do_boot_behaviour B2 + + # add again 00infoLCD.sh to .bashrc of pi user + sudo sed -i s'/#exec $SCRIPT/exec $SCRIPT/' /home/pi/.bashrc + +fi