tisdag 26 augusti 2014

Asus rt-n66u och bahnhof OpenVpn

Efter att ha hämtat hem config filerna från bahnhof så redigerade jag filen client.ovpn.

Jag tog bort raden tls-auth tls.key 1 och raden ca ca.crt

Därefter infogade jag detta:
<ca>
-----BEGIN CERTIFICATE-----

 och allt här i mellan från filen ca.crt
-----END CERTIFICATE-----
</ca>

Sedan lade jag till dessa rader:

key-direction 1
<tls-auth>
-----BEGIN OpenVPN Static key V1-----
 och allt här i mellan från filen tls.key
-----END OpenVPN Static key V1-----
</tls-auth>


Efter att jag ändrat filen client.ovpn enligt ovan så loggade jag in på Routern och klickade på VPN och fliken VPN Client och valde där openVPN och skrev in användaruppgifterna och sedan laddade jag upp den ändrade filen client.ovpn.

Så vipps så funkade det att klicka på connect. :)

torsdag 25 juli 2013

Ändra tidszon från terminalen

Kör följande kommando och välj passande tidszon :)

       
sudo dpkg-reconfigure tzdata

fredag 15 mars 2013

Spotify coverart, Artist, Album and Title in Notification

Hi,
I have made a Python script that shows Spotify cover art in notifications. It is just a thumbnail, 90x90 and it has a little Spotify logo in the lower right corner. I am getting the cover from the tracks artUrl tag that Spotify provides. If Spotify don't provide a cove art, then it will be no image in the notification :)  It works both with local music and streamed tracks from Spotify if just Spotify finds the cover.

I had a Next button in the notification but I have commented it out. It is easier to use global short-cuts for Next/Previous/PlayPause. The button also just worked for 7 seconds, as long as the notification is shown. :)

It is two scripts, make sure to keep the file names as they are, atleast the "handle_notification-spotify.py" becouse it is used in "main_handle-spotify.py".

Then install python3-dbus, it is used to communicate with Spotify.
sudo apt-get install python3-dbus

Make sure to make the scripts Executable. Then start Spotify and start "./main_handle-spotify.py" from a terminal, it will give you some information on what is going on.

If all works well the notification will start to work and if you change track in Spotify it will show you the notification containing the thumbnail of the cover and what Artist, Album and Title is playing.

The script automatic shuts down within 7 seconds from that you exits Spotify. If you want to terminate it before you have to do Ctrl+c in the terminal you started the main script. :)

Just want to draw your particular attention to this part of the scripts:

#    This script is NOT supported by or made by Spotify.
#    Spotify are NOT responsible for anything that goes wrong.
#
#    This script is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY.

Have fun! :)


main_handle-spotify.py
       

#!/usr/bin/env python
# -*- coding: utf-8 -*-

# --------------------------------------
#
#    Author: Jonas Lindberg
#    Contact: badomen02 gmail
#    Created: March 10, 2013
#
#    Purpose: To show pop-up notification about current track when track changes in Spotify.
#    Usage: Start Spotify, make sure 'handle_notification-spotify.py' is in the same folder as this script, then start this script. This script will self exit when spotify exits or if you press ctrl+c.
#    Dependencies: python3-dbus, sudo apt-get install python3-dbus to install it.
#    Troubleshooting: The Printed output will give you a hint where the problem lies. Also test this ./handle_notification-spotify.py "Artis" "Album" "Title". Hopefully it will show a simple Notification or an error that will tell you something :).
#
#   
#    This script is NOT supported by or made by Spotify.
#    Spotify are NOT responsible for anything that goes wrong.
#
#    This script is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY.
#
# --------------------------------------


from gi.repository import GLib
import subprocess
from subprocess import Popen, PIPE, STDOUT

import sys
import dbus
from dbus.exceptions import DBusException
from dbus.mainloop.glib import DBusGMainLoop
import re


def handle_properties_changed(interface, changed_props, invalidated_props):
    """Handle track changes."""
   
    # changed_props is a dict, in it there is a key that is named 'Metadata' and is containing another dictionary as Value. An empty dict will be created if 'Metadata' does not exist.
    metadata =changed_props.get("Metadata", {})
   
    # if pause is pressed then metadata will be an empty dict, i.e. False.
    if(bool(metadata)):
        sArtist = metadata['xesam:artist'][0]
        sAlbum = metadata['xesam:album']
        sTitle = metadata['xesam:title']

        #Check if the track has an artUrl
        try:
            sIcon = str(metadata['mpris:artUrl'])
        except:
            sIcon = ""
       
        # Just make the pop-up notification if a new track is playing.
        if (bool(re.search(r"(?i)spotify|http:", sArtist)))or (bool(re.search(r"(?i)spotify|http:", sTitle))) or (bool(re.search(r"(?i)spotify|http:", sAlbum))) :
            pass
        else:
            cmd = ["./handle_notification-spotify.py", sArtist, sAlbum, sTitle, sIcon]
            # If I do not PIPE I get GLib-GObject-WARNING. In Python 3.3 I think DEVNULL will work instead of PIPE. 
            try:
                subprocess.Popen(cmd , shell=False, stderr=subprocess.PIPE)
                print("Notification sent")

            except OSError as e:
                print("In line 57: ",e)
                print("Could not send notification. Make sure the handle_notification-spotify.py is in the same directory as this script.")
                loop.quit()               

           
def isSpotify():
    """This checks if Spotify service is running. Its name is 'org.mpris.MediaPlayer2.spotify' """
    player = bus_Session.get_object('org.freedesktop.DBus', '/org/freedesktop/DBus')
    iface = dbus.Interface(player, 'org.freedesktop.DBus')
    l=list(iface.ListNames())
    running = False
    for name in l:
        name=str(name)
        if name=="org.mpris.MediaPlayer2.spotify":
           running=True
             
    if bool(running):
        pass
    else:
        print("Spotify is NOT running.")
        # Quit the main loop if it is running.
        if bool(loop.is_running()):
            loop.quit()   

    return running
 
       
def connectToSpotify():
    if bool(isSpotify()):
        print("Spotify is running")
        props_changed_listener()
        return True
    else:
        sys.exit()
       

def props_changed_listener():
    """Hook up callback to PropertiesChanged event."""
    print("Trying to connect with spotify ")
    try:
        spotify = bus_Session.get_object("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2")
        spotify.connect_to_signal("PropertiesChanged", handle_properties_changed)
        print("Connection Succesful")
    except:
        print("Connection Faild.")     

   
if __name__ == '__main__':
   
    loop = GLib.MainLoop(None, False)
    dbus_loop = DBusGMainLoop(set_as_default=True)
   
    bus_Session = dbus.SessionBus(mainloop=dbus_loop)
   
    #This is making the connection to spotify or exit if it is not running.
    connectToSpotify()
    #checks every 7 sec if spotify is running, so that if you quit spotify this script will exit in less then 7 sec.
    GLib.timeout_add_seconds(7,isSpotify)
    loop.run()
    print("Script Exit")

 
handle_notification-spotify.py
       


#!/usr/bin/env python
# -*- coding: utf-8 -*-


# --------------------------------------
#
#    Author: Jonas Lindberg
#    Contact: badomen02 gmail
#    Created: March 10, 2013
#
#    Purpose: To show pop-up notification about current track when track changes in Spotify.
#    Usage: Start Spotify, then run the script 'main_handle-spotify.py' it will call This script with the argumets "Artis" "Album" "Title" "artUrl". The script will self exit in 8 seconds.
#
#    Dependencies: python3-dbus, sudo apt-get install python3-dbus to install it.
#    Troubleshooting: Test this ./handle_notification-spotify.py "Artis" "Album" "Title". Hopefully it will show a simple Notification or an error that will tell you something :).
#
#   
#    This script is NOT supported or created by Spotify.
#    Spotify is NOT responsible for anything that goes wrong.
#
#    This script is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY.
#
# --------------------------------------

from gi.repository import GLib, Gio
from gi.repository import Notify
from gi.repository.GdkPixbuf import Pixbuf

import sys
import dbus
from dbus.mainloop.glib import DBusGMainLoop
import re


def next_cb(n, action, data):
    try:
        spotify = session_bus.get_object("org.mpris.MediaPlayer2.spotify", "/org/mpris/MediaPlayer2")
        iface = dbus.Interface(spotify, 'org.mpris.MediaPlayer2.Player')
        iface.Next()
    except:
        #print("Spotify is not running")
       loop.quit()

def closed_cb(user_data):
    Notify.uninit()
    loop.quit()


if __name__ == '__main__':
    artist = sys.argv[1]
    album = sys.argv[2]
    title = sys.argv[3]

    #Checks if the artUrl is sent. Sets the icon to a Pixbuf or None.
    if (len(sys.argv)==5 and bool(sys.argv[4])):
        artUrl = str(sys.argv[4])
        file = Gio.File.new_for_uri(artUrl)
        icon =Pixbuf.new_from_stream(file.read(None), None)
    else:
        icon=None

    sLabel = artist
    sBody='Album: ' +album+'\n'+ 'Track: ' + title
    sActionlabel = "Next"
   
    loop = GLib.MainLoop(None, False)
    dbus_loop = DBusGMainLoop(set_as_default=True)
    session_bus = dbus.SessionBus(mainloop=dbus_loop)

    # Any name will do.
    Notify.init("Played on Spotify")
   
    n = Notify.Notification.new(sLabel, sBody, None)
    try:
        n.set_image_from_pixbuf(icon)
    except TypeError as e:
        #print("No Art Url, Spotify can't find the cover.",e)
        pass
   
    n.set_urgency(Notify.Urgency.CRITICAL)
    n.connect("closed", closed_cb)
    # Uncomment the next line to get a "Next" button. It only works while the notification is displayed, 7 seconds.
    #n.add_action("next", sActionlabel, next_cb, None, None)
    n.set_timeout(7000)
    loop=GLib.MainLoop()
    Notify.Notification.show(n)
    loop.run()


 

söndag 17 februari 2013

Spotify in notification

Hello,
 I have made a little script that sends a notification of the Artist, Album and Song that is playing on Spotify.
It is checked every fifth second but not updated if it has not changed.
Change the sleep command to change the update frequency.

So I thought I would share it with the world :)
       



#!/bin/bash

# --------------------------------------
#
#    Author: Jonas Lindberg
#    Contact: badomen02 gmail
#    Created: February 17, 2013
#
#    Purpose: Pop up notification of what Spotify is playing.
#    Usage: Start Spotify then start this script. This script will self exit when spotify exits. 
#    Dependencies: libnotify-bin, sudo apt-get install libnotify-bin to install it.
#    Troubleshooting: Test this command notify-send "Artist" "Album" in a terminal.
#
#    This script is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY.
#
# --------------------------------------

echo "Started"
title_playing=""
# It will run as long spotify is runing.
while [ "$(pidof spotify)" ];do
  title_compare="$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata' 2>/dev/null |egrep -A 1 "title"|egrep -v "title"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$)"

  # Just make a notify when a new song is played 
  if [ "$title_playing" != "$title_compare" ];then
    album="$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata' 2>/dev/null |egrep -A 2 "album"|egrep -v "album"|egrep -v "array"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$)"

    artist="$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata' 2>/dev/null |egrep -A 2 "artist"|egrep -v "artist"|egrep -v "array"|cut -b 27-|cut -d '"' -f 1|egrep -v ^$)"

    title_playing="$(dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.freedesktop.DBus.Properties.Get string:'org.mpris.MediaPlayer2.Player' string:'Metadata' 2>/dev/null |egrep -A 1 "title"|egrep -v "title"|cut -b 44-|cut -d '"' -f 1|egrep -v ^$)"
    
      # Checks that the artist is not empty and that the title doesn't start with Spotify.
      if [ -n "$artist" ]; then 
        if [[ $title_playing != Spotify* ]]; then
          notify-send "$artist" "Album: $album
Title: $title_playing"
        fi
     fi  
  fi
# How often in seconds it will update
 sleep 5
done
echo "Ended"


       
 

söndag 20 januari 2013

Qt Quick 2.0 LocalStorge

Just another note to my self... Qt documentation is not updated correctly. This works to get/create the database:
.import QtQuick.LocalStorage 2.0 as LS
db = LS.LocalStorage.openDatabaseSync("your_db_name", "db_Version_Nr", 
"db_description", estimated_size_of_db_in_bytes);
More info at Qt-LocalStorage

k4dirstat - keep track of your hard drive space

Just thought I'd tell about k4dirstat. A really clear and good way to keep track of what consumes disk space.

lördag 20 oktober 2012

Simple version control of your files

This litle script under the action menu in dolphin comes in handy when you often need to do copies of some files in one folder.
I use it when i am scripting and need to know that different script(files) are in sync with each other. It adds date and time to the end of the filename--20121020-2236.

Save this to a file named myAction.desktop ( the .desktop is the important part of the name ) in this folder  /home/USER/.kde/share/kde4/services/ . Changeg USER to  your username.
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=all/allfiles
Actions=backupFile

[Desktop Action backupFile]
Name=Copy file(s) and add date-time to filename(s) 
Icon=background
Exec=~/bin/cpRename.sh %F


Then in /home/USER/bin folder  save this to a file named cpRename.sh and make it executable.
#!/bin/bash
 
addDate=$(date +%Y%m%d) #20121020
addTime=$(date +%k%M) #1743
addText=$(kdialog --inputbox "Add additional text ( optional )")
isCansled=$? # Check if text was added or if the dialog was cancelled

# $@ is all the selected files and folders
for file in "${@}"
do
  # checks if it is a file so that not a folder is selected by mistake
  if [ -f "$file" ]
  then
    if [ $isCansled == 1 ]
      then
      new_name="$file--$addDate-$addTime"
      cp "$file" "$new_name"
    else
      new_name="$file--$addDate-$addTime-$addText"
      cp "$file" "$new_name"
    fi
  fi
done


Now restart Dolphin and select some files, right click and select actions and now ther should be a submenu with the name "Copy file(s) and add date-time to filename(s)"

tisdag 2 oktober 2012

Qt quick folderlistmodel

To be able to use folderlistmodel in qml, install it like this:
sudo apt-get install libqt4-declarative-folderlistmodel
and use it like this:
import QtQuick 1.1
import Qt.labs.folderlistmodel 1.0

ListView {
  id:myListView
     width: 200; height: 400

    FolderListModel {
         id: folderModel
         nameFilters: ["*.svg"]
         folder: "./images/"
         showDirs:false
     }

    Component{
      id:fileDelegate
 
      Item{
        width:myListView.width
        height:myListView.height/10
  
        Text { id :imageInfo 
          text: "file name",fileName
          width:parent.width 
          height:imageInfo.text.height 
         }
        Image { source: filePath 
          anchors.top:imageInfo.bottom
          width:parent.width 
          height:parent.height}
      }
    }
     
  model: folderModel
  delegate: fileDelegate
}
Read more here: folderlistmodel


söndag 19 augusti 2012

Wifi Stream any sound to UPnP/DLNA device.

Hi

Streaming sound from wine Spotify or VLC etc. to for example Philips bdp5200.
Do it like this:
 (Important if 3. is impossible to do then do 4. first and try 3. again. I don't remember the order I did it in...)

1. open ~/.config/rygel.conf for editing.
2.  skip by the [general] tag and then turn everything to false (lower case) and save it.
3. start  paprefs (it is the pulse audio config tool) select Network Server tab and select the "Make local sound device available as DLNA/UPnP server".
4.In the terminal run this pacmd load-module module-http-protocol-tcp command to make everything work with rygel.
5. Start rygel in the terminal by typing rygel


You will see it has now found "rygel-Message: New plugin 'org.gnome.UPnP.MediaServer2.PulseAudio' available" and there will be some errors witch I just ignore because it works :)

Start Wine and spotify or what ever sound you want to stream.
On my Philips bdp5200 blue ray player i select brows PC and the rygel server pops up. Select outgoing units (direct translation from swedish...) and the sounds starts playing after a little while. ("buffering").

Do NOT mute the sound on your computer playing anythin just turn the volyume really low :)

onsdag 27 juni 2012

krunner (Alt + F2) i Kubuntu

Om Alt + F2 slutar fungera i Kubuntu kan det fungera med att öppna en terminal och starta krunner från den.

Det hjälpte iaf mig. Efter att jag gjort det så fungerade Alt + F2 utan problem.

Se även till att den finns under autostartprogram så fungerar det nästa gång datorn startas också.

onsdag 24 augusti 2011

kryptera fil

Krypterar en fil:
openssl des3 -salt -in infile.txt -out krypterad_fil.txt


Dekrypterar till en fil
(OBS! Man måste ange ett annat namn på -out annars förstörs originalfilen!)
openssl des3 -d -salt -in krypterad_fil.txt -out normalfile.txt

Dekrypterar till stdout:
openssl des3 -d -salt -in encryptedfile.txt

söndag 22 maj 2011

Egna skript i dolphin

(Nu har jag bytt till Kubuntu)

Skapar ett till alternativ under åtgärder (Skapa kopia) i menyn som dyker upp när man högerklickar på en fil.

Man får namnge en ny kopia av filen så om man vill göra en kopia i samma mapp som man är i och ge den ett valfritt namn så är det bara ett klick bort.

i mappen
~/.kde/share/kde4/services/

skapade jag filen backupFile.desktop. Det är viktigt att den slutar på .desktop

Detta ska filen inehålla:
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=application/octet-stream;
Actions=backupFile

[Desktop Action backupFile]
Name=Skapa kopia
Icon=background
Exec=~/bin/cp_backup_dialog.sh %u

MimeTypen som jag har angett gör att meny alternativet Skapa kopia visas för alla sorters filer men inget annat.
Actions visar vilka actions som finns tillgängliga. Här finns det bara en tillgänglig, backupFile.

Icon visar en icon annars visas bara text i menyn.
Exec=~/bin/cp_backup_dialog.sh %u kör ett skript som jag har gjort och %u gör att sökvägen och filnamnet på den filen man har högerklickat på skickas till skriptet.

Här är skriptet:

01if [[ -f "$1" ]]; then # True if FILE exists and is a regular file.
02    selectedFile="$1"
03    backupPathName=$(zenity --text="Skriv in namnet för kopian och eventuell ny sökvägen." --entry-text="$selectedFile" --entry)


04    if [[ $? == 0 ]]; then # True if previos command exicutet correctly.
05        backupname=${backupPathName##*/}

06        if [[ -n "$backupname" ]]; then # True if the length of "STRING" is non-zero. -n

07            if [[ -a "$backupPathName" ]]; then # True if FILE exists.

08                if zenity --question --ok-label=JA --cancel-label=NEJ --text="Filen $backupname finns redan, vill du skriva över den?"; then
09                    if [[ -w "$backupPathName" ]]; then # True if FILE exists and is writable.
10                        cp "$1" "$backupPathName"
11                        if [[ $? == 0 ]] ; then # True if previos command exicutet correctly.
12                            zenity --info --text "Backupen är nu klar, filen $backupPathName har skapats."
13                        else
14                        zenity --info --text "Backupen misslyckades, kanske har du inte skrivrättigheter här"
15                        fi

16                    else
17                        zenity --info --text "Filen $backupPathName är skrivskyddad så backupen kunde inte tas."
18                    fi
19                else
20                    zenity --info --text "Backupen är ej genomförd"
21                fi
22            else
23                cp "$1" "$backupPathName"
24                if [[ $? == 0 ]] ; then # True if previos command exicutet$backupname correctly.
25                    zenity --info --text "Backupen är nu klar, filen $backupPathName har skapats."
26                else
27                    zenity --info --text "Backupen misslyckades, kansk $backupnamee har du inte skrivrättigheter här eller så finns inte mappen du angav."
28                fi
29            fi
30        else
31            zenity --info --text "Backupen är ej genomförd, du namngav inte filen."
32        fi
33    else
34        zenity --info --text "Backupen är ej genomförd"
35    fi
36else

37        zenity --info --text "Du har inte valt någon fil."
38fi


För en mer ordentlig genomgång hur allt fungerar(inte mitt skript men resten) så kolla in

torsdag 21 april 2011

Flash i helskärm

Flash filmer i helskärm har strulat för mig. De har fungerat nån gång ibland men oftast har bilden bara fryst på en gång.

Med inställningshanteraren CompizConfg kan man fixa det även om det finns en viss risk att man inte kommer ut från helskärmsläget ifall man pressar den för hårt mellan lägena.

Programmet som måste vara installerat är Avancerade inställningar för skrivbordseffekter

I inställningshanteraren CompizConfg gå till Avancerad sökning och sök efter helskärm. Allmänna Alternativ - Omdirigera tillbaka helskärmsfönster ska förkryssas.
Sen i FF kan man högerklicka på filmen och välja inställningar och där under bildskärmen finns Aktivera maskinvaruacceleration, se till att den är aktiverad.

tisdag 1 februari 2011

Installera det senaste QT biblioteket

Installera det senaste QT biblioteket.
I skrivandets stund så är det v4.7.1

Hämta filen här och sen pakar du upp den och kör följande kommando i dens mapp.

./configure
make
sudo make install

När jag körde ./configure så fick jag ett felmeddelande "Qt configure error: Basic XLib functionality test failed" men det gick till sig efter att jag installerade "libxext-dev", libxrender-dev. Jag vet inte vilken av dem som hjälpte men jag installerade båda för säkerhetsskull.

Obs! se till att tidigare bibliotek är borttagna för säkerhetsskul. Om ni har installerat den tidigare så gå in i mappen där källkoden finns och kör följande kommando: "sudo make uninstall"

onsdag 26 januari 2011

PySide/PyQt4 kod komplitering i Eclip

Kåd kompilering för PySide/PyQt4 i Eclips
1. Window -> Preferences... -> Pydev -> Interpreter - Python
2. Under "Forced builtin libs" fliken, klicka "New..."
3. Skriv in PySide och klicka OK (om man vill ha kompilation för PyQt4 så skriver man det)

Obs!
Om du installerat PyDev efter att du insallerat PySide/PyQt4 så kan det bli strul med biblioteken. Om det strular är det enklast att ta bort Python interpriatorn och installera om den och sen göra om det där tre punkterna. :)

Om man använder olika python versioner måste man repetera de tre punkterna för varje python Interpreter som man vill använda.

Av nån anledning måste jag skriva så här för att komplitering ska fungera någorlunda...:
import PySide.QtCore
import PySide.QtDeclarative
import PySide.QtGui

Den visar inte nån annan än QtCore som förslag vid första punkten och om jag skriver QtDeclarative så efter den andra punkten så visar den vilka valmöjligheter man har.
PySide.QtDeclarative.

Originalet är taget härifrån:
http://www.saltycrane.com/blog/2007/06/how-to-get-code-completion-for-pyqt/

Installation av Pyside

Som jag har sagt tidigare så är detta som en stor Post-it lapp för mig så här är länken till PySide sidan som visar hur enkelt man kan installera PySide.

PySide installation

tisdag 28 december 2010

Streama film till xbox 360

citat från:
https://help.ubuntu.com/community/Ps3MediaServer


PS3 Media Server

Introduction

Stream Media to your DLNA compliant devices.

PS3 Media Server is a DLNA compliant Upnp Media Server originally written for the PS3, now supports Xbox360, Sony Bravia, Popcorn Hour, Samsung Wiselink, Freebox HD & others. PMS is written in Java, with the purpose of streaming or transcoding any kind of media files, with minimum configuration. It's backed up with the powerful Mplayer/FFmpeg packages.

Installation instructions

You can install the software directly from the .deb package pms-linux. Otherwise, you may follow the instructions below for building from the source.

- PMS requires the following packages: MEncoder, Mplayer, FFMpeg, and Sun's Java

* To install from a terminal and type:

sudo apt-get install mencoder ffmpeg mplayer vlc sun-java6-jre

* in Ubuntu 10.04 ( lucid ) type:

sudo apt-get install mencoder ffmpeg mplayer vlc openjdk-6-jre

Or you can click on these packages individually if you'd prefer to avoid the terminal:

* mencoder ffmpeg mplayer vlc sun-java6-jre

- Grab the latest version of Playstation 3 Media Server and save it on you home directory

- Navigate to your home directory, right cilck on the .tgz file you just downloaded and select extract here.

- Navigate to that folder, right click on PMS.sh and choose properties now in Permissions allow it to be executed. Do the same thing for a file called tsMuxeR which is in a sub-folder called linux.

- Finally just double click on PMS.sh and choose run to start the program!

Configuration

In the General Configuration tab Under Network Settings choose the network interface you want to stream your media from (ex wlan0, lan0, etc) You maybe want to tick Start Minimized.

In the Navigation/Share Settings add any folders of media you would like to share for example ~/Videos and ~/Music

Click Save to save your settings.

Additional configuration files per device can be found in the subfolder renderers they are simple text files you can edit with your favorite editor Vi(m), Gedit, pico, etc. For Xbox360 avi/divx playback you need to edit the last line in XBOX360.conf

From:

StreamExtensions=wma,asf

To:

StreamExtensions=wma,asf,avi

start at startup

If you'd like to have PMS startup when you log into ubuntu, you can simply add the PMS.sh script with the full path to System -->Preferences --> Startup Applications -->Add

http://code.google.com/p/ps3mediaserver/ - PS3MediaServer home page

EDIT:
Med version 1.21.1 var jag tvungen att flytta mappen renders från ps3mediacenter mappen till /home/dokument annars fick jag hela tiden felet:[New I/O server worker #1-1] Media renderer was not recognized.HTTP User agent :Xbox/2.0.7371.0 UPnP/1.0 Xbox/2.0.7371.0

En annan sak som jag la märke till är att pms.conf filen som används också läggs direkt under dokumentmappen.

Detta ändras under inställningar:
Och så en sista sak som jag glömde säga tidigare man ska välja vilket nätverkskort man vill använda och så ska man skriva port 49200 under "Tvinga serverport"

Under Navigations/utdelningsinställningar ska man välja vilka mappar man vill dela ut. Det är bara att klicka på plusstecknet.

EDIT2:
Om inte srt undertexterna fungerar så testa att under MEncoder avmarkera ASS/SSA Undertexter, då dök helt plötligt undertexten upp för mig :)


Xbox 360 och Monowall

I could play games online, but could not chat in private chat. Here is a direct quote from monowall forum that helped me:

Quote:"
"Here's what I did to get it from "Moderate" to "Open":

1. Create a reservation in my DHCP server for my Xbox 360 so that it always gets the same IP address. You could also set a static IP on the Xbox if that is your preference.

2. In m0n0wall, check the box "Enable advanced outbound NAT" on the Outbound NAT configuration tab.

3. Setup a mapping for your local LAN subnet. Interface should be WAN, source should be your subnet address (for example, my subnet is 192.168.0.0/24), target should be left blank and leave "Disable port mapping" unchecked.

4. Setup a mapping for your Xbox 360. Interface should be WAN, source should be the IP address assigned to the Xbox in Step 1 with a 32 bit mask (for example, 192.168.0.100/32), target should be left blank and this time check the box for "Disable port mapping".

5. Save and apply these changes.

6. Configure Inbound NAT and create a mapping for TCP/UDP 3074. Interface should be WAN, External address should be Interface address, Protocol should be TCP/UDP, External port range should be 3074 to 3074, NAT IP should be the IP address of the Xbox assigned in Step 1, Local port should be 3074. Check the box to "Auto-add a firewall rule to permit traffic through this NAT rule."

7. Save and apply these changes.

8. Reset the NAT and Firewall state.

Now when you run the Xbox live test, it should come back as "Open".

NOTE: The above steps were based on the 1.3b11 version of m0n0wall. I haven't used any of the previous versions, so the steps may vary from version to version."

by Tismo on monowall forum

In addition to Port 3074 (UDP and TCP) I had to open port 88 (UDP)

Note: If you cannot chat with someone using Video Kinect, you might need to open port 1863 (UDP and TCP).
"End Quote

My monowall is on 192.168.1.1 and my xbox is on 192.168.1.4 . So I had to change 3. to 192.168.1.0/24 and 4. to 192.168.1.4/32)

Note:

8. Reset the NAT and Firewall state. ( Diagnostic -> Reser state )



onsdag 22 september 2010

Bash. Byt filändelse eller förändra filnamnet.

Här visar jag lite olika lösningnar på hur man kan ändra namnen på filerna.

Om man tex vill byta alla *.JPG till att bli *.jpg så kan man göra det så här, först kolla man vilka filer som kommer att ändras:
for filnamn in *.JPG; do filnamn=./"${filnamn// /\\ }"; echo "$filnamn" '->' "${filnamn/.JPG/.jpg}";done

Denna del filnamn=./"${filnamn// /\\ }" sätter in en \ före alla melanslag i filnamnet och skriver över grundvariabeln filnamn med det nya värdet. /. delen ser till så att ett namn som startar med ett bindesträck inte av misstag tolkas som en flagga till kommandot. När man sedan kör mv och omsluter filnamnen med " " så lägger mv in \ där det behövs automatiskt och man behöver inte försöka att själv hantera mellanslagen i filnamnen.

Om det är de filer man vill ändra så gör man ändrinFetgen så här:
for filnamn in *.JPG; do mv -v ./"$filnamn" ./"${filnamn/.JPG/.jpg}";done

-v gör att det visas vilka filer som har bytt namn.

Några varianter med förklaringar:

echo $s
.jpghej.jpg
Så ser variabeln s ut i sin grund .

echo ${s/.jpg/.JPG}
.JPGhej.jpg
Byter ut första

echo ${s//.jpg/.JPG}
.JPGhej.JPG
Byter ut alla(även om det fanns en i mitten)

echo ${s/%.jpg/.JPG}
.jpghej.JPG
Byter ut den sista (även om det fanns en i mitten)

om man skippar utbytesdelen så tar man helt enkelt bort den/de delar som man annars förändrade.

måndag 2 augusti 2010

Installera Python2.7 i Ubuntu 10.4

Så här kan ni installera Python 2.7 under Ubuntu 10.04.

Börja med att ladda ned källkoden härifrån:
http://python.org/ftp/python/2.7/Python-2.7.tgz

Packa upp den i valfri mapp och gå in i den mappen.
Kör följande komandon i den mappen.

./configure
make
sudo make altinstall

Lägg märke till att det står altinstall och INTE install, det gör att det inte riskerar att bli den primära Python versionen i systemet.
Du hittar Python2.7 här /usr/local/bin och bibliote ken ligger då under /usr/local/lib/python2.7

Ett enkelt sett att se att den funkar är att i terminalen skriva python2.7. Ni avslutar den med exit() eller ctrl+d