Uzbl-tabbed, mon nouveau navigateur hors développement, scripts

J'utilise à présent Uzbl-tabbed comme navigateur (hormis quand je fais du développement web). Il fonctionne à merveille, sans compter l'incroyable facilité de personnalisation.

Voici quelques éléments de ma configuration :

Clique molette : ouverture dans un onglet
@bind  <Button2>  = sh 'if [ "$1" ]; then echo "event NEW_TAB $1" > "$UZBL_FIFO"; else echo "uri $(xclip -o | sed s/\\\@/%40/g)" > "$UZBL_FIFO"; fi' '\@SELECTED_URI'
Divers binds
@cbind <Ctrl>n = event REQ_NEW_WINDOW # nouvelle fenêtre
@cbind <Ctrl>r = reload # rechargement
@cbind <Ctrl>R = reload_ign_cache # rechargement sans cache
@cbind <Mod1>b = back # précédent
@cbind <Mod1>n = forward  suivant 
@cbind <Ctrl>w = exit # fermerture d'onglet/fenêtre

@on_event NEW_WINDOW  sh 'uzbl-tabbed "$1"' %r
@cbind  clone = event REQ_NEW_WINDOW \@uri # copie de fenêtre/fenêtre
Gestion de bookmarks avec des tags

Ce script est un hack de celui présent sur le site d'Uzbl.

  • Emplacement : @scripts_dir/bookmark_with_tags_for_folders.sh
  • Bind : @cbind <Ctrl>d = spawn @scripts_dir/bookmark_with_tags_for_folders.sh
#!/bin/bash
# @scripts_dir/bookmark_with_tags_for_folders.sh
#NOTE: it's the job of the script that inserts bookmarks to make sure there are no dupes.

file=${XDG_DATA_HOME:-$HOME/.local/share}/uzbl/bookmarks

[ -r "$file" ] || exit

DMENU_SCHEME="bookmarks"
DMENU_OPTIONS="xmms vertical resize"

. "$UZBL_UTIL_DIR/dmenu.sh"
. "$UZBL_UTIL_DIR/uzbl-dir.sh"

TAG=`cat $file | cut -d" " -f2 | sort -u | $DMENU -nb \#303030 -nf khaki -sb \#CCFFAA -sf \#303030`

goto=`grep $TAG $file | cut -d" " -f1,3- | while read url name; do [ -z "\$name" ] || name="\$name "; echo "\$name: $url"; done | $DMENU $COLORS | cut -d":" -f2-`

[ -n "$goto" ] && echo "uri $goto" > "$UZBL_FIFO"
Le contrôle+L de Firefox
  • Emplacement : @scripts_dir/prompt_url.sh
  • Bind : @cbind <Ctrl>l = spawn @scripts_dir/prompt_url.sh
#!/bin/sh

goto=$(zenity --entry --text "$UZBL_TITLE" --entry-text "$UZBL_URI" --title "$UZBL_TITLE")

if [ $? -eq 0 ]; then
	echo "uri $goto" > "$UZBL_FIFO"	
fi
Le contrôle+K de Firefox
  • Emplacement : @scripts_dir/prompt_search.sh
  • Bind : @cbind <Ctrl>k = spawn @scripts_dir/prompt_search.sh
#!/bin/sh

search=$(zenity --entry --text "Effectuer une recherche" --entry-text "" --title "UZBL : Effectuer une recherche")

if [ $? -eq 0 ]; then
	echo "uri http://www.google.fr/search?q=$(echo "$search" | sed 's/ /%20/g')" > "$UZBL_FIFO"	
fi
Gestion du zoom à la Firefox (contenu + conteneur)
Binds :
@cbind <Ctrl>i         = js (function() { var event = document.createEvent('HTMLEvents'); event.initEvent('uzbl_zoom_in', true, true); document.dispatchEvent(event); } )();
@cbind <Ctrl><Shift>I  = js (function() { var event = document.createEvent('HTMLEvents'); event.initEvent('uzbl_zoom_out', true, true); document.dispatchEvent(event); } )();
@cbind <Ctrl>à         = js (function() { var event = document.createEvent('HTMLEvents'); event.initEvent('uzbl_zoom_init', true, true); document.dispatchEvent(event); } )();

@on_event   LOAD_COMMIT    script @scripts_dir/zoom.js

Dans @scripts_dir/zoom.js :

function get_cookie(name) {
	var dc = document.cookie;
	var prefix = name + '=';
	var begin = dc.indexOf('; ' + prefix);

	if (begin == -1) {
		begin = dc.indexOf(prefix);

		if (begin!= 0) {
			return null;
		}

	} 
	else {
		begin += 2;
	}

	var end = document.cookie.indexOf(';', begin);

	if (end == -1) {
		end = dc.length;
	}

	return unescape(dc.substring(begin + prefix.length, end));
}

var step = function()
{
	return 0.1;
}

var get_body = function()
{
	var body = document.getElementsByTagName('body');

	return body ? body[0] : null;
}

var get_body_zoom = function()
{
	return get_body().getAttribute('data-zoom') ? parseFloat(get_body().getAttribute('data-zoom')) : 1;
}

var set_body_zoom = function(zoom)
{
	get_body().setAttribute('data-zoom', zoom);
	get_body().style.zoom = zoom;
	document.cookie='uzbl_zoom='+zoom+';path=/;expires=Tue, 2 Jun 2020 00:00:00 UTC;'	
}

var zoom_in = function()
{
	set_body_zoom(get_body_zoom() + step());
}

var zoom_out = function()
{
	set_body_zoom(get_body_zoom() - step());
}

var zoom_init = function()
{
	set_body_zoom(1);
}

var zoom_retrieve = function()
{
	var zoom = get_cookie('uzbl_zoom');

	if (zoom) {
		set_body_zoom(zoom);
	}
}

document.addEventListener('uzbl_zoom_in', zoom_in, true);
document.addEventListener('uzbl_zoom_out', zoom_out, true);
document.addEventListener('uzbl_zoom_init', zoom_init, true);
document.addEventListener('DOMContentLoaded', zoom_retrieve, true);

J'espère que ça vous sera utile :)

Simon Vieille

[TIPS] Rocketchat : désactiver SSL sans l'interface d'administration

[TIPS] Rocketchat : désactiver SSL sans l'interface d'administration

C'est en testant le logiciel franz, un outil qui permet de centraliser les clients web de pa…

Capture, un reverse proxy pour analyser les requêtes de vos applications

Capture, un reverse proxy pour analyser les requêtes de vos applications

Capture est un reverse proxy HTTP qui se place entre votre application cliente et une API. C…

Un modèle pour démarrer un script shell

Un modèle pour démarrer un script shell

J'ai régulièrement le besoin d'écrire des scripts shell un peu évolués. Il y a quelques mois…


Ajouter un commentaire

Votre commentaire - Vous pouvez utiliser du markdown

Renouveler