Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash -x
- echo " dollar-pound is $#"
- if [ "$#" -gt "1" ]; then
- read -p "$* was interpreted as $# arguments. This script does not yet support multiple arguments although the actual thunar command will open multiple instances if given multiple arguments that are valid directory names. If a need to emulate this behaviour arises this script will need to be revised. [enter] to exit." # could make this a loop unil a single vaid argument was entered.
- exit
- fi
- if [ "$#" = "0" ]; then
- PATH_DIR="$PWD"
- fi
- if [ "$#" = "1" ]; then
- PATH_DIR="$1"
- fi
- if [ !-d "$PATH_DIR" ]; then
- read -p "$PATH_DIR is not a directory."
- exit
- fi
- DIR="${PATH_DIR##*/}"
- # Setting an initial condition for a variable that may be changed later. Logically it could be left undefined but this is easier to follow.
- ARGUMENT_IS_SPECIAL_CASE=no
- nohup thunar "$PATH_DIR" &
- sleep 1
- # The idea below is to make a good guess at the title of the thunar window just opened and wmctrl it into shape. It will work for all explicit full paths, including / which thunar's titling mechanism treats specially, and for ~/. It will fail for other arguments like ".", "..", "~/..", "~/../other_user/dir", etc. There is probably some way to get the actual directory name, just the simple filename without a path that will work even for these, which could make this more robust. But this will do since a failure to get the name right just means the window isn't quite where it should be, which can be corrected with a couple of clicks, this will cover most likely cases, and eventually somebody will fix the damn rc.xml anyway and this won't be needed.
- if [ "$PATH_DIR" = "/" ]; then
- wmctrl -r "File System - File Manager" -e 0,0,60,1912,970
- ARGUMENT_IS_SPECIAL_CASE=yes
- fi
- if [ "$PATH_DIR" = "~/" ]; then
- wmctrl -r "$USER - File Manager" -e 0,0,60,1912,970
- ARGUMENT_IS_SPECIAL_CASE=yes
- fi
- if [ "$#" = "0" ]; then
- wmctrl -r "${PWD##*/} - File Manager" -e 0,0,60,1912,970
- ARGUMENT_IS_SPECIAL_CASE=yes
- fi
- if [ "$ARGUMENT_IS_SPECIAL_CASE" = "no" ]; then
- wmctrl -r "$DIR - File Manager" -e 0,0,60,1912,970
- fi
- /bin/bash
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement