Here some usefull snippets


- This can change the default open application for .gpx files with an executable.

mimeopen -d sample.gpx

- This will mute sound for 5 minutes (mutesound.sh)

amixer set Master mute
sleep 285 && amixer set Master unmute &


- This is will block internet connection except the current terminal (lowband.sh)

#!/bin/sh
# Firewall apps - only allow apps run from "internet" group to run
# clear previous rules
sudo iptables -F
# accept packets for internet group
sudo iptables -A OUTPUT -p tcp -m owner --gid-owner internet -j ACCEPT
# also allow local connections
sudo iptables -A OUTPUT -p tcp -d 127.0.0.1 -j ACCEPT
sudo iptables -A OUTPUT -p tcp -d 192.168.0.1/24 -j ACCEPT
# reject packets for other users
sudo iptables -A OUTPUT -p tcp -j REJECT
# open a shell with internet access
sudo -g internet -s


- This is an awk that can be used to rename files (rename.awk)

#ls | awk -f rename.awk |sh
# will remove xyz. from beggining of files
{
ret = match ($0,"xyz.");
if (ret==1){
pos = match($0,"-")
print "mv '"$0"' '"substr($0,pos+2)"'"
}
}


-This will convert greek text files to utf8 format (iconv.sh)

iconv -fiso-8859-7 -tutf8 $1 >temp$.$$$
mv $1 $1.old
mv temp$.$$$ $1


- This will set screen to sleep (sleep.sh)

xset dpms force off


- This is used to start gitk (git viewer) (gitk.sh)

gitk --branches=* &


-This will start vlc (startvlc.sh)

vlc --qt-start-minimized /home/kostas/Music/radios.m3u


- To start wine with file manager in x files (w.sh)

wine start "x:"
   to setup wine run :
winecfg
   then:
     In drives -> add x: \home\kostas\WINDOWS to access windows path with x: drive
     In default settings (or in a selected .exe) windows version : windows XP
     For foul screen games/apps In default settings (or in a selected game.exe)
     graphics -> emulate virtual desktop in desired resolution.
     If this does not work change resolution from Ubuntu -> settings -> display


- How to create autoexec.sh file in Ubuntu

Create ~/.config/autostart/ folder. Inside this folder create a file with name btauto.desktop
Add this text to this file:
[Desktop Entry]
Type=Application
Exec=/home/kostas/.config/autostart/autoexec.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=BTAutoConnect
X-GNOME-Autostart-Delay=1
Comment=execute autoexec.sh on start
In the same folder (~/.config/autostart/) add the autoexec.sh file. This file will be executed
after login to user's account.
#!/bin/bash
# echo "connect 04:51:9B:35:10:44" | bluetoothctl
exit


All snippets are in this zip file:usefull.zip

Back to main page