Tips and Tricks About Computers, Web Development, Linux, the Internet and the Like
Window Management
Random gnome-terminal profiles (themes) in Ubuntu
Sep 30th
Posted by Tyler Mulligan in Application Management
Introduction
Does it ever confuse you if you have too many terminals open at once that look alike? Perhaps you’re just looking to express your personality or tickle your brain. In any case, if you’re using the terminal in ubuntu a lot, you may be interested in having random profiles (colors / settings).
The concept of the method is pretty simple, define a hotkey that launches a script that picks a random profile you’ve created and then open the terminal with that profile as a parameter.
Prerequisites
- Compiz or other hotkey script that will allow you to link to a .sh file
- gnome-terminal
- bash
Getting Started
You can figure out what Profiles you have by going to Edit > Profiles in gnome-terminal. You likely only have one, “Default”, unless you’re already actively using terminal profiles. If you only have one, you should create a few, maybe 3 or 4 right now and play with the colors a bit. Important, don’t include spaces in the names of the profiles
The Script
Create a file in your scripts folder (or create a directory if you don’t have one):
mkdir ~/scripts touch ~/scripts/gnome-terminal.sh && chmod +x ~/scripts/gnome-terminal.sh gedit ~/scripts/gnome-terminal.sh
Paste the following replacing the Profile names with those of your own (delimited by spaces) and change the number 4 to that of the :
#!/bin/bash
p=( Default Delta Psi Sigma )
gnome-terminal --window-with-profile ${p[$((RANDOM%${#p[@]}))]}
That ugly looking bit right here is a calculation between a random number (echo RANDOM) and the size of the array (${#p[@]}), “random” % “length of array”. Where % means mod, or remainder of the division. (examples: 7%4 = 3; 6%4 = 2; 5%4 = 1; 4 % 4 = 0; 4 % 3 = 1; 321%321= 0).
To illustrate more, play with this code:
r=$RANDOM; echo $r; echo $((r % 4))
This is how we get a random index value for the array. This value is nested inside the array ${p[r]}, where r is the random, within bounds, array index. That array then corresponds with a name of our profile and we pass it as a paramater to gnome-terminal with “–window-with-profile”. So using my define array above, if the random index were “1″, “Delta” would be echoed. If the index were “0″, Default would be.
The Setup
Now, I use compiz with the commands plugin, setting my “command line 0″ to ~/scripts/./gnome-terminal.sh and my “run command 0″ under my key bindings tab to ctrl+alt+t, but you can associate this script with anything you’d like to kick it off. A shortcut icon for example.
May this inspire you to understand, extend and share.
Some Issues I found with Dual Monitors in KDE
May 13th
Posted by Tyler Mulligan in Computers
I had originally made a thread on ubuntu forums essentially asking how to change the way kde or more specifically kwin treats dual monitors.
When trying out KDE 4.4, I was trying to establish a similar workflow to what I have in my GNOME/compiz setup. I use dual monitors and heavily use the expo compiz plugin (equivalent to kwin’s ‘desktop grid’). However, the behavior in KDE is a bit odd to me.
(not my video but gives you an idea about the effect, see below for how I lay mine out)
In compiz, I have 4 virtual desktops with dimensions that spanned both monitors.
[ ] | [ ]
In KDE however, each monitor is considered it’s own “activity” and as such, I have 8 virtual desktops
[ ][ ] | [ ][ ] [ ][ ] | [ ][ ]
This in and of itself isn’t all so bad. What bothers me however, is how they behave.
Labeling the virtual desktops..
[1][2] | [1][2] [3][4] | [3][4]
When I click virtual desktop [1] on the left monitor, [1] on the right monitor zooms with it. The behavior I’m used to in compiz would be to have both [1][2] on the left desktop zoom if I were to click [1].
Sure, this behavior “makes sense” knowing how KDE treats multiple monitors as separate activities but even after setting up matching desktop backgrounds on the monitors, I find it confusing to my workflow.
What’s more, is that KDE seems to know this is what I want… but ignores this fact when creating activities:

Has anyone come up with a clever solution to achieve this? I didn’t see anything about it planned for 4.5.
If it matters, I’m using twinview.