Elric's random thoughts in idle times

"Why stop now, when I'm just starting to hate it?" – Marvin the robot

Archive for the ‘linux’ Category

Debian: script to manipulate apt sources quickly from the command line

with 5 comments

I’m one of those who just uses the command line to manage packages, and since I don’t use synaptic, it makes no sense to have the application ‘Software Preferences’ installed, which all in all pulls in a lot of packages.

But sometimes it’s tiresome to open an editor to enable or disable sources, or throw some sed command to change the line, which is anyway some typing. And it’s worse if you want to enable or disable several repositories at once.

So I created a bash script, aptsources (pretty unoriginal), to deal with repositories’ files under the directory ‘/etc/apt/sources.list.d/’. It doesn’t touch the file ‘/etc/apt/sources.list’ file at all, as it’s the file I edit the least. I have most Debian’s distributions entries uncommented (squeeze, sid, etc), with the use of apt-pinning.

The script allows to enable, disable, remove and add files under that directory. It also sets launchpad’s ppa repositories (Note and disclaimer: Ubuntu packages are not binary compatible!) with a syntax similar to add-apt-repository, allowing to set as an argument the Ubuntu version you think your Debian system is closer to. Thanks to Anant Shirvastava, as this function uses the code in his script. It also does backup, shows content, etc…

You can only specify one parameter a time, but some of them (--enable, --disable, --source) accept multiple arguments.

This is:

# aptsources --enable wine zeitgeist

would enable (uncomment) the ‘deb’ lines (not the ‘deb-src’ ones) in the files ‘wine.list’ and ‘zeitgeist.list’ at once.

One handy feature of the script is listing repos grouping them as enabled or disabled.

omar~$ aptsources -l
Enabled: cardapio docky multimedia synapse
Disabled: awn burg codeblocks getdeb hadret mpd-sound-menu notify-osd orta playdeb translate ufw-gtk vineyard wine zeitgeist

The script doesn’t run “exotic” commands, and it’s very easy to read. I stopped posting it here cause it got too big. You can download it from github. Click on the “Download” button and you will get a compressed archive with the latest version. You can install the script to ‘/usr/local/bin’ and bash-completion feature with aptsources.sh -i. I still enhance with small things so you better come back once or twice :)

Play with it and I hope it’s useful for more people than just me.

Enjoy!

Written by elric80

January 8, 2011 at 6:46 pm

Posted in debian, linux

Tagged with , , , , , ,

Using vim-addons and PO plugin

leave a comment »

I really like vim-addons. It provides a very convenient and quick way to install, enable, disable, and more, addons for Vim. You can do it per-user if you run without privileges (a link is created under ~/.vim, or system-wide. To work, it needs some data fields in a yaml file for every plugin. The package vim-scripts in Debian provides such file, so I just used that one.

By default, vim-addons searches for plugins under /usr/share/vim/addons, whereas the plugins provided by vim-scripts are located under /usr/share/vim-scripts. This means you can add any plugin under /addons with the knowledge that it won’t interfere with other vim-scripts.

The reason I did this is because I don’t like the PO plugin file provided with vim-scripts. I rather like its fork, which also includes documentation. This is the entry I created for it in /usr/share/vim/registry/vim-scripts.yaml. You can also create a new yaml file and place it under the same directory. I didn’t have to specify the field basedir, as I placed the files under vim/addons.

addon: po-fork
description: "Enhanced PO addon"
disabledby: "let loaded_alternateFile = 1"
files:
- ftplugin/po.vim
- doc/po.txt
---

This done, use vim-addons list to see all addons with a yaml file, and vim-addons install addon to activate it. Use vim-addons help to get an idea of what you can do with this program.

Enjoy!

Written by elric80

December 1, 2010 at 12:30 pm

Posted in debian, l10n, linux, vim

Tagged with , , , ,

Ncmpcpp config example

leave a comment »

Configuring ncmpcpp can be pretty hard, and I benefited from people who posted their config file. I’m just posting my current configuration, omitting the default configuration values present in the config file, which are commented. Here, you’ll only see what is different from the default config, as the config file is HUGE. I also deleted most comments, so you’ll need to open ncmpcpp’s example config file to see the comments and understand what’s going on.

The colors are simple (I use few), and look a bit like aptitude’s or my mutt’s color layout.

###############################################
## Omar config ##
####################################################
#
##### connection settings #####
#
## set it in order to make tag editor and renaming files work properly
#
mpd_host = "localhost"
#
mpd_port = "6600"
#
mpd_music_dir = "~/Music/"

# I had to set this to avoid a bug which slows down viewing artist's list
mpd_communication_mode = "polling" (polling/notifications)

##### music visualizer #####
##
## Note: In order to make music visualizer work you'll
## need to use mpd fifo output, whose format parameter
## has to be set to 44100:16:1. Example configuration:
## (it has to be put into mpd.conf)
## This is the simplest way to configure it. ncmpcpp has to
## be compiled with support for it.
visualizer_fifo_path = "/tmp/mpd.fifo"

## Note: To enable spectrum frequency visualization
## you need to compile ncmpcpp with fftw3 support.
##
#
visualizer_type = "spectrum" (spectrum/wave)

##### song format #####

song_list_format = "{%a - }{%t}|{$8%f$9}$R{$8(%l)$9}"

song_library_format = "{$4%n - }{%t}|{%f$9}"

media_library_album_format = "{%b}|$D"

## Note: Below variables are for alternative version of user's interface.
## Their syntax supports all tags and colors listed above plus some extra
## markers used for text attributes. They are followed by character '$'.
## After that you can put:

alternative_header_first_line_format = "$b$8$aqqu$/a {%t}|{%f} $atqq$/a$9$/b"
#
alternative_header_second_line_format = "{{$5$b%a$/b}{ - $b%b}{ (%y)}}|{%D$9}"

## Note: Below variables also supports
## text attributes listed above.

now_playing_prefix = "$b"

now_playing_suffix = "$/b"

selected_item_prefix = "$b"

selected_item_suffix = "$/b"

##### columns settings #####

song_columns_list_format = "(25)[blue]{a} (25)[white]{b} (40)[white]{t} (5)[yellow]{l}"

##### various settings #####

playlist_display_mode = "columns" (classic/columns)

browser_display_mode = "columns" (classic/columns)

incremental_seeking = "yes"

user_interface = "alternative" (classic/alternative)

header_visibility = "yes"

statusbar_visibility = "yes"

header_text_scrolling = "yes"

## How shall key_screen_switcher work?

screen_switcher_mode = "sequence: 2 -> 5"

## Note: You can define startup screen for ncmpcpp
## by choosing screen number from the list above.
##
startup_screen = "5"

clock_display_seconds = "yes"

display_bitrate = "yes"

empty_tag_marker = "----"

enable_window_title = "yes"

##### lyrics support #####
##
## supported lyrics databases:
##
## - 1 - lyricsplugin.com
##
#
lyrics_database = "1"
#
external_editor = "vim"

##### colors definitions #####

colors_enabled = "yes"

empty_tag_color = "red"

header_window_color = "cyan"

volume_color = "yellow"

main_window_color = "white"

color1 = "blue"

color2 = "white"

main_window_highlight_color = "blue"

progressbar_color = "blue"

statusbar_color = "yellow"

alternative_ui_separator_color = "blue"

active_column_color = "white"

window_border_color = "green"

active_window_border = "white"

This is an image showing the current layout and colors with this configuration.

Enjoy!

Written by elric80

November 25, 2010 at 1:53 pm

Posted in linux, music

Tagged with , , ,

Debian Squeeze nautilus-dropbox.deb i386 package

with 17 comments

Edit 2: Official Debian dropbox package on the way :) http://raphaelhertzog.com/2011/06/06/official-debian-ubuntu-packages-for-nautilus-dropbox/

Edit: The package nautilus-dropbox is now available in Hadret’s Debian PPA (among other interesting stuff). You might be better off using it.

If you are looking for the amd64 version, go here.

This is the nautilus-dropbox package built on Debian Squeeze i386.

nautilus-dropbox_0.6.3_i386.deb

It will call the real installation and that’s about it. Don’t be mistaken by the version number, it will download the latest version, just hover over the notification icon and you’ll see the real version. You can upgrade by just deleting the appropriate folder in your home directory.

Enjoy!

Written by elric80

October 6, 2010 at 1:31 pm

Posted in debian, gnome, linux

Tagged with , , , ,