You are not logged in.

#26 2008-10-13 15:00:47

Phrodo_00
Member
From: Seattle, WA
Registered: 2006-04-09
Posts: 342
Website

Re: Post your handy self made command line utilities

Send commands to 30 computers called lpa-pc-??:

#!/bin/bash

for ((i=1; $i<=30; i++)); do
        if [ $i -lt 10 ] ; then
                ssh -f root@lpa-pc0$i $1
        else
                ssh -f root@lpa-pc$i $1
        fi
done

get the ssh fingerprints of said computers, so I don't have to type yes thirty times each time ubuntu screws their randdom generator (yes, those computers use ubuntu... and vista *shudder* although the machine with the ssh key is a gentoo)

#!/bin/bash
#for ((i=0; $i<=30; i++)); do ssh-keyscan -p 22 -t rsa,dsa 10.5.40.$(echo 100+$i | bc) 1>> ~/.ssh/known_hosts ; done

for ((i=0; $i<=30; i++)); do
    if [ $i -lt 10 ] ; then
        ssh-keyscan -p 22 -t rsa,dsa lpa-pc0$i 10.5.40.$(echo 100+$i | bc) 1>> ~/.ssh/known_hosts
    else
        ssh-keyscan -p 22 -t rsa,dsa lpa-pc$i 10.5.40.$(echo 100+$i | bc) 1>> ~/.ssh/known_hosts
    fi

done

Offline

#27 2008-10-13 17:02:25

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: Post your handy self made command line utilities

ArchArael wrote:

About Common Lisp....are you also Emacs or Stumpwm user? I'm really fascinated about the idea of changing my working environment in real time.

I would like to learn more about it. smile

I'm an Emacs user, but I haven't tried Stumpwm, which is something I'll have to do some time. It's an interesting language.

Offline

#28 2008-10-13 21:34:55

Veles
Member
Registered: 2008-10-13
Posts: 2

Re: Post your handy self made command line utilities

Barrucadu wrote:

I'm considering rewriting some of my utilities in Common Lisp as a learning exercise...

Its an interesting language indeed, though using Common Lisp to write a simple script is, quite frankly, gratuitous overkill. For scripting, scheme is better suited.. theres even a shell based on it, scsh, which might better suit your needs as it provides all the functionality of a shell scripting language though doing it in a lispy manner, and thus might help getting into the mindset of writing lisp code. Anyways, Common Lisp is better suited for large, complex applications/systems.. though if you insist, go ahead, though its unlikely to prove much of an exercise in CL coding as you most likely wouldn't utilize most of the capabilities that make it such an interesting language, ie metaprogramming, CLOS, etc. in order to slap a few shell utilities together.


Waffles?

Offline

#29 2008-10-13 21:47:46

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: Post your handy self made command line utilities


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#30 2008-10-13 21:59:48

ArchArael
Member
Registered: 2005-06-14
Posts: 504

Re: Post your handy self made command line utilities

moljac024 wrote:

lol I always suspected that!

Last edited by ArchArael (2008-10-13 22:00:26)

Offline

#31 2008-10-13 22:14:40

Veles
Member
Registered: 2008-10-13
Posts: 2

Re: Post your handy self made command line utilities


Waffles?

Offline

#32 2008-10-13 22:16:09

Asgaroth
Member
From: Hesse, Germany
Registered: 2008-03-26
Posts: 58

Re: Post your handy self made command line utilities

ArchArael wrote:
moljac024 wrote:

lol I always suspected that!

That actually explains a lot of the messy results we are witnessing today. big_smile
*dogdes objects thrown by perl-programmers*

Offline

#33 2008-10-14 04:12:09

TjPhysicist
Member
From: Waterloo, Canada
Registered: 2008-04-12
Posts: 126
Website

Re: Post your handy self made command line utilities

here is one i made  (its not the best) for a make-do video library thingi...

#!/bin/bash
fuser -k /dev/dsp*
fuser -k /dev/dsp
echo ""
find -L "/home/tharihar/Videos//" -depth -iname "*$1*$2*$3*" ! -iname *.jpg>.playmovies
#cat .playmovies
mplayer -shuffle -really-quiet -playlist .playmovies>/dev/null

rm .playmovies
echo ""

here is one to convert .deb or .rpm to .pkg.tar.gz

#!/bin/bash
mkdir k
cd k
pkgextract.sh $1.deb
cd ..
mv k/ pkg/
echo "pkgname="$1>>PKGBUILD
echo "pkgver="$2>>PKGBUILD
echo "pkgrel=1">>PKGBUILD
echo "arch=(i686)">>PKGBUILD
echo "build()">>PKGBUILD
echo "{">>PKGBUILD
echo "echo "Building package"">>PKGBUILD
echo "}">>PKGBUILD

makepkg -R
cd ..
rm -rf pkg

that one uses pkgextract from aur i think (not my pkg).

here is one for writing Lec files, it takes input of course name and number (eg PHIL 400) and opens up vim with a tex file, and compiles it into pdf aafter i quit and displays pdf for me. The reason for this is so that i do not have to browse to the folder everytime, plus I have a universal template kinda file (called lec.tex) that I put stuff that i wanna start off with.

#!/bin/bash

#definitions
Today=`date +%b%d`
FileName=`echo "Lec_"$Today`
FilePlainPath="/home/tharihar/.bookmarks/Notes: Current/"$1\ $2/
export FilePath="/home/tharihar/.bookmarks/Notes: Current/"$1\ $2/$FileName.tex

#change directory
cd "$FilePlainPath"
if [ -e "$FilePath" ]
then
    echo "file already exists"
else
    cp ~/Notes/lec.tex "$FilePath"
fi

vim "$FilePath"
latex "$FilePath"
cp "$FilePath" "$FilePlainPath/.Lec"
rm *.aux
rm *.log
rm *.nav
rm *.out
rm *.snm
rm *.toc
rm *.vrb
dvips $FileName.dvi
ps2pdf $FileName.ps
rm *.ps
xpdf $FileName.pdf

I have another one for my essay but this one uses essay.tex and essay.bib and does latex-> bibtex-> latex-> latex before doing dvips etc.

here is the thing i use to output to dwm... (status bar)

#!/bin/bash

while true
do
    echo -e `/home/tharihar/.Bin/Info` "|" `date +"%a, %b %d"` "|" `date +"%T %p"` "| Upgradable:" `cat /home/tharihar/.tobeupgraded` "|" `cat /proc/acpi/thermal_zone/THM/temperature|gawk '/temp/ {print $2}'`"\xb0C"
done

and here is Info: (seperate siince i sometimes like to call it from CLI when i am only working with CLI without any X

#!/bin/bash
#export MPD_HOST=TjsLaptop
#export MPC_PORT=65000
tit=$(mpc | awk '/-/ {print $0}')
textp=$(mpc | gawk '/play/ {print $3,$4}')
len=${#tit}
text=""
if [ "${#textp}" -eq 0 ] #//paused
then
    text="*Paused* "
fi
    echo -n "Now Playing: "


################################
if [ "$len" -eq 0 ]    
then ####not playin mpc
    flag=0
    mpstat=$(pgrep -d ' ' mplayer) 
    if [ `pgrep Play` ] #watching anime
    then
        if [ `expr index "$mpstat" " "` -eq 0 ];then #only Play running.
            lsof -p $mpstat -a +D /media/EXTERNAL/ | gawk --field-separator='/' '/EXTERNAL/ {print $NF}'
        else #play +i one more mplayer
                       lsof -p $mpstat -a +D /media/EXTERNAL/ 2>/dev/null | gawk --field-separator='/' '/EXTERNAL/ {print $NF}'
            pos=$(expr index "$mpstat" " ")    
               lsof -p ${mpstat:pos} -a +D /media/EXTERNAL/ | gawk --field-separator='/' '/EXTERNAL/ {print $NF}'    
               echo ", Porn"
        fi
        flag=1 #1 for anime.
    elif [ `pgrep mplayer` ] ##no Play +  porn
    then
        echo -n "Porn"
        flag=2 #2 for porn
    else
        echo -n ""
    fi
    ##########Nothing is Playing###################33
    if [ $flag -eq 0 ]  #nothing is playing
    then
        echo -n "None"
    fi
###end crazy if's, mpc##########
elif [ `expr match "$tit" "D I G I T A L L Y"` -eq 0 ]
then
    ##playing music##
    echo -e $tit ' ' '[' $textp $text']'
else
    ##playing radio##
    tit=$(mpc | gawk --field-separator=':' '/-/ {print $(NF - 0)} ') 
    textp="$(mpc | gawk '/play/ {print $1"/"$3,$4}' | gawk --field-separator='/' '/play/ {print $(NF - 1)}') *Radio*"
    echo -n -e $tit ' ' '[' $textp $text ']'
fi

that one is extremely involved and basically gives the now playing status (including video etc). It works best if you use with the 'Play' script, since I play everything all my regular videos (aka not porn) using Play and everything else (aka porn) using just mplayer (start it from nautilus etc).  I also use mpd for radio which has a bit of extra adverrtisement junk at the begining of the title (the extensive expr match and the gawk is for that).


-Tj

Last edited by TjPhysicist (2008-10-14 06:59:32)


-Tj
Now reborn as Tjh_ (to keep it similar to my username in other places)

Offline

#34 2008-10-14 14:31:33

Windowlicker
Member
Registered: 2008-07-20
Posts: 15

Re: Post your handy self made command line utilities

Dmenu script for changing wallpaper with Feh or Nitrogen:

#!/bin/sh

#current=`awk '{gsub (/\/home\/joe\/wallpapers\//, ""); print $3}' ~/.fehbg`
current=`awk '/file/ {gsub (/file=\/home\/joe\/wallpapers\//, ""); print $1}' ~/.config/nitrogen/bg-saved.cfg`

cmd=$(ls ~/wallpapers | dmenu -p $current)

if [ -f ~/wallpapers/$cmd ]; then
  #feh --bg-scale ~/wallpapers/$cmd
  nitrogen --set-scaled ~/wallpapers/$cmd --save
fi

Playing albums with MPD:

#!/bin/sh

cmd=$(mpc ls | dmenu)

if [ -d ~/music/"$cmd" ]; then
  mpc clear & mpc add "$cmd"
  mpc play
fi

Editing scripts and config files with Leafpad:

#!/bin/sh

configs()
{
echo "rc.xml (config)
menu.xml (config)
autostart.sh (config)
tintrc (config)
conkyrc (config)
gtkrc-2.0 (config)
xinitrc (config)
rtorrentrc (config)
bashrc (config)
awesomerc (config)
xdefaults (config)
irssi (config)
abcde.conf (config)
fonts.conf (config)
screenrc (config)
rc.conf (config)
xorg.conf (config)
mpd.conf (config)
inittab (config)
fstab (config)
hosts (config)
hosts.allow (config)
hosts.deny (config)
ssh_config (config)
sshd_config (config)
pacman.conf (config)
makepkg.conf (config)
rc.wmii (config)
wmiirc (config)"
for name in ~/.scripts/*
do
echo "$name (script)"
done
}

dmenu=`configs | awk '!/.png|.log|.txt/ {gsub (/\/home\/joe\/.scripts\//, ""); print}'`

cmd=$(echo -n "$dmenu" | dmenu)

case ${cmd} in
  rc.xml*)        exec leafpad ~/.config/openbox/rc.xml &;;
  menu.xml*)        exec leafpad ~/.config/openbox/menu.xml &;;
  autostart.sh*)    exec leafpad ~/.config/openbox/autostart.sh &;;
  tintrc*)        exec leafpad ~/.config/tint/tintrc &;;
  conkyrc*)        exec leafpad ~/.conkyrc &;;
  gtkrc-2.0*)        exec leafpad ~/.gtkrc-2.0 &;;
  xinitrc*)        exec leafpad ~/.xinitrc &;;
  rtorrentrc*)        exec leafpad ~/.rtorrent.rc &;;
  bashrc*)        exec leafpad ~/.bashrc &;;
  awesomerc*)        exec leafpad ~/.awesomerc &;;
  xdefaults*)        exec leafpad ~/.Xdefaults &;;
  irssi*)        exec leafpad ~/.irssi/config &;;
  abcde.conf*)        exec leafpad ~/.abcde.conf &;;
  fonts.conf*)        exec leafpad ~/.fonts.conf &;;
  screenrc*)        exec leafpad ~/.screenrc &;;
  rc.conf*)        exec gksudo leafpad /etc/rc.conf &;;
  xorg.conf*)        exec gksudo leafpad /etc/X11/xorg.conf &;;
  mpd.conf*)        exec gksudo leafpad /etc/mpd.conf &;;
  fstab*)        exec gksudo leafpad /etc/fstab &;;
  inittab*)        exec gksudo leafpad /etc/inittab &;;
  hosts.allow*)        exec gksudo leafpad /etc/hosts.allow &;;
  hosts.deny*)        exec gksudo leafpad /etc/hosts.deny &;;
  hosts*)        exec gksudo leafpad /etc/hosts &;;
  ssh_config*)        exec gksudo leafpad /etc/ssh/ssh_config &;;
  sshd_config*)        exec gksudo leafpad /etc/ssh/sshd_config & ;;
  pacman.conf*)        exec gksudo leafpad /etc/pacman.conf &;;
  makepkg.conf*)    exec gksudo leafpad /etc/makepkg.conf &;;
  rc.wmii*)        exec gksudo leafpad /etc/wmii-3.5/rc.wmii &;;
  wmiirc*)        exec gksudo leafpad /etc/wmii-3.5/wmiirc &;;
  *script*)        exec leafpad ~/.scripts/${cmd} &;;
  *)            exec leafpad "$cmd" &;;
esac

Offline

#35 2008-10-14 15:47:42

rson451
Member
From: Annapolis, MD USA
Registered: 2007-04-15
Posts: 1,233
Website

Re: Post your handy self made command line utilities

Something I wrote yesterday, may be useful for someone

#!/bin/bash
#
# gov-tool
# 
# Randy Morris (rson)
#
# script to adjust cpufreq governor
# meant to be used with hotkeys, originally for use with dwm
#
# NOTE: makes the assumption that this is a dual core machine
#       and both cores are using the same governor
# 
# CREATED:  2008-10-13 20:32
# MODIFIED: 2008-10-13 21:31
 
USAGE="\ngov-tool <ACTION> [GOVERNOR]\n\
 ACTIONS:\n
  -i, --increase\t\t\tset governor to a more power hungry governor\n\
  -d, --decrease\t\t\tset governor to a less greedy governor\n\
  -s, --set <governor>\t\tset <governor> as  the current governor\n" 
 
CUR=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor)
ACT="die"
 
OPTS=$(getopt -o ids: --long increase,decrease,set: -- $@)
eval set -- "$OPTS"
while true
do
  case $1 in
    -i|--increase) ACT="up"; break;;
    -d|--decrease) ACT="down"; break;;
    -s|--set) ACT="set"; GOV=$2; break;;
    --) break;;
    *) echo "error: option parsing is broken"; exit 1;;
  esac
done
 
[ $ACT == "die" ] && echo "error: you must specify an action" && echo -e $USAGE && exit 1
 
if [[ ! $ACT == "set" ]]
then
  case $CUR in
    "performance")
      if [[ $ACT == "up" ]]
      then
        echo "error: highest performing governor is already set"
        exit 1;
      else
        GOV="ondemand"
      fi
      ;;
    "ondemand")
      if [[ $ACT == "up" ]]
      then
        GOV="performance"
      else
        GOV="conservative"
      fi
      ;;
    "conservative")
      if [[ $ACT == "up" ]]
      then
        GOV="ondemand"
      else
        GOV="powersave"
      fi
      ;;
    "powersave")
      if [[ $ACT == "up" ]]
      then
        GOV="conservative"
      else
        echo "error: most conservative governor already set"
        exit 1
      fi
      ;;
  esac
fi
 
echo "setting $GOV governor"
cpufreq-set -c0 -g $GOV
cpufreq-set -c1 -g $GOV
exit 0

archlinux - please read this and this — twice — then ask questions.
--
http://rsontech.net | http://github.com/rson

Offline

#36 2008-10-14 16:26:14

dyscoria
Member
Registered: 2008-01-10
Posts: 1,007

Re: Post your handy self made command line utilities

up ()
{
  [[ $# -eq 0 ]] && cd ..
  if [[ $1 =~ ^[0-9]+$ ]] && [[ $1 -gt 0 ]]
  then
      dirs=1
      until [[ $dirs -gt $1 ]]
      do
          command="${command}../"
      dirs=$(($dirs+1))
      done
      cd $command
      command=''
  fi
}

'up' is the same as 'cd ..'
'up 2' is the same as 'cd ../..'
'up 3' is the same as 'cd ../../..'
etc etc

this is probably written really badly tho


flack 2.0.6: menu-driven BASH script to easily tag FLAC files (AUR)
knock-once 1.2: BASH script to easily create/send one-time sequences for knockd (forum/AUR)

Offline

#37 2008-10-14 16:55:32

Procyon
Member
Registered: 2008-05-07
Posts: 1,819

Re: Post your handy self made command line utilities

@dyscoria: That's a useful one. Also fun to look for an optimization. How about: up() { for updirs in $(seq ${1:-1}); do cd ..; done; }

Offline

#38 2008-10-14 18:18:42

Dieter@be
Forum Fellow
From: Belgium
Registered: 2006-11-05
Posts: 2,001
Website

Re: Post your handy self made command line utilities

Phrodo_00 wrote:

get the ssh fingerprints of said computers, so I don't have to type yes thirty times each time ubuntu screws their randdom generator

I this command might be helpfull for you cool

ssh -o "StrictHostKeyChecking=no"

< Daenyth> and he works prolifically
4 8 15 16 23 42

Offline

#39 2008-10-14 18:38:55

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Post your handy self made command line utilities

Allan wrote:

Kill gnome-screensaver before starting mplayer

#!/usr/bin/env python 

import os
import os.path
import sys

os.system("killall gnome-screensaver")

command = '/usr/bin/mplayer %s "%s"' % (' '.join(sys.argv[1:-1]), os.path.normpath(sys.argv[-1]))
os.system(command)

os.system("gnome-screensaver")

I still do not understand the "command =" line but it works big_smile

Just an FYI. xscreensaver has a -disable command that disables the screensaver for some time. You can use that with mplayer's "heartbeat-cmd" setting - might be cleaner to do it that way

Offline

#40 2008-10-14 18:49:05

dante4d
Member
From: Czech Republic
Registered: 2007-04-14
Posts: 176

Re: Post your handy self made command line utilities

Veles wrote:

The comments, lol. It's always the same ...

Offline

#41 2008-10-14 18:50:53

dante4d
Member
From: Czech Republic
Registered: 2007-04-14
Posts: 176

Re: Post your handy self made command line utilities

To keep track of what I'm doing all the time with my computer - it needs to be polished a lot and rewritten in Java as my college "homework" hmm:

cat /usr/local/bin/achievo 
#!/bin/bash
# script achievo
# author: dante4d <dante4d@gmail.com>

DATABASE="$HOME/.achievo"

function usage() {
    BASENAME="`basename $0`"
    echo "Usage: $BASENAME <command> [arguments]"
    echo "  commands:"
    echo "    start project [task]"
    echo "    stop"
    echo "    print"
    echo
    exit 1
}

case $1 in
    'start')
        PROJECT=$2
        if [[ -z "$PROJECT" ]]; then
            echo 'Missing project'
            usage
        fi
        TASK=${3:-"-"}
        echo -e "`date '+%y/%m/%d'`\t`date '+%H:%M:%S'`\t$PROJECT\t$TASK" >> $DATABASE
        ;;
    'stop')
        echo -e "-\t`date '+%H:%M:%S'`\t-\t-" >> $DATABASE
        ;;
    'print')
        cat "$DATABASE"
        echo
        ;;
    *)
        usage
esac

exit 0

Last edited by dante4d (2008-10-14 18:53:51)

Offline

#42 2008-10-14 21:25:27

jwcxz
Member
Registered: 2008-09-23
Posts: 239
Website

Re: Post your handy self made command line utilities

Here are a few really, really stupid ones.  I'm using kdialog for information display.

lidsusp
Sometimes, I like my laptop to suspend when I close my lid.  Sometimes, I don't.  The control script:

#!/bin/bash

case $1 in
        on|1|true)
                echo 1 > ~/.lidsusp
                lidsusp check
                ;;
        off|0|false)
                echo 0 > ~/.lidsusp
                lidsusp check
                ;;
        check|get)
                if [ $(cat ~/.lidsusp) == "1" ] ; then
                        STATUS="Enabled"
                else
                        STATUS="Disabled"
                fi
                kdialog --msgbox "Suspend on Lid Close $STATUS"
                ;;
esac

The event in /etc/acpi/handler.sh:

        button/lid)
                if grep -q 1 /home/j/.lidsusp ; then
                        if grep -q closed /proc/acpi/button/lid/LID/state ; then
                                echo mem > /sys/power/state
                        fi
                fi
                ;;

This is only useful if you're the only user, obviously.

Battery status:

#!/bin/bash

STATUS=`acpi | cut -d " " -f 8 | sed s/,//g`
BATTLF=`acpi | cut -d " " -f 9 | sed s/,//g`
TIMERM=`acpi | cut -d " " -f 10 | sed s/,//g`

DIALOG="status : $STATUS
remaining : $BATTLF
time left : $TIMERM"

kdialog --msgbox "$DIALOG"

Some monitor controls (used to quickly change between on and off, single and dual displays):

[j@jwcxz Scripts]$ cat mon
#!/bin/bash

# monitor controls

newmode=$1

case $newmode in
        one|1)
                #echo "single monitor"
                xrandr --dpi 96 --output VGA --off
                ;;
        two|2)
                #echo "dual monitors"
                xrandr --dpi 96 --output VGA --size 1280x1024 --preferred --right-of LVDS
                ;;
        auto)
                if xrandr -q | grep VGA | grep " connected" > /dev/null ; then
                        mon 2
                else
                        mon 1
                fi
                ;;
        off)
                xset dpms force off
                ;;
        on)
                xset dpms force on
                ;;
esac

Switch between QWERTY and Dvorak layouts:

case $1 in
        switch)
                if [ "$(cat ~/.keymap)" == "qwerty" ] ; then
                        kbd dvorak
                else
                        kbd qwerty
                fi
                ;;
        dvorak)
                xmodmap ~/Arch/keymaps/dvorak.pke
                echo "dvorak" > ~/.keymap
                ;;
        qwerty | aaa)
                xmodmap ~/Arch/keymaps/qwerty.pke
                echo "qwerty" > ~/.keymap
                ;;
        check)
                if [ "$(cat ~/.keymap)" == "qwerty" ] ; then
                        STATUS="QWERTY"
                else
                        STATUS="Dvorak"
                fi
                kdialog --msgbox "Keyboard Layout: $STATUS"
                ;;
        *)
                kbd check
esac

Yeah, stupid, I know.  But they're useful for me.  smile


-- jwc
http://jwcxz.com/ | blog
dotman - manage your dotfiles across multiple environments
icsy - an alarm for powernappers

Offline

#43 2008-10-14 22:33:04

Barrucadu
Member
From: York, England
Registered: 2008-03-30
Posts: 1,158
Website

Re: Post your handy self made command line utilities

moljac024 wrote:

I had a dream like that last night, it was really weird.

Offline

#44 2008-10-17 12:41:18

joqueza
Member
Registered: 2008-08-16
Posts: 58

Re: Post your handy self made command line utilities

mine is pretty lame in comparsion to you guys but it helps me fixing my fonts when I'm using the external monitor in eeePC

#!/bin/bash
#ajusta tamanho das fontes no gnome dependendo da resolucao escolhida

resol=`xrandr | grep "+0+0"| awk {'print $3'} |cut -d"x" -f1`

if [ $(($resol / 100)) -gt 9 ]; then 
        gconftool-2 --set /apps/nautilus/preferences/desktop_font --type string "Sans 12"
        gconftool-2 --set /desktop/gnome/interface/document_font_name --type string "Sans 12"
        gconftool-2 --set /desktop/gnome/interface/font_name --type string "Sans 12"
        gconftool-2 --set /apps/metacity/general/titlebar_font --type string "Sans Bold 12"
        gconftool-2 --set /desktop/gnome/interface/monospace_font_name --type string "Monospace 12"
        echo "fontes setadas com tamanho 12"
else
        gconftool-2 --set /apps/nautilus/preferences/desktop_font --type string "Sans 8"
        gconftool-2 --set /desktop/gnome/interface/document_font_name --type string "Sans 8"
        gconftool-2 --set /desktop/gnome/interface/font_name --type string "Sans 8"
        gconftool-2 --set /apps/metacity/general/titlebar_font --type string "Sans Bold 8"
        gconftool-2 --set /desktop/gnome/interface/monospace_font_name --type string "Monospace 10"
        echo "fontes setadas com tamanho 8"
fi

Offline

#45 2008-10-17 13:57:30

jwcxz
Member
Registered: 2008-09-23
Posts: 239
Website

Re: Post your handy self made command line utilities

joqueza wrote:

mine is pretty lame in comparsion to you guys but it helps me fixing my fonts when I'm using the external monitor in eeePC

Have you tried adjusting the DPI settings instead?  You can do that with xrandr.


-- jwc
http://jwcxz.com/ | blog
dotman - manage your dotfiles across multiple environments
icsy - an alarm for powernappers

Offline

#46 2008-10-17 14:18:12

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,482
Website

Re: Post your handy self made command line utilities

phrakture wrote:
Allan wrote:

Kill gnome-screensaver before starting mplayer

#!/usr/bin/env python 

import os
import os.path
import sys

os.system("killall gnome-screensaver")

command = '/usr/bin/mplayer %s "%s"' % (' '.join(sys.argv[1:-1]), os.path.normpath(sys.argv[-1]))
os.system(command)

os.system("gnome-screensaver")

I still do not understand the "command =" line but it works big_smile

Just an FYI. xscreensaver has a -disable command that disables the screensaver for some time. You can use that with mplayer's "heartbeat-cmd" setting - might be cleaner to do it that way

I didn't know about the heartbeat-cmd option.  That it a better way to deal with this....  For gnome-screensaver: add  heartbeat-cmd "gnome-screen-saver-command -p"  to the mplayer config file

Offline

#47 2008-10-17 17:10:36

joqueza
Member
Registered: 2008-08-16
Posts: 58

Re: Post your handy self made command line utilities

jwcxz wrote:
joqueza wrote:

mine is pretty lame in comparsion to you guys but it helps me fixing my fonts when I'm using the external monitor in eeePC

Have you tried adjusting the DPI settings instead?  You can do that with xrandr.

Yeah I tried that but the ratio pixel/font size didn't look right to me, dunno.... but who am I to argue about coding big_smile

Offline

#48 2008-10-17 19:39:30

XFire
Member
From: UK
Registered: 2008-05-11
Posts: 192

Re: Post your handy self made command line utilities

rine wrote:

Here is my backup script. It's designed for daily use and saves the backups in a directory named after the date. It works with hardlinks, so there is a directory for every day, but not that much disk space is used.

#!/bin/bash
# Edit parameters here.
# Important: Don't forget the trailing slashes in SOURCES and TARGET
SOURCES="/etc/ /boot/ /home/rine/" 
TARGET="/media/e/archbackup/"
OPTIONS="--exclude-from=/home/rine/documents/scripts/exclude.list"

### Don't edit below ###

LASTBACKUP=`ls -d $TARGET* | sort -r | head -1`  
TODAY=`date +%y%m%d`

if [ "$LASTBACKUP" == "$TARGET$TODAY" ]; then
    echo "Backup for today is done, if there were errors, delete $TARGET$TODAY first"
    exit 1
fi

for src in $SOURCES
do
    if [ "$LASTBACKUP" ]; then
        LD="--link-dest=$LASTBACKUP$src"
    fi

    mkdir -p $TARGET$TODAY$src
    rsync -auv $OPTIONS $LD $src $TARGET$TODAY$src
done

When you want to exclude files, it's important to start them with a slash in exclude.list. If, for example, you want to exclude your "movies" directory, you type /movies. Otherwise, if you happened to have a file called movies somewhere else, it also would get excluded. Example exclude.list:

/.adobe
/.alsaplayer
/.cache
/.dbus
/.fontconfig
/.gstreamer-0.10
/.java
/.local
/.macromedia
/.mcop
/.mozilla
/.openoffice.org2
/.qt
/.quodlibet
/.session
/.texlive
/.texmf-var
/.thumbnails
/.xine
/serien
/tmp

Comments for improvement welcome.

Thanks for the code smile I modified it a bit so that it would tar and compress the folder created, then delete the folder afterwards. Thanks for making backing up so much easier.


There is a difference between bleeding [edge] and haemorrhaging. - Allan

Offline

#49 2008-10-17 23:50:03

jwcxz
Member
Registered: 2008-09-23
Posts: 239
Website

Re: Post your handy self made command line utilities

XFire wrote:

I modified it a bit so that it would tar and compress the folder created, then delete the folder afterwards.

I found that for my system, dar is much faster and also allows for things like differential backups.


-- jwc
http://jwcxz.com/ | blog
dotman - manage your dotfiles across multiple environments
icsy - an alarm for powernappers

Offline

#50 2008-10-18 02:15:23

sparky
Member
From: Minnesota, USA
Registered: 2008-07-29
Posts: 15

Re: Post your handy self made command line utilities

This is a fun little one, not really a system utility, but an entertainment one. Simple bash script that will retrieve the latest comic from dilbert.com, name it to something meaningful, and save it to a directory of your choosing. It runs as a cron job at 5:45AM daily.

Probably not the most efficient, but it has gotten the job done without complaint for quite some time now.

#!/bin/bash
#
# Script to download the daily dilbert.com comic.
# Created by Tim Lofgren.
# Revision Date: August 28, 2008

### VARIABLE DECLARATION
# Define the temporary and archive directories.
# Unless they change their website, this is all that
# should need adjusting.
tmpdir=/tmp
archivedir=/home/httpd/html/dilbert

# Define Dilbert webpage URL (no trailing slash).
dilberturl=http://dilbert.com

# Define leading section of dilbert.com's image storage location
# This is found by snooping through the page source
stripident=/dyn/str_strip/

### SCRIPT
# Make sure no files exist that could screw things up.
rm -f $tmpdir/index.html*

# Get the index.html file.
wget -q -P $tmpdir $dilberturl

# Search the index.html file for the daily comic URL.
dilbertext=`grep $stripident $tmpdir/index.html`

# Filter out the unique number and file extension.
dilbertext=${dilbertext##*img\ src=\"}
dilbertext=${dilbertext%%\"*}

# Download the daily comic.
# Rename it to something meaningful and place it in the archive directory.
# Weekdays are in .gif format, Sundays are in .jpg format. <--this is now old.
# This checks the file type and acts accordingly...
dilbertextf=${dilbertext##*.}
if [ $dilbertextf == gif ]; then
    wget -q -O $archivedir/dilbert`date +%Y%m%d`.gif $dilbertext
elif [ $dilbertextf == jpg ]; then    
    wget -q -O $archivedir/dilbert`date +%Y%m%d`.jpg $dilbertext
else
    exit 1
fi

# Remove the index.html file.
rm -f $tmpdir/index.html

exit 0

Offline

Board footer

Powered by FluxBB