Posts

Showing posts from 2012

obbrowser

Image
obbrowser is a very simple script which displays files and directories in the Openbox menu. It recursively browse the filesystem through openbox3 pipe menus. (related to  fbrowse-tray ) The following line needs to be added inside the menu.xml file:   <menu id="obbrowser /my/dir" label="Disk" execute="obbrowser"/> Or, if you are using the obmenu-generator , add the following line inside the schema.pl file:   {pipe => ['obbrowser /my/dir', 'Disk', 'drive-harddisk']}, The script supports a large variety of icons, thanks to  File::MimeInfo  module. Github:  https://github.com/trizen/obbrowser AUR link:  https://aur.archlinux.org/packages/obbrowser/ Simple version, in C++ :     https://github.com/trizen/cpp-learning/blob/master/Apps/openbox-pipefs.cpp Simpler version, in Go:      https://github.com/trizen/go-learning/blob/master/Apps/openbox-pipefs.go

alsi

Image
alsi is a system information tool, designed for Arch Linux, related to archey and screenfetch, but more configurable. All the configuration files are in:  ~/.config/alsi For example, to configure it for Gentoo, get the  gentoo logo  and put it in  alsi.logo  file, change something in  alsi.output  and  alsi.conf  files (if necessary) and then execute:  alsi -f -l -c1=blue -c2=purple Result: 1. Changing  alsi.output : my $ b = "\b\b\b\b" ; [ { HARDCODED => "\b\e[1;37m\e[41mTHIS IS ALSI\e[0m" } , { OS => $ b . '%13sOS:%s %s' } , # Operating system { HOSTNAME => $ b . '%4sHostname:%s %s' } , # Hostname { UPTIME => $ b . '%9sUptime:%s %s' } , # Uptime { KERNEL => $ b . '%9sKernel:%s %s' } , # Kernel version { SHELL => $ b . '%10sShell:%s %s' } , # Shell { PACKAGE

Binary search

Image
When we are looking in a sorted list, we are looking for which part of the list begins with the character we want. This technique can be implemented in Perl known as binary search, because we divide the list in two pieces after each look. We are starting in the middle of the list and we check if the current word is lower or greater than the word we are looking for. If it is lower, we are going in the middle of the bottom half of the list, if it is higher, we are going in the middle of the top half of the list, and we are continuing the process, dividing the list in halves until we find the word we are looking for, or we are out of the list. This process is faster than linear searching because we skip quite a lot of words in large arrays. The biggest drawn back is that the list must be sorted, but this is fine if we sort the array once and then we make multiple checks to see if some words exists inside the list. This algorithm is best suited to look for some lines in a very large a

Linux::DesktopFiles

Image
After a pretty long vacation, I'm back with some news :) I created this Perl module to use it for  menutray , fbmenugen and obmenu-generator . It requires the  Module::Build  for installation. It has been designed to be very fast and pretty easy to use. It parses the *.desktop files and returns a Perl data structure with the information required. It offers many configuration options (see the man page or the source code). It works only on Linux with a version of perl>=5.14.0; Download:  https://metacpan.org/module/Linux::DesktopFiles

file-monitor

Image
file-monitor is a simple Perl script to monitor a directory path for new files, updated files and deleted files. It can be set to look for new files in a given interval of seconds (e.g.: -n 30) and also can be set to check for updated and deleted files in another interval of seconds (e.g.: -c 12) Download:  https://github.com/trizen/perl-scripts/blob/master/Monitoring/file-monitor

Expanding a string

Image
The problem: We have a string like this: my $ str = 'perl-{file-{which,basedir,copy-recursive},pathtools,path-class}' ; ... and we need to expand it into: ( 'perl-file-which' , 'perl-file-basedir' , 'perl-file-copy-recursive' , 'perl-pathtools' , 'perl-path-class' , ) Solutions: One-line solution:  split q{ } , qx(echo $string) ; Go:  https://github.com/trizen/go-learning/blob/master/abs_string.go Perl:  https://github.com/trizen/perl-scripts/blob/master/Text/abs_string.pl Sidef:  https://github.com/trizen/sidef/blob/master/scripts/absolute_string.sf Sidef:  https://github.com/trizen/sidef-scripts/blob/master/Text/shell_string_expand.sf

GD::Simple

Image
GD::Simple is a simple interface to the GD  library, which is an open source code library used in dynamic creation of images by programmers. If you like math, this library will bring a lot of fun in your life. :) Images :  https://goo.gl/photos/6n1KzxZNxW6tTsxe8 Scripts :  https://github.com/trizen/perl-scripts/tree/master/GD

YouTube Viewer

Image
# GTK YouTube Viewer This application came to life in 12 September 2010 as my first GTK2/Glade learning project. gtk-youtube-viewer Its scope is to search and play YouTube videos in a native player.  It comes with various search options; it can search for videos, playlists and/or channels. The videos are streamed directly in a selected video player at the best resolution (customizable) and with closed-captions (if available). By default, the application supports three video players: MPV (recommended), MPlayer and VLC, but it allows the addition of more players inside the configuration file. For a better experience, the application also comes with built-in authentication support, using the OAuth 2.0 mechanism. After inserting the authentication token, a new tab will appear, named "My panel", which has the following buttons: Subscriptions Favorited videos Liked videos Disliked videos Uploads Playlists Log out For more details (+screenshots), see also:

obmenu-generator

Image
obmenu-generator  is a simple, lightweight, easily configurable Perl script that generates a full Openbox XML-menu based upon the information present in *.desktop application files (related to  fbmenugen  and  menutray ). It has full support for icons (respecting the current icon theme) and can generate either a static or a dynamic menu. The parsing of the *.desktop files is provided by the Linux::DesktopFiles module. In a dynamic menu, the entries are updated automatically when a new application is installed or when the current icon theme is changed by the user. Starting with version 0.61, obmenu-generator introduced a new smart-cache system which will store all the required data from the *.destkop files in a new cache.db file, which is also updated automatically when a new application is (re)installed or when the config.pl  or schema.pl are changed. With the new cache-system in place, a full menu with icons is generated in ~8ms (compared to ~60ms before). In versi

fbmenugen

Image
fbmenugen is a simple menu generator for the Fluxbox WM (related to  menutray  and  obmenu-generator ). It generates a valid Fluxbox menu file with the applications from the /usr/share/applications  directory, ordered on categories. It also provides a configuration file that allows the user to customize the menu. Github:  https://github.com/trizen/fbmenugen AUR Link:  https://aur.archlinux.org/packages/fbmenugen/

menutray

Image
Menutray is a simple menu generator (related to obmenu-generator  and  fbmenugen ). It generates a Perl script containing all the applications from the /usr/share/applications directory, ordered on categories. It also provides a schema file for customization. Starting with version 0.42, menutray supports Gtk3 with the  --gtk3 option . Github :  https://github.com/trizen/menutray AUR Link :  https://aur.archlinux.org/packages/menutray/

locatepm

Image
Find installed Perl modules matching a regular expression. It's very fast and efficient. Download : https://github.com/trizen/perl-scripts/blob/master/Finders/locatepm