Skip to content
Snippets Groups Projects
Commit b23c2dfe authored by Aymeric Bernard's avatar Aymeric Bernard
Browse files

Bunch of scripts for Rpi

parent 004b5261
No related branches found
No related tags found
No related merge requests found
startup_message off
vbell off
# Enable 256 color term
term xterm-256color
# Erase background with current bg color
defbce "on"
# Allow bold colors - necessary for some reason
attrcolor b ".I"
# Cache 30000 lines for scroll back
defscrollback 30000
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm "Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm"
# Enables use of shift-PgUp and shift-PgDn
termcapinfo xterm|xterms|xs|rxvt ti@:te@
# Hardstatus content
hardstatus string "%{= KG}%H %{= KW} | %{= Kd} %{= Kd}%-w%{= Kr}[%{= KW}%n %t%{= Kr}]%{= Kd}%+w %-= %D %d %M %Y%{= Kc} %c%{-}"
hardstatus alwayslastline
# Hide hardstatus: ctrl-a f
bind f eval "hardstatus ignore"
# Show hardstatus: ctrl-a F
bind F eval "hardstatus alwayslastline"
# Windows at startup
screen -t bash 0 bash
select 0
startup_message off
vbell off
# Enable 256 color term
term xterm-256color
# Erase background with current bg color
defbce "on"
# Allow bold colors - necessary for some reason
attrcolor b ".I"
# Cache 30000 lines for scroll back
defscrollback 30000
# Tell screen how to set colors. AB = background, AF=foreground
termcapinfo xterm "Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm"
# Enables use of shift-PgUp and shift-PgDn
termcapinfo xterm|xterms|xs|rxvt ti@:te@
# Hardstatus content
hardstatus string "%{= KG}%H %{= KW} | %{= Kd} %{= Kd}%-w%{= Kr}[%{= KW}%n %t%{= Kr}]%{= Kd}%+w %-= %D %d %M %Y%{= Kc} %c%{-}"
hardstatus alwayslastline
# Hide hardstatus: ctrl-a f
bind f eval "hardstatus ignore"
# Show hardstatus: ctrl-a F
bind F eval "hardstatus alwayslastline"
# Windows at startup
screen -t "tvp_back" 0 bash -c 'cd /home/hermod/tv_panel && yarn start:prod'
screen -t "tvp_front" 1 bash -c 'cd /home/hermod/tv_panel && yarn start:front'
screen -t "tvp_chromium" 2 bash -c 'cd /home/hermod/tv_panel && DISPLAY=:0 ./front/start.sh'
screen -t bash 3 bash
select 3
" Number of spaces that a pre-existing tab is equal to.
" For the amount of space used for a new tab use shiftwidth.
au BufRead,BufNewFile *py,*pyw,*.c,*.h set tabstop=4
" What to use for an indent.
" This will affect Ctrl-T and 'autoindent'.
au BufRead,BufNewFile *.py,*pyw set shiftwidth=4
au BufRead,BufNewFile *.py,*.pyw set expandtab
" Use the below highlight group when displaying bad whitespace is desired.
highlight BadWhitespace ctermbg=red guibg=red
" Display tabs at the beginning of a line in Python mode as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /^\t\+/
" Make trailing whitespace be flagged as bad.
au BufRead,BufNewFile *.py,*.pyw match BadWhitespace /\s\+$/
" Wrap text after a certain number of characters
au BufRead,BufNewFile *.py,*.pyw set textwidth=79
" Use UNIX (\n) line endings.
" Only used for new files so as to not force existing files to change their
" line endings.
au BufNewFile *.py,*.pyw set fileformat=unix
" Set the default file encoding to UTF-8:
set encoding=utf-8
" Puts a marker at the beginning of the file to differentiate between UTF and
" UCS encoding (WARNING: can trick shells into thinking a text file is actually
" a binary file when executing the text file):
set bomb
" For full syntax highlighting:
let python_highlight_all=1
syntax on
" Automatically indent based on file type:
filetype indent on
" Keep indentation level from previous line:
set autoindent
" Folding based on indentation:
"set foldmethod=indent
" Colorscheme
colo delek
#!/bin/bash
# WORK IN PROGRESS, /tmp/ stuff is to avoid breaking stuff
CURDIR=`pwd`
ln -s "$CURDIR/.screenrc" /tmp/ # /home/hermod
ln -s "$CURDIR/.vimrc" /tmp/ # /home/hermod
sudo cp "$CURDIR/waitForNetwork" /tmp/ # /root/scripts
sudo cp "$CURDIR/startup-telegram-message" /tmp/ # /root/scripts
# Folder containing root scripts that can be used with sudo without password
sudo mkdir /hermod_bin
sudo cp "$CURDIR/statusRGB.py" /hermod_bin
echo "Put in root crontab (sudo crontab -e):"
echo "@reboot /root/scripts/waitForNetwork && /root/scripts/startup-telegram-message"
echo ""
echo "Edit /root/scripts/startup-telegram-message to add your token and chat id"
echo ""
echo "Add this at the end of /etc/sudoers (sudo visudo):"
echo "hermod ALL=(ALL) NOPASSWD: /hermod_bin/statusRGB.py"
#!/bin/bash
screen -dm -S TVPanelScreen -c /home/hermod/tv_panel/scripts/.screenrc_tv_panel
#!/bin/bash
# Example: echo "Hello" | telegram.sh
apiToken="YOUR_TOKEN"
chatId=YOUR_CHAT_ID
hostname=$(hostname)
localIp=$(hostname -I)
publicIp=$(wget http://ipinfo.io/ip -qO -)
message="$hostname have local IP $localIp and public IP $publicIp"
send() {
curl -s \
-X POST \
https://api.telegram.org/bot$apiToken/sendMessage \
-d text="$message" \
-d chat_id=$chatId
}
if [[ ! -z "$message" ]]; then
send
fi
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import time
import argparse
from neopixel import *
# LED strip configuration:
LED_COUNT = 1 # Number of LED pixels.
LED_PIN = 18 # GPIO pin connected to the pixels (18 uses PWM!).
#LED_PIN = 10 # GPIO pin connected to the pixels (10 uses SPI /dev/spidev0.0).
LED_FREQ_HZ = 800000 # LED signal frequency in hertz (usually 800khz)
LED_DMA = 10 # DMA channel to use for generating signal (try 10)
LED_BRIGHTNESS = 255 # Set to 0 for darkest and 255 for brightest
LED_INVERT = False # True to invert the signal (when using NPN transistor level shift)
LED_CHANNEL = 0 # set to '1' for GPIOs 13, 19, 41, 45 or 53
LED_STRIP = ws.WS2811_STRIP_GRB # Strip type and colour ordering
def opt_parse():
parser = argparse.ArgumentParser()
parser.add_argument('color', help='The color to display')
parser.add_argument('-t', '--time', type=float, help='Display the color during this amount of seconds')
return parser.parse_args()
# Main program logic follows:
if __name__ == '__main__':
# Process arguments
args = opt_parse()
hex_color = args.color
hex_color = hex_color.lstrip('#')
if len(hex_color) == 3:
hex_color = '{0}{0}{1}{1}{2}{2}'.format(*hex_color)
if len(hex_color) != 6:
raise ValueError('Please use 6 hex characters color format')
(r, g, b) = (int(x, 16) for x in [hex_color[i:i+2] for i in (0, 2, 4)])
# Create NeoPixel object with appropriate configuration.
strip = Adafruit_NeoPixel(LED_COUNT, LED_PIN, LED_FREQ_HZ, LED_DMA, LED_INVERT, LED_BRIGHTNESS, LED_CHANNEL, LED_STRIP)
# Intialize the library (must be called once before other functions).
strip.begin()
strip.setPixelColorRGB(0, r, g, b)
strip.show()
if isinstance(args.time, float) and args.time > 0:
time.sleep(args.time)
strip.setPixelColorRGB(0, 0, 0, 0)
strip.show()
#!/bin/bash
while true
do
ping 8.8.8.8 -c 3 -W 15 -q > /dev/null
res=$?
if [ "$res" = "0" ]
then
echo "Connection established"
break
else
echo "Connection failed"
fi
sleep 5
done
exit 0
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment