You are not logged in.

#1 2010-01-28 17:48:04

NeOnsKuLL
Member
From: Havana, Cuba
Registered: 2005-03-29
Posts: 117

[script] Archlinux's related Thunar Actions

Hi all:
I'm tired of right clicking on Thunar, select "Open terminal here" and then type 'makepkg -fi', so, I'm trying to make this boring process as automatic as posible. To acompplish that, I'd written a little script which helps me to do exactly what I want to.

The script knows about tow actions: 'mkpkg' (named that way to avoid conflicts with the existent makepkg command) and 'dopkg'.

The way you use it is:
1.- On Thunar, go to Edit->Configure custom actions...
2.- Create a new action and name it
3.- Select an icon for it
4.- Set command to: your_terminal_emulator -e "full_path_to_script/the_script.sh ACTION ACTION_PARAM"
5.- On tab "Appearance Conditions", set what is needed


Concrete examples:
1.- For mkpkg action, this is my configuration:
    - Action Name: "Make Package"
    - Description: "Make Archlinux Package"
    - Icon: "terminal"
    - Command: sakura -e "/home/pavel/.bin/archpkg_thunar_actions.sh mkpkg"
    - File Pattern (On Appearance Conditions): "PKGBUILD"
    - Selection Conditions (On Appearance Conditions): "Text Files"

Then, I have a directory with the PKGBUILD and the sources of the package I want to build, I do right click over PKGBUILD file, there is my action ("Make Package"), a terminal gets opened with the output of makepkg command, then a prompt asking for confirmation if I want to install the just build package (if no problems with package build, off course).


1.- For dopkg action, this is my configuration:
    - Action Name: "Install/Uninstall Package"
    - Description: "Install/Uninstall Local Archlinux Packages"
    - Icon: "terminal"
    - Command: sakura -e "/home/pavel/.bin/archpkg_thunar_actions.sh dopkg %f"
    - File Pattern (On Appearance Conditions): "*.pkg.tar.gz"
    - Selection Conditions (On Appearance Conditions): "Other Files"

Then, I do right click over, say, pybgsetter-0.4-1.any.pkg.tar.gz, there is my action ("Install/Uninstall Package"), the script first look for the package for being installed, if it is, then it prompts you for confirmation about uninstalling it, if the package is not installed, then it prompts you for confirmation about installing the package.

Note: I tried to set it using "exo-open --working-directory %d --launch TerminalEmulator /home/pavel/.bin/archpkg_thunar_actions.sh dopkg %f" as the command, but unsuccessfuly.

My english is not the best, so, you should see it in action.

I think should be easy to make similar actions with nautilus, or any other that supports a similar approach, without any modification for the script.

The script:

#!/bin/sh


mkpkg ()
{
    makepkg -f
    if [ $? -eq 0 ];then
        read -p "Do you want to install the package? [Y/n]: " INSTALL
        [[ (-z "$INSTALL") || ("$INSTALL" = "y") || ("$INSTALL" = "Y") ]] &&\
            sudo pacman -U $(find -type f -iname "*.pkg.tar.gz")
    fi
}


dopkg ()
{
    pkgname=$(pacman -Qpi $1|grep -E "^Name.*"|sed -r 's/.*:\s+(.*)$/\1/')
    
    if [ -z "$(pacman -Qs $pkgname)" ];then
        echo "You're about to INSTALL: $(basename $1)"
    
        read -p "Do you want to install the package? [Y/n]: " INSTALL
        [[ (-z "$INSTALL") || ("$INSTALL" = "y") || ("$INSTALL" = "Y") ]] &&\
            sudo pacman -U $1
    else
        echo "You're about to UNINSTALL: $(basename $1)"
        
        sudo pacman -Rs $pkgname
    fi
}


$@
echo ""
read -p "Press ENTER to close this terminal..."

Hope it makes the making/installing/uninstalling process less boring and more confortable.

See you

Last edited by NeOnsKuLL (2010-01-28 21:01:51)


Intel Core 2 Duo E8400 3.0 GHz | 2x1GB 667MHz | 250+750GB Seageate SATAII | Samsung 19" TFT 1440x900
Openbox + obmenugen + PyTyle | bmpanel2 | oblogout | conky | pyBgSetter (with Esetroot as backend)
Projects: obmenugen, pyBgSetter

Offline

Board footer

Powered by FluxBB