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å.