You are not logged in.

#1 2014-02-26 15:22:33

emeres
Member
Registered: 2013-10-08
Posts: 1,570

obxprop2obrc - a faster way to configure openbox application settings

Configuring Openbox can be tiresome, especially if you want to customize *all* applications and its windows to your taste, so I wrote this script. Since apparently obxprop changed now, it may have bugs, although it works fine for me.

#!/bin/bash
##Script: obxprop-to-openbox-rc.sh
##Recommended executable name: obxprop2obrc

while [ $# -ne 0 ]; do
case $1 in
	-f*)
	shift;
	FILE="$1";
	shift;
	;;
	-t*)
	shift;
	TIME="$1";
	shift;
	;;
	*)
	echo Usage: $0 [-f FILE_TEMPLATE] [-t WAIT_TO_KILL_TIME] 
	exit 1;
	;;
esac
done

if [ $TIME ]; then
	OBXPROPS=( $(obxprop | cat & (sleep $TIME && pkill -13 cat) | awk -F \" '/_OB_APP/{ print "\x22"$2"\x22" }' ) );
else
	OBXPROPS=( $(obxprop | awk -F \" '/_OB_APP/{ print "\x22"$2"\x22" }' ) );
fi
OBPROPS=(TYPE TITLE GROUP_CLASS GROUP_NAME CLASS NAME ROLE);
j=0;
for i in $( seq 2 2 14 ); do
	OBPROP="$( echo ${OBXPROPS[@]} | awk -F \" '{ print $'$i'}' )";
	if [[ -z $OBPROP ]]; then 
		declare ${OBPROPS[$j]}='"*"';
	else 
		declare ${OBPROPS[$j]}="\"$OBPROP\"";
	fi
	j=$(($j+1));
done;

echo "    <application type="$TYPE" title="$TITLE" class="$CLASS" name="$NAME" role="$ROLE">"
if [ -f "$FILE"  ]; then cat "$FILE" && exit 0; fi
cat << EOF
      <desktop>1</desktop>
      <desktop>all</desktop>
      <decor>yes</decor>
      <decor>no</decor>
      <focus>yes</focus>
      <focus>no</focus>
      <fullscreen>yes</fullscreen>
      <fullscreen>no</fullscreen>
      <iconic>yes</iconic>
      <iconic>no</iconic>
      <maximized>yes</maximized>
      <maximized>no</maximized>
      <maximized>both</maximized>
      <maximized>horizontal</maximized>
      <maximized>vertical</maximized>
      <monitor>0</monitor>
      <monitor>1</monitor>
      <position force="no">
      <position force="yes">
        <width>40%</width>
        <height>30%</height>
        <x>-1</x>
        <y>-1</y>
        <x>center</x>
        <y>center</y>
      </position>
      <layer>above</layer>
      <layer>normal</layer>
      <layer>below</layer>
      <shade>yes</shade>
      <shade>no</shade>
      <skip_pager>yes</skip_pager>
      <skip_pager>no</skip_pager>
      <skip_taskbar>yes</skip_taskbar>
      <skip_taskbar>no</skip_taskbar>
    </application>
EOF

The default configuration at the end can be edited or better yet use a template file with a -f switch. Also a time switch is present, since sometimes obxprop likes to keep you waiting forever. It does work smoothly most of the time.

Offline

Board footer

Powered by FluxBB