<?xml version="1.0"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
   <channel>
      <pubDate>Thu, 4 Dec 2008 00:52:58 GMT</pubDate>
      <lastBuildDate>Thu, 4 Dec 2008 00:52:58 GMT</lastBuildDate>
      <language>en</language>
      <docs>http://www.rssboard.org/rss-specification</docs>
      <title>CrunchBang ~ bash</title>
      <link>http://crunchbang.org/tags/bash/</link>
      <description>Code, Design &amp; GNU/Linux</description>

<item>
    <title>Openbox Pipe Menu for xcompmgr</title>
    <link>http://crunchbang.org/archives/2008/04/06/openbox-pipe-menu-for-xcompmgr/</link>
    <pubDate>Sun, 06 Apr 2008 01:42:04 GMT</pubDate>
    <dc:creator>Philip Newborough</dc:creator>
    <guid>http://crunchbang.org/archives/2008/04/06/openbox-pipe-menu-for-xcompmgr/</guid>
    <description><![CDATA[
    <p>I have been playing around with and writing a Bash script <a href="http://icculus.org/openbox/index.php/Openbox:Pipemenus " title="More about Openbox pipe menus.">pipe menu</a> for xcompmgr under <a href="http://icculus.org/openbox/index.php/Main_Page " title="Openbox is a highly configurable, next generation window manager with extensive standards support.">Openbox</a>. The script has dual functionality; firstly, it acts as on/off toggle for xcompmgr; secondly, it produces a conditional menu depending on whether or not xcompmgr is running &#8212; if xcompmgr is not running, an &#34;Enable Compositing&#34; menu item will appear; if xcompmgr is running, a &#34;Disable Compositing&#34; menu item will be offered along with a list of &#34;Set Target Window Transparency to XX%&#34; items.</p>

<p>It is a simple Bash script, but quite effective. Please feel free to modify/improve as you see fit.</p>

<pre><code>#!/bin/bash
# Openbox Pipe Menu for xcompmgr
################################

# Set xcompmgr command options
EXEC='xcompmgr -c -t-5 -l-5 -r4.2 -o.55' #basic compositing
#EXEC='xcompmgr -cCfF -t-5 -l-5 -r4.2 -o.55 -D6' #more effects

# Toggle compositing. Call with "myxcompmgr --startstop"
if [ "$1" = "--startstop" ]; then 
    if [ ! "$(pidof xcompmgr)" ]; then
      $EXEC
    else
      killall xcompmgr
    fi
    exit 0
fi
# Output Openbox menu
if [ ! "$(pidof xcompmgr)" ]; then
    cat &lt;&lt; _EOF_
    &lt;openbox_pipe_menu&gt;
        &lt;item label="Enable Compositing"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;myxcompmgr --startstop&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
    &lt;/openbox_pipe_menu&gt;
_EOF_
else
    cat &lt;&lt; _EOF_
    &lt;openbox_pipe_menu&gt;
        &lt;item label="Remove Transparency from Target Window"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;transset 1&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
        &lt;item label="Set Target Window Transparency to 10%"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;transset .90&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
        &lt;item label="Set Target Window Transparency to 20%"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;transset .80&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
        &lt;item label="Set Target Window Transparency to 30%"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;transset .70&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
        &lt;item label="Set Target Window Transparency to 40%"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;transset .60&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
        &lt;item label="Set Target Window Transparency to 50%"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;transset .50&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
        &lt;item label="Set Target Window Transparency to 60%"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;transset .40&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
        &lt;item label="Set Target Window Transparency to 70%"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;transset .30&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
        &lt;item label="Set Target Window Transparency to 80%"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;transset .20&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
        &lt;item label="Set Target Window Transparency to 90%"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;transset .10&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
        &lt;separator/&gt;
        &lt;item label="Disable Compositing"&gt;
            &lt;action name="Execute"&gt;
                &lt;execute&gt;myxcompmgr --startstop&lt;/execute&gt;
            &lt;/action&gt;
        &lt;/item&gt;
    &lt;/openbox_pipe_menu&gt;
_EOF_
fi
exit 0
</code></pre>

<h3>How to use the script</h3>

<p>Follow the instructions below to install the script and set-up the Openbox pipe menu:</p>

<p><strong>1.</strong> Open a terminal and download the script with the following command:</p>

<pre><code>wget http://crunchbang.org/misc/myxcompmgr
</code></pre>

<p><strong>2.</strong> Move the script to your &#34;bin&#34; directory and make executable:</p>

<pre><code>mv myxcompmgr ~/bin/myxcompmgr &amp;&amp; chmod +x ~/bin/myxcompmgr
</code></pre>

<p><strong>3.</strong> Open your Openbox menu.xml file for editing:</p>

<pre><code>gedit ~/.config/openbox/menu.xml
</code></pre>

<p><strong>4.</strong> Insert the following code where you would like the menu to appear, save and exit:</p>

<pre><code>&lt;menu execute="myxcompmgr" id="CompositingPipeMenu" label="Compositing"/&gt;
</code></pre>

<p><strong>5.</strong> Issue the following command to update/reconfigure Openbox:</p>

<pre><code>openbox --reconfigure
</code></pre>

<p><strong>Optional:</strong> You could also place the following entry in <code>~/.config/openbox/autostart.sh</code> to start xcompmgr on boot:</p>

<pre><code># Enable Eyecandy, see ~/bin/myxcompmgr for more info
myxcompmgr --startstop &amp;
</code></pre>

    <p style="font-size:smaller;">Tags: <a href="http://crunchbang.org/tags/bash/" title="Browse all posts tagged with &#8220;bash&#8221;">bash</a>, <a href="http://crunchbang.org/tags/crunchbanglinux/" title="Browse all posts tagged with &#8220;crunchbanglinux&#8221;">crunchbanglinux</a>, <a href="http://crunchbang.org/tags/openbox/" title="Browse all posts tagged with &#8220;openbox&#8221;">openbox</a>, <a href="http://crunchbang.org/tags/ubuntu/" title="Browse all posts tagged with &#8220;ubuntu&#8221;">ubuntu</a></p>
    ]]></description>
</item>

<item>
    <title>Wicked Cool Shell Scripts</title>
    <link>http://crunchbang.org/archives/2008/02/17/wicked-cool-shell-scripts/</link>
    <pubDate>Sun, 17 Feb 2008 07:41:45 GMT</pubDate>
    <dc:creator>Philip Newborough</dc:creator>
    <guid>http://crunchbang.org/archives/2008/02/17/wicked-cool-shell-scripts/</guid>
    <description><![CDATA[
    <p>I&#39;ve not read the book, but the <a href="http://www.intuitive.com/wicked/index.shtml " title="Wicked Cool Shell Scripts">Wicked Cool Shell Scripts</a> site and its example shell scripts are, erm, wicked cool. The site offers a whole host of scripts, some of which could quite easily be adapted/hacked into useful tools. If you&#39;re remotely interested in Shell scripting, you should take a look, even people with scripting experience might learn a thing or two.</p>

<p>URL: <a href="http://www.intuitive.com/wicked/index.shtml " title="Wicked Cool Shell Scripts">http://www.intuitive.com/wicked/index.shtml</a></p>

<p>Download the script library: <a href="http://crunchbang.org/misc/wicked-cool-shell-scripts.tgz " title="Wicked Cool Shell Scripts">wicked-cool-shell-scripts.tgz</a></p>

    <p style="font-size:smaller;">Tags: <a href="http://crunchbang.org/tags/bash/" title="Browse all posts tagged with &#8220;bash&#8221;">bash</a>, <a href="http://crunchbang.org/tags/code/" title="Browse all posts tagged with &#8220;code&#8221;">code</a>, <a href="http://crunchbang.org/tags/linux/" title="Browse all posts tagged with &#8220;linux&#8221;">linux</a>, <a href="http://crunchbang.org/tags/programming/" title="Browse all posts tagged with &#8220;programming&#8221;">programming</a>, <a href="http://crunchbang.org/tags/shell/" title="Browse all posts tagged with &#8220;shell&#8221;">shell</a></p>
    ]]></description>
</item>

<item>
    <title>Bash Script: MySQL Backup</title>
    <link>http://crunchbang.org/archives/2007/11/18/bash-script-mysql-backup/</link>
    <pubDate>Sun, 18 Nov 2007 22:11:11 GMT</pubDate>
    <dc:creator>Philip Newborough</dc:creator>
    <guid>http://crunchbang.org/archives/2007/11/18/bash-script-mysql-backup/</guid>
    <description><![CDATA[
    <p><em>I thought that it might be a good idea to start posting a few of my scripts; it&#39;ll be handy to have them on my site for future reference. Also, I learn  a lot by reading example scripts &#8212; I guess others might be able to learn from mine.</em></p>

<p>I wrote the following Bash script to perform a backup of a remote MySQL database. The script first connects via SSH and performs a MySQL dump, saving the results to file. It then connects via SFTP and downloads the file. Once the file has been downloaded, it restores the database to my local MySQL server.</p>

<p>It is quite a simple Bash script and it should be fairly straightforward to follow.</p>

<pre><code>#!/bin/sh
# Settings
#############################
REMOTEHOST="example.com"
REMOTEBACKUPDIR="backup/sql"
SQLHOST="localhost"
SQLDB="database_name"
SQLUSER="username"
SQLPASS="password"
SQLFILE="database_name.sql"
LOCALBACKUPDIR="backup/sql"
#############################
# Start main
echo "* Connecting via SSH..."
ssh $REMOTEHOST &lt;&lt;**
echo "* Performing SQL dump..."
if [ -d $REMOTEBACKUPDIR ]; then
    cd $REMOTEBACKUPDIR
else
    mkdir $REMOTEBACKUPDIR
    cd $REMOTEBACKUPDIR
fi
mysqldump -h $SQLHOST --user="$SQLUSER" --password="$SQLPASS" $SQLDB &gt; $SQLFILE
echo "* Closing SSH connection..."
exit
**
cd ~
if [ -d $LOCALBACKUPDIR ]; then
    cd $LOCALBACKUPDIR
else
    mkdir $LOCALBACKUPDIR
    cd $LOCALBACKUPDIR
fi
echo "* Connecting via SFTP..."
sftp $REMOTEHOST &lt;&lt;**
cd $REMOTEBACKUPDIR
get $SQLFILE
exit
**
echo "* Restoring SQL dump to local server..."
mysql --user "$SQLUSER" --password="$SQLPASS" $SQLDB &lt; $SQLFILE
echo "* SQL backup complete."
cd ~
exit 0
</code></pre>

<h3>Notes</h3>

<ol>
<li>For automation purposes, this script assumes that SSH and SFTP have been configured for automatic login. See &#34;<a href="http://crunchbang.org/archives/2007/10/19/creating-privatepublic-ssh-keys/ " title="Creating Private/Public SSH Keys">Creating Private/Public SSH Keys</a>&#34;</li>
<li>It also assumes there is a mirrored MySQL server and user account running on the local machine.</li>
<li>The script can be automated using <a href="http://crunchbang.org/archives/2007/10/26/howto-setup-a-crontab-file/ " title="Howto Set-up a Crontab File">Crontab</a>.</li>
<li>Lacks any error handling and/or logging!?</li>
<li>I&#39;ve worked with some commercial hosting providers who do not grant table locking privileges to their MySQL users &#8212; table locking can be bypassed by adding the &#34;<code>--skip-lock-tables</code>&#34; option to the &#34;<code>mysqldump</code>&#34; command. <em>Use with caution.</em>   </li>
</ol>

    <p style="font-size:smaller;">Tags: <a href="http://crunchbang.org/tags/bash/" title="Browse all posts tagged with &#8220;bash&#8221;">bash</a>, <a href="http://crunchbang.org/tags/code/" title="Browse all posts tagged with &#8220;code&#8221;">code</a>, <a href="http://crunchbang.org/tags/linux/" title="Browse all posts tagged with &#8220;linux&#8221;">linux</a>, <a href="http://crunchbang.org/tags/programming/" title="Browse all posts tagged with &#8220;programming&#8221;">programming</a>, <a href="http://crunchbang.org/tags/shell/" title="Browse all posts tagged with &#8220;shell&#8221;">shell</a></p>
    ]]></description>
</item>

<item>
    <title>Creating Private/Public SSH Keys</title>
    <link>http://crunchbang.org/archives/2007/10/19/creating-privatepublic-ssh-keys/</link>
    <pubDate>Fri, 19 Oct 2007 08:49:20 GMT</pubDate>
    <dc:creator>Philip Newborough</dc:creator>
    <guid>http://crunchbang.org/archives/2007/10/19/creating-privatepublic-ssh-keys/</guid>
    <description><![CDATA[
    <p><strong>13th May 2008 Update:</strong> I have removed the original contents of this post. Normally I would not remove the contents of any blog post; however, due to <a href="http://crunchbang.org/archives/2008/05/13/ubuntu-security-notice-openssl/ " title="Ubuntu Security Notice: openssl">security reasons</a> I did not want anyone to follow the instructions that were contained within the post. I have updated the information about creating passwordless SSH keys and moved it to my wiki, it is probably better off there anyway ;) See:</p>

<ul>
<li><a href="http://crunchbang.org/wiki/ssh-create-passwordless-privatepublic-key-pair/ " title="SSH: Create Passwordless Private/Public Key Pair">SSH: Create Passwordless Private/Public Key Pair</a></li>
<li><a href="http://crunchbang.org/wiki/ssh-create-privatepublic-key-pair/ " title="SSH: Create Private/Public Key Pair">SSH: Create Private/Public Key Pair</a></li>
</ul>

<p>Sorry for any inconvenience this may have caused.</p>

    <p style="font-size:smaller;">Tags: <a href="http://crunchbang.org/tags/bash/" title="Browse all posts tagged with &#8220;bash&#8221;">bash</a>, <a href="http://crunchbang.org/tags/linux/" title="Browse all posts tagged with &#8220;linux&#8221;">linux</a>, <a href="http://crunchbang.org/tags/ssh/" title="Browse all posts tagged with &#8220;ssh&#8221;">ssh</a>, <a href="http://crunchbang.org/tags/ubuntu/" title="Browse all posts tagged with &#8220;ubuntu&#8221;">ubuntu</a></p>
    ]]></description>
</item>

 </channel>
</rss>