Author Archives: l3on

Use GTK-3.0 Dark variant theme for your GTK-2 terminal emulator

This is a workaround to force your preferred terminal emulator to use the Dark variant of Adwaita theme in GNOME >= 3.12 (maybe less, but untested).

Just add these lines to your ~/.bashrc file:

# set dark theme for xterm emulators
if [ "$TERM" == "xterm" ] ; then
 xprop -f _GTK_THEME_VARIANT 8u -set _GTK_THEME_VARIANT "dark" -id `xprop -root | awk '/^_NET_ACTIVE_WINDOW/ {print $5}'`
fi

This is how it works with Terminator:

Before

Before

After

After

Ubuntu Themes for GNOME 3.12

Ubuntu Themes with support for GNOME >= 3.12

Install:

sudo add-apt-repository ppa:l3on/ubuntu-themes-gnome-shell
sudo apt-get update
sudo apt-get install light-themes

Preview:

Ambiance_gnome-shell

Radiance_gnome-shell

For more info, check out lp:~l3on/ubuntu-themes/gnome-shell-fixes.

The patch was applied to the Ubuntu Themes development branch.
The GNOME environment comes from the gnome3-staging ppa.

apt-venv — apt virtual environment

Quickly collect information about packages in different Debian and Ubuntu releases.

apt-venv creates a sort of virtual environments in $HOME/.local/share/apt-venv (one for each release), able to exec bash sessions where apt thinks to be in another distro/release. In these sessions a $APT_VENV variable is set and points out the release name in use.

If you want to customize environment you can modify files in:

$HOME/.config/apt-venv/$release

apt-venv is already available in Debian and Ubuntu utopic unicorn.

Use case

Show which version of some package is in Debian and Ubuntu, simply:

# init apt database for releases
for release in unstable stable trusty lucid ; do
    apt-venv $release -u
done

# do what you want
for release in unstable stable trusty lucid ; do
    apt-venv $release -c "apt-cache madison base-files | grep Source | tail -1"
done

If you do not specify -c option you will entry an interactive shell.

Usage

$ apt-venv -h
usage: apt-venv [-h] [-D DEBUG] [-v] [-d] [-c COMMAND] [-l] [release]

positional arguments:
  release               the debian/ubuntu release

optional arguments:
  -h, --help            show this help message and exit
  -D DEBUG, --debug DEBUG
                        set debug level
  -v, --version         show program's version number and exit
  -c COMMAND, --command COMMAND
                        exec the given command instead of entry the interactive shell
  -d, --delete          delete venv for release
  -l, --list            list all venv installed in your system
  -u, --update          update the apt indexes

Fluxbox Light Themes

Fluxbox Light Themes is a porting of Ubuntu Themes for Fluxbox.

Install

You can choose to use this ppa or take directly the deb package.
Alternatively you can download the archive and install themes manually by copying Ambiance and Radiance into your local Fluxbox styles folder:

cp -r Ambiance ~/.fluxbox/styles
cp -r Radiance ~/.fluxbox/styles

Tips

Remember to update these settings in your ~/.fluxbox/init:

session.*.titlebar.left:    Close Minimize Maximize
session.*.titlebar.right:

Preview

Ambiance

Ambiance with menu

Radiance

Radiance with menu

Simple workaround to keep PC alive playing songs in Amarok and Gnome

During last months, I must confess, I got a new music player: Amarok.

Now, I would not fall in flame, but Rhythmbox seems still incomplete (and a bit bugged) if compared to Amarok. And, sadly, this is a fact, not an opinion (lol, and this is flame).

Anyway.. Amarok is not able to keep your PC alive when plays something, so if you set a hibernate time in gnome-settings you will see your PC going to sleep while you’re listening some song. And this is really bad..

This little script checks if Amarok is running (and it’s playing something as well) and set hibernate time to 0 (that means: no hibernate) in gnome-settings.

#!/bin/bash

# you MUST set this accoring with your QT installation
QDBUS=/usr/lib/x86_64-linux-gnu/qt4/bin/qdbus

# change these as you wish
# daemon time in seconds
TIME_DAEMON=10
# time to hibernate in seconds
TIME_HIBERNATE=600

# do not touch these
KEY=/org/gnome/settings-daemon/plugins/power/sleep-inactive-ac-timeout
QDBUS_CMD="org.mpris.MediaPlayer2.amarok /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlaybackStatus"

function amarok_on() {
  dconf write $KEY 0
}

function amarok_off() {
  dconf write $KEY $TIME_HIBERNATE
}

function check() {
  STATUS=`$QDBUS $QDBUS_CMD`
  if [ "$STATUS" == "Playing" ] ; then
    amarok_on
  else
    amarok_off
  fi
}

while `sleep $TIME_DAEMON` ; do check ; done

Obviously, you have to run this script when a gnome session starts (Startup applications).

Turning off/on display via cli/bash

This little script will help you to understand how to use xrandr to enable, disable and configure your second Display via bash:

#!/bin/bash

FIRST="HDMI-0"
SECOND="DVI-0"

BASECMD="xrandr --auto --output $SECOND"

MODE="--mode 1920x1080"
DIRECTION="--right-of $FIRST"
ROTATE="--rotate left"
OFF="--off"

function off() {
  $BASECMD $OFF
}

function on() {
  $BASECMD $MODE $DIRECTION $ROTATE
}

function usage() {
  echo "usage: $(basename $0) on|off"
}

case "$1" in
  on)   on 
  ;;
  off)  off 
  ;;
  *)    usage
  ;;
esac

Enjoy! :)

A smart way to use /tmp

I always loved use tmp directory to manage my “temporary files”. First of all, which files can be considered as “temporary”, and what does temporary exactly means? Well.. In my opinion, we can address as temporary all those files used only during a single Session. Such as:

  • files downloaded from browser – typically “to take a look or a single read”, they will never be opened again.
  • “text_files / notes / drafts / patches / etc..” – bound to be sent by email (and never used again).
  • “apt-get source” – do you use it? :)
  • many more … (pictures, samples, songs, backgrounds, code_branches, videos…)

If you use the standard $HOME/Downloads (or the Desktop, or Home or whatever_you_use) directory to locate all those files, you already know which kind of mess will be there in few days, unless you do not spend part of your time to delete those files no longer used. Looking for a solution to this I figured out that set /tmp directory (not really, but think about that) as my Download directory can be a good choice… It will be cleaned to each boot, so I can take no interest about files I download during a Session – and store only those I consider “important”, by moving to my “Downloads” (or “Documents”) directory. It can work, no? No. In fact that’s not all. I also love mount /tmp in Ram in order to speed up a bit the system… And place my downloads in /tmp can be dangerous for the system –  sometimes downloaded files can be bigger than we expect (try to think to a 20MB pdf). So, one of the best way (in my opinion) to have a clean “downloads” directory is create a local ~/tmp directory and use it as the default download directory for my Desktop and in the following lines I will show you how set it up.

Let’s start with mount /tmp in Ram, edit your /etc/fstab appending the lines below:

# RAM Disks
tmpfs /tmp tmpfs defaults 0 0

Next step, create a ~/tmp directory (or wherever you prefer) and set it as Downloads directory:

mkdir ~/tmp
xdg-user-dirs-update --set DOWNLOAD ~/tmp

Now create a script able to clean the directory to each login. I choose a file named ~/.initrc (you can use it to launch other applications, like conky). Use your preferred editor and insert the following lines:

#!/bin/bash
# Clean tmp dir:
find $HOME/tmp -mindepth 1 -delete &

Save the file and link it into yourStartup Applications” (search it through Unity), I use the following:

That’s all. My simple way to have a clean Home directory.

Forum ubuntu-it gets a new theme and a new engine

Hi all,

after many many weeks working on forum.ubuntu-it.org, we finally done!

The forum for ubuntu-it.org has been migrated from SMF 1.X (MySQL) to PhpBB3 (PSQL). The entire work has taken more than one month, considering the huge data (almost 5GB database) to migrate.

The new theme is inspired to the ubuntu-it website and ubuntu design guidelines, hope you like it.

 

Thanks to #canonical-sysadmin to help me in tuning psql, apache, php, etc… PphBB3 (default) is not so fast with big forums as I expected.