Outils pour utilisateurs

Outils du site


59:c_c

Two months ago I wrote about using SSH and Rsync. This month, I'd like to introduce you all to a trick I've recently started using for wirelessly syncing my android tablet, as well as outline a few other useful tricks I use, which others might find useful. Specifically, how to display a custom date in a foreign language (in Conky), how to spruce up your Vim interface (and PS1 prompt), and a script to randomly select an image for your background every 15 minutes. I realize that GNOME can probably take care of your backgrounds for you, but someone may still find a use for it. For anyone who wants an idea of the date and PS1 adjustments, check out this month's screenshot on my deviantart page (http://lswest.deviantart.com/#/d4se2tv) Android The things you'll need for this are as follows: On the Android device: QuickSSHd (as far as I remember, it's free). Once it's installed, simply check the IP address of the device, and give it a password/port. To start the server, hit the button that says “off” (so that it reads “on”). On your PC: sshfs, and a mount-point (preferably in your home folder) for the device.

Il y a deux mois, j'ai écrit sur l'utilisation de SSH et Rsync. Ce mois-ci, je voudrais vous présenter à tous un truc que j'ai récemment commencé à utiliser pour la synchronisation sans fil de ma tablette Android et décrire quelques autres trucs utiles que j'utilise, que d'autres pourraient trouver utiles. Plus précisément, comment afficher une date personnalisée dans une langue étrangère (dans Conky), comment embellir votre interface Vim (et votre prompt PS1) et un script pour choisir au hasard une image pour votre fond d'écran toutes les 15 minutes. Je me rends compte que GNOME peut probablement gérer vos fonds d'écran pour vous, mais d'aucuns peuvent toujours trouver un emploi pour ce script. Pour tous ceux qui veulent avoir une idée de la date et des ajustements PS1, consultez la capture d'écran de ce mois sur ma page deviantart (http://lswest.deviantart.com/#/d4se2tv).

Android

Les choses dont vous aurez besoin sont les suivantes :

Sur le périphérique Android : QuickSSHd (si je me souviens bien, c'est gratuit). Une fois qu'il est installé, il suffit de vérifier l'adresse IP de l'appareil et de lui donner un mot de passe et un port. Pour démarrer le serveur, cliquez sur le bouton « off » (afin qu'il passe à « on »).

Sur votre PC : sshfs et un point de montage (de préférence dans votre dossier personnel) pour le périphérique.

A brief explanation of the process: I simply mount the sdcard folder using sshfs, and then copy files over as I would using USB (which never worked very well for me and my Asus TF101 Transformer eeePad for media files). As for how to do this, see below. Mounting can be done with: sshfs root@127.0.0.1:/sdcard/ ~/tf101 -p 2222 Just like with rsync, you need to specify the path after a colon, and to avoid input/output errors on the mounted folder, you must have a closing slash at the end of the path. The second path is the mountpoint, and the -p 2222 is simply the port that QuickSSHd is listening on. After this, copy the files to the folder with whichever method you prefer. As an optional final step, I find that my Music app does not refresh after these files are added. The only way I've found to fix this is to go to the File Manager, and rename the copied file/folder, forcing the tablet to re-load the information.

Une brève explication du processus :

J'ai simplement monté le dossier sdcard en utilisant sshfs, puis copié les fichiers comme on le ferait en USB (qui n'a jamais vraiment fonctionné pour moi et mon Asus TF101 Transformer eeePad pour les fichiers multimédias). En ce qui concerne la façon de procéder, voir ci-dessous.

Le montage peut être fait avec :

sshfs root@127.0.0.1:/sdcard/ ~/tf101 -p 2222

Tout comme avec rsync, vous devez spécifier le chemin d'accès après les deux points et, pour éviter les erreurs d'entrée/sortie sur le dossier monté, vous devez mettre un slash de fermeture à la fin du chemin. Le deuxième chemin est le point de montage et le -p 2222 est tout simplement le port sur lequel écoute QuickSSHd.

Ensuite, copiez les fichiers dans le dossier avec la méthode que vous préférez.

Comme étape finale facultative, j'ai trouvé que mon application Musique ne s'actualisait pas après l'ajout de ces fichiers. La seule façon que j'ai trouvée pour résoudre ce problème est d'aller dans le gestionnaire de fichiers et renommer le fichier/dossier copié, forçant la tablette à re-charger l'information.

Custom date I've been learning Japanese for a while now, and decided to display the date in Japanese (both for practice, and to save space). However, it was not so easily done, as I use Conky for my status bar in XMonad. My solution to this is to write the following code-segment, which I call every few seconds from my conkyrc. You may need to run the following command to get the right formatting (this applies to any locale you may decide to use). locale-gen ja_JP.UTF-8 Code-segment: #!/bin/sh LC_ALL=“” LC_TIME=ja_JP.UTF-8 date +'%A, %-d日%B%Y年 %H:%M' You'll of course need to change the date format into the string you'd like (thoroughly documented in the man page).

Date personnalisée

J'apprends le japonais depuis un certain temps maintenant et j'ai décidé d'afficher la date en japonais (à la fois pour l'entrainement et pour économiser de l'espace). Cependant, ce n'était pas si facile à faire, car j'utilise Conky comme barre d'état dans XMonad. Ma solution pour cela est d'écrire le code suivant, que j'appelle toutes les quelques secondes dans mon conkyrc. Vous devrez peut-être exécuter la commande suivante pour obtenir la bonne mise en forme (ce qui s'applique à toute localisation que vous pouvez décider d'utiliser) :

locale-gen ja_JP.UTF-8

Code :

#!/bin/sh

LC_ALL=“” LC_TIME=ja_JP.UTF-8 date +'%A, %-d日%B%Y年 %H:%M'

Vous aurez, bien sûr, besoin de changer le format de date dans la chaîne selon ce que vous voulez (bien documenté dans la page de man).

Vim & PS1 (Powerline) Powerline homepage: https://github.com/Lokaltog/vim-powerline The easiest way to install Powerline is to use vundle. Instructions for installing Vundle are on the github page, here: http://github.com/gmarik/vundle. Once you've installed it, you'll need to add the following three lines to your .vimrc: set rtp+=~/.vim/bundle/vundle/ call vundle#rc() Bundle 'Lokaltog/vim-powerline' After which you'll need to open vim and type :InstallBundle (requires git to install) Once you've installed it, you'll need to patch the font you're using with the script found under the folder fontpatcher (full path will be something like ~/.vim/bundle/vim-powerline/fontpatcher). The readme file there will guide you through the patching.

Vim PS1 (Powerline) Page d'accueil Powerline: https://github.com/Lokaltog/vim-powerline

Le moyen le plus facile d'installer Powerline est d'utiliser vundle. Les instructions pour l'installation de Vundle sont sur la page github, ici: http://github.com/gmarik/vundle. Une fois que vous l'avez installé, vous devrez ajouter les trois lignes suivantes dans votre fichier .vimrc :

set rtp+=~/.vim/bundle/vundle/

call vundle#rc()

Bundle 'Lokaltog/vim-powerline'

Après cela vous devrez ouvrir vim et taper :InstallBundle (nécessite d'installer git).

Une fois que vous l'avez installé, vous devrez patcher la police que vous utilisez avec le script trouvé dans le dossier fontpatcher (le chemin d'accès complet sera quelque chose comme ~/.vim/bundle/vim-powerline/fontpatcher). Là, le fichier readme vous guidera pour patcher.

Once your font is patched (and your font-cache reloaded with the command fc-cache), you can add the final line to your .vimrc to get arrow shapes. let g:Powerline_symbols='fancy' If you find this to be something you want for your prompt as well, you simply need to make sure you're using the patched font, and copy the arrow from the vim line into your .bashrc prompt line, which I sadly can't supply, as it would require a patched font. Make sure you set the background behind the arrow glyph to the next color, and the foreground to the previous, to achieve the arrow appearance.

Une fois que votre police est corrigée (et votre cache de police rechargé avec la commande fc-cache), vous pouvez ajouter la dernière ligne à votre fichier .vimrc pour obtenir les flèches.

let g:Powerline_symbols='fancy'

Si vous trouvez que cela est aussi ce que vous voulez pour votre prompt, il vous suffit de vous assurer que vous utilisez la police corrigée et copier la flèche de la ligne de vim dans votre ligne de prompt dans .bashrc, que je ne peux malheureusement pas fournir, car il faudrait une police patchée. Assurez-vous de définir l'arrière-plan derrière le symbole de flèche à la couleur suivante et le premier plan à la précédente, pour obtenir l'apparence d'une flèche.

Wallpaper This script, as I have it written, requires fluxbox to be installed (for the fbsetbg program). However, if you know of a command-line wallpaper setter that offers a random option, feel free to replace it. The script: #!/bin/bash while true do fbsetbg -R ~/Pictures/Hyperion/Wallpapers/Guitars sleep 15m done The script runs in an infinite loop, calling the random command on my guitar wallpaper folder every 15 minutes. If anyone has any adjustments (or improvements upon the script), feel free to send me an email about it! Hopefully some of you will find some of these tips useful (and hopefully I've interested one or two readers into using Vim a bit more). If anyone has any questions, comments, or suggestions, I can be reached at lswest34@gmail.com. Any emails should include “C&C” or “FCM” in the subject line, so that I don't overlook it. Happy customizing!

Fond d'écran

Ce script, de la manière dont je l'ai écrit, nécessite d'installer fluxbox (pour le programme fbsetbg). Toutefois, si vous connaissez un gestionnaire de fond d'écran en ligne de commande qui offre une option aléatoire, n'hésitez pas à le remplacer.

Le script :

#!/bin/bash

while true

do

  fbsetbg -R ~/Pictures/Hyperion/Wallpapers/Guitars
  sleep 15m

done

Le script s'exécute dans une boucle infinie, appelant la commande aléatoire sur mon dossier de fond d'écran de guitares toutes les 15 minutes. Si quelqu'un a des ajustements (ou des améliorations sur le script), n'hésitez pas à m'envoyer un e-mail à ce sujet !

Espérons que certains d'entre vous y trouveront des conseils utiles (et j'espère avoir convaincu un ou deux lecteurs à utiliser un peu plus Vim). Si quelqu'un a des questions, des commentaires ou des suggestions, on peut me joindre à lswest34@gmail.com. Les e-mails doivent inclure « C&C » ou « FCM » dans la ligne Objet, de sorte que je ne l'ignore pas. Bonne personnalisation !

59/c_c.txt · Dernière modification : 2012/04/24 12:34 de papyjacques