Autostart for Linux X Windows

 Raspberry Pi  Kommentare deaktiviert
Mai 062014
 
  1. create a new directory in ~/.config:

    mkdir autostart
    
  2. create a new file with ending .desktop
    [Desktop Entry]
    Name=MyPython
    Exec=python mypythonscript.py
    Type=application
    
  3. After a reboot and starting X Windows the given script will be launched.
Dez 232013
 

The following text will describe how to set up a small media server for playing audio files with the Raspberry. I was actually looking for a light-weight solution and that is the reason why I chose the ArchLinux distribution as a platform. This solution will implement the following features:

  • a media player server with mpd
  • playback of mp3, m4a, mp4, ogg and other audio formats
  • remote control of media player via (Linux or Windows)PC, Mac, iOs or Android device
  • storing music files on an USB-stick or SD card
  • access to media files from other devices via Samba

ArchLinux Installation

Download the Arch Linux image from http://archlinuxarm.org/platforms/armv6/raspberry-pi or http://www.raspberrypi.org/downloads. Install the image on an SD-card of size>2GB. For Linux and Windows you can follow the instructions on http://archlinuxarm.org/platforms/armv6/raspberry-pi. For Mac there exists a tool called RPi SD card builder that makes life much easier.
After install insert the SD card in the Pi, connect to Network via Ethernet and power it up.

Install software

Connect to the Pi via SSH and do the following installations:

  1. Update all packages via pacman -Syu
  2. Install Music Player Daemon and client: pacman -S mpd mpc
  3. Install Alsa Utilities: pacman -S alsa-utils
  4. Install Samba: pacman -S samba

MPD configuration

Open /etc/mpd.conf with your favorite editor. It should look something like this:

user "mpd"
pid_file "/run/mpd/mpd.pid"
db_file "/var/lib/mpd/mpd.db"
state_file "/var/lib/mpd/mpdstate"
playlist_directory "/var/lib/mpd/playlists"

Add the following lines:
music_directory "/media"
follow_inside_symlinks "yes"
follow_outside_symlinks "yes"

The music_directory option is the place where your music is stored. The follow_links options allow you to insert links in the music directory that also contain music files. If these options are set to “yes” mpd will also look for music files in these directories.

Set the access rights:
chmod g+w /media /var/lib/mpd/playlists/
chgrp audio /media /var/lib/mpd/playlists/

At last set the audio output to the Raspberry 3.5mm output:
amixer cset numid=3 1

Now set the daemon free:
systemctl start mpd
and enable it for system start:
systemctl enable mpd

Now put all your music in the /media directory and update database:
mpc update

Links

Archlinux Packages

 Raspberry Pi  Kommentare deaktiviert
Dez 182013
 

All the following packages can be installed via the archlinux package manager packman.

package description
autofs Automounting removable media or network drives
htop Much nicer then top
mc Midnight Commander
mpd Audio player with server structure
samba Platform independent file and printer sharing
vsftpd Very secure FTP Daemon

useful bash commands

 Raspberry Pi  Kommentare deaktiviert
Okt 192013
 

Packages

install new package apt-get install packagename
list installed packages dpkg --get-selections
list installed packages with filter for python dpkg --get-selection | grep python

Links

Aug 112013
 

Der folgende Code zeigt einen einfachen SocketServer, geschrieben in Python, der das Bedienen eines angeschlossenen 433.92MHz-Funkmoduls von einem anderen Rechner aus ermöglicht.

Das Funkmodul wurde nach der Anleitung von Oliver Schneider auf sweetpi.h3llfire.de mit dem Raspberry gekoppelt.

server.py:

#!/usr/bin/python
#-*- coding: utf-8 -*-
'''
Created on 10.08.2013
@author: Stefan Lehmann
@summary: Kleiner Socketserver für die Fernsteuerung von RPi
'''
import SocketServer
from subprocess import call
from config import *

def light_on():
    call (["sudo","/home/pi/wiringPi/433.92-Raspberry-Pi/send", "-u","0","-i","9393870","-t"])
    return "on"

def light_off():
    call (["sudo","/home/pi/wiringPi/433.92-Raspberry-Pi/send", "-u","0","-i","9393870","-f"])   
    return "off"
    
    
class RPiRequestHandler(SocketServer.BaseRequestHandler):
    def handle(self):
        clientAdr = self.client_address[0]
        print "[%s] Verbindung hergestellt." % clientAdr
        
        while True:
            s = self.request.recv(RECV_BYTE_COUNT)
            if s:
                print "[%s] %s" % (clientAdr, s)
                if s == CMD_LIGHT_ON:
                    light_on()
                elif s == CMD_LIGHT_OFF:
                    light_off()
                elif s==CMD_QUIT:
                    break;
            else:
                break
            
        print "[%s] Verbindung geschlossen"
    
if __name__ == "__main__":
    server = SocketServer.ThreadingTCPServer(("", PORT), RPiRequestHandler)
    server.serve_forever()

client.py:

#-*- coding: utf-8 -*-
'''
Created on 10.08.2013
@author: stefanlehmann
'''
import socket
from config import *

ip = raw_input("IP-Adresse: ") 
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
s.connect((ip, PORT))

try: 
    while True: 
        nachricht = raw_input("Nachricht: ") 
        s.send(nachricht) 
 
finally: 
    s.close()

config.py:

#-*- coding: utf-8 -*-
'''
Created on 11.08.2013
@author: stefanlehmann
@summary: Konfiguration und Befehle für Client und Server
'''

PORT = 50000
RECV_BYTE_COUNT = 1024

CMD_LIGHT_ON = "lightOn"
CMD_LIGHT_OFF = "lightOff"
CMD_QUIT = "quit"

SMTP Mail einrichten

 Raspberry Pi  Kommentare deaktiviert
Jun 252013
 
  • Folgende Pakete laden:
    sudo apt-get install ssmtp
    sudo apt-get install mailutils
    sudo apt-get install mpack
  • Einstellungen des Email-Accounts bearbeiten:
    sudo nano /etc/ssmtp/ssmtp.conf
  • Folgende Felder bearbeiten:
    AuthUser=youruserid@gmail.com
    AuthPass=userpass
    FromLineOverride=YES
    mailhub=smtp.gmail.com:587
    UseSTARTTLS=YES
  • Test-Email senden:
    echo "sample text" | mail -s "Subject" username@domain.tld
  • Anhang senden:
    mpack -s "test" /home/pi/test/somefile.ext username@domain.tld

siehe http://rpi.tnet.com/project/faqs/smtp