move html papers to md

This commit is contained in:
arcan1s
2016-01-24 15:41:28 +03:00
parent 28dd83b280
commit 4c9ff17bf0
57 changed files with 2815 additions and 3184 deletions

View File

@ -6,32 +6,37 @@ hastr: true
tags: zshrc, configuration, linux
title: About zshrc
short: about-zshrc
description: It is first paper in my blog (I think I need something here for tests =)). There are many similar articles, and I'll not be an exception. I just want to show my <code>.zshrc</code> and explain what it does and why it is needed. Also any comments or additions are welcome. It is a translated paper from Russian (<a href="//archlinux.org.ru/forum/topic/12752/" title="Forum thread">original</a>).
---
<h2><a href="#prepare" class="anchor" id="prepare"><span class="octicon octicon-link"></span></a>Prepare</h2>
<p>First install recommended minima:</p>
It is first paper in my blog (I think I need something here for tests =)). There are many similar articles, and I'll not be an exception. I just want to show my `.zshrc` and explain what it does and why it is needed. Also any comments or additions are welcome. It is a translated paper from Russian ([original](//archlinux.org.ru/forum/topic/12752/ "Forum thread")).
{% highlight bash %}
<!--more-->
## <a href="#prepare" class="anchor" id="prepare"><span class="octicon octicon-link"></span></a>Prepare
First install recommended minima:
```bash
pacman -Sy pkgfile zsh zsh-completions zsh-syntax-highlighting
{% endhighlight %}
```
<p><a href="//www.archlinux.org/packages/pkgfile/" title="Archlinux package">pkgfile</a> is a very useful utility. Also this command will install shell, additional completion and syntax highlighting.</p>
[pkgfile](//www.archlinux.org/packages/pkgfile/ "Archlinux package") is a very useful utility. Also this command will install shell, additional completion and syntax highlighting.
<h2><a href="#configuration" class="anchor" id="configuration"><span class="octicon octicon-link"></span></a>Shell configuration</h2>
<p>All options are avaible <a href="//zsh.sourceforge.net/Doc/Release/Options.html" title="zsh documentation">here</a>.</p>
## <a href="#configuration" class="anchor" id="configuration"><span class="octicon octicon-link"></span></a>Shell configuration
<p>Set history file and number of commands in cache of the current session and in the history file:</p>
All options are avaible [here](//zsh.sourceforge.net/Doc/Release/Options.html "zsh documentation").
{% highlight bash %}
Set history file and number of commands in cache of the current session and in the history file:
```bash
# history
HISTFILE=~/.zsh_history
HISTSIZE=500000
SAVEHIST=500000
{% endhighlight %}
```
<p>I can not remember all <code>Ctrl+</code> combinations so I bind keys to its default usages:</p>
I can not remember all `Ctrl+` combinations so I bind keys to its default usages:
{% highlight bash %}
```bash
# bindkeys
bindkey '^[[A' up-line-or-search # up arrow for back-history-search
bindkey '^[[B' down-line-or-search # down arrow for fwd-history-search
@ -41,106 +46,106 @@ bindkey '\e[3~' delete-char # del
bindkey '\e[4~' end-of-line # end
bindkey '\e[5~' up-line-or-history # page-up
bindkey '\e[6~' down-line-or-history # page-down
{% endhighlight %}
```
<p>But in this case <code>Up</code>/<code>Down</code> arrows are used to navigate through the history based on <b>already entered part</b> of a command. And <code>PgUp</code>/<code>PgDown</code> <b>will ignore</b> already entered part of a command.</p>
But in this case `Up`/`Down` arrows are used to navigate through the history based on **already entered part** of a command. And `PgUp`/`PgDown` **will ignore** already entered part of a command.
<p>Command autocomplete:</p>
Command autocomplete:
{% highlight bash %}
```bash
# autocomplete
autoload -U compinit
compinit
zstyle ':completion:*' insert-tab false
zstyle ':completion:*' max-errors 2
{% endhighlight %}
```
<p>Full command autocomplete will be enabled. <code>insert-tab false</code> will enable autocomplete for <b>non-entered</b> commands. <code>max-errors</code> sets maximum number of errors that could be corrected.</p>
Full command autocomplete will be enabled. `insert-tab false` will enable autocomplete for **non-entered** commands. `max-errors` sets maximum number of errors that could be corrected.
<p>Prompt:</p>
Prompt:
{% highlight bash %}
```bash
# promptinit
autoload -U promptinit
promptinit
{% endhighlight %}
```
<p>Enable colors:</p>
Enable colors:
{% highlight bash %}
```bash
# colors
autoload -U colors
colors
{% endhighlight %}
```
<p>Here are some other options.</p>
<p>Change directory without <code>cd</code>:</p>
Here are some other options.
Change directory without `cd`:
{% highlight bash %}
```bash
# autocd
setopt autocd
{% endhighlight %}
```
<p>Correcting of typos (and question template):</p>
Correcting of typos (and question template):
{% highlight bash %}
```bash
# correct
setopt CORRECT_ALL
SPROMPT="Correct '%R' to '%r' ? ([Y]es/[N]o/[E]dit/[A]bort) "
{% endhighlight %}
```
<p>Disable f#$%ing beep:</p>
Disable f#$%ing beep:
{% highlight bash %}
```bash
# disable beeps
unsetopt beep
{% endhighlight %}
```
<p>Enable calculator:</p>
Enable calculator:
{% highlight bash %}
```bash
# calc
autoload zcalc
{% endhighlight %}
```
<p>Append history (<b>do not recreate</b> the history file):</p>
Append history (**do not recreate** the history file):
{% highlight bash %}
```bash
# append history
setopt APPEND_HISTORY
{% endhighlight %}
```
<p>Do not save dups to history file:</p>
Do not save dups to history file:
{% highlight bash %}
```bash
# ignore spaces in history
setopt HIST_IGNORE_ALL_DUPS
{% endhighlight %}
```
<p>...and additional spaces:</p>
...and additional spaces:
{% highlight bash %}
```bash
# ignore dups in history
setopt HIST_IGNORE_SPACE
{% endhighlight %}
```
<p>...and blank lines too:</p>
...and blank lines too:
{% highlight bash %}
```bash
# reduce blanks in history
setopt HIST_REDUCE_BLANKS
{% endhighlight %}
```
<p>Enable <code>pkgfile</code>:</p>
Enable `pkgfile`:
{% highlight bash %}
```bash
# pkgfile
source /usr/share/doc/pkgfile/command-not-found.zsh
{% endhighlight %}
```
<h2><a href="#highlighting" class="anchor" id="highlighting"><span class="octicon octicon-link"></span></a>Syntax highlighting</h2>
## <a href="#highlighting" class="anchor" id="highlighting"><span class="octicon octicon-link"></span></a>Syntax highlighting
{% highlight bash %}
```bash
# highlighting
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)
@ -185,14 +190,15 @@ ZSH_HIGHLIGHT_STYLES[double-quoted-argument]='fg=yellow'
#ZSH_HIGHLIGHT_PATTERNS+=('rm -rf *' 'fg=white,bold,bg=red')
# root example
#ZSH_HIGHLIGHT_STYLES[root]='bg=red'
{% endhighlight %}
```
<p>In first line highlighting is turned on. Next main, brackets and pattern highlighting are turned on. Patterns are set below (<code>rm -rf *</code> in the example). Also <code>root</code> and <code>cursor</code> highlighting may be turned on. Colors syntax is understandable, <code>fg</code> is font color, <code>bg</code> is background color.</p>
In first line highlighting is turned on. Next main, brackets and pattern highlighting are turned on. Patterns are set below (`rm -rf *` in the example). Also `root` and `cursor` highlighting may be turned on. Colors syntax is understandable, `fg` is font color, `bg` is background color.
<h2><a href="#prompt" class="anchor" id="prompt"><span class="octicon octicon-link"></span></a>$PROMPT and $RPROMPT</h2>
<p>The general idea is the use single <code>.zshrc</code> for root and normal user:</p>
## <a href="#prompt" class="anchor" id="prompt"><span class="octicon octicon-link"></span></a>$PROMPT and $RPROMPT
{% highlight bash %}
The general idea is the use single `.zshrc` for root and normal user:
```bash
# PROMPT && RPROMPT
if [[ $EUID == 0 ]]; then
# [root@host dir]#
@ -211,11 +217,11 @@ else
%{$fg_bold[yellow]%}%1/%{$reset_color%}\
%{$fg_bold[white]%}]$ %{$reset_color%}"
fi
{% endhighlight %}
```
<p><code>fg</code> is font color, <code>bg</code> is background color. <code>_bold</code> and <code>_no_bold</code> regulate the tint. Commands should be in <code>%{ ... %}</code> so they do not appear. Avaible colors are:</p>
`fg` is font color, `bg` is background color. `_bold` and `_no_bold` regulate the tint. Commands should be in `%{ ... %}` so they do not appear. Avaible colors are:
{% highlight bash %}
```bash
black
red
green
@ -224,11 +230,11 @@ blue
magenta
cyan
white
{% endhighlight %}
```
<p>Avaible variables are:</p>
Avaible variables are:
{% highlight bash %}
```bash
%n - the username
%m - the computer's hostname (truncated to the first period)
%M - the computer's hostname
@ -241,11 +247,11 @@ white
%d - the current working directory
%~ - the same as %d but if in $HOME, this will be replaced by ~
%1/ - the same as %d but only last directory
{% endhighlight %}
```
<p>RPROMPT (<code>acpi</code> package is necessary):</p>
RPROMPT (`acpi` package is necessary):
{% highlight bash %}
```bash
precmd () {
# battery charge
function batcharge {
@ -268,25 +274,26 @@ $(batcharge)\
"%{$fg_bold[white]%}[%{$reset_color%}"\
$returncode\
"%{$fg_bold[white]%}]%{$reset_color%}"
{% endhighlight %}
```
<p>My RPROMPT shows current time, battery change and last returned code. <code>precmd()</code> is necessary for automatic updating. The construct <code>$(if.true.false)</code> is conditional statement in <code>zsh</code>.</p>
My RPROMPT shows current time, battery change and last returned code. `precmd()` is necessary for automatic updating. The construct `$(if.true.false)` is conditional statement in `zsh`.
<h2><a href="#aliases" class="anchor" id="aliases"><span class="octicon octicon-link"></span></a>Aliases</h2>
<p><b>Copy only those aliases that you need.</b> If any alias uses application that is not installed it will leads to fail of loading of configuration file.</p>
## <a href="#aliases" class="anchor" id="aliases"><span class="octicon octicon-link"></span></a>Aliases
<p>Small useful (or maybe not) function:</p>
**Copy only those aliases that you need.** If any alias uses application that is not installed it will leads to fail of loading of configuration file.
{% highlight bash %}
Small useful (or maybe not) function:
```bash
show_which() {
OUTPUT=$(which $1 | cut -d " " -f7-)
echo "Running '$OUTPUT'" 1>&2
}
{% endhighlight %}
```
<p>Here is the first group of aliases:</p>
Here is the first group of aliases:
{% highlight bash %}
```bash
## alias
# colored grep
alias grep='grep --colour=auto'
@ -302,11 +309,11 @@ alias du='show_which du && du -k --total --human-readable'
# change less and zless to vimpager
alias less='vimpager'
alias zless='vimpager'
{% endhighlight %}
```
<p>Here are ls aliases (see <a href="//unixhelp.ed.ac.uk/CGI/man-cgi?ls" title="Man page">man ls</a>):</p>
Here are ls aliases (see [man ls](//unixhelp.ed.ac.uk/CGI/man-cgi?ls "Man page")):
{% highlight bash %}
```bash
alias ls='show_which ls && ls --color=auto --group-directories-first'
alias ll='show_which ll && ls -l --human-readable'
alias lr='show_which lr && ls --recursive'
@ -315,11 +322,11 @@ alias lx='show_which lx && ll -X --ignore-backups'
alias lz='show_which lz && ll -S --reverse'
alias lt='show_which lt && ll -t --reverse'
alias lm='show_which lm && la | more'
{% endhighlight %}
```
<p>Here are aliases to quick file view from console (just type a file name!):</p>
Here are aliases to quick file view from console (just type a file name!):
{% highlight bash %}
```bash
# alias -s
alias -s {avi,mpeg,mpg,mov,m2v,mkv}=mpv
alias -s {mp3,flac}=qmmp
@ -327,11 +334,11 @@ alias -s {odt,doc,xls,ppt,docx,xlsx,pptx,csv}=libreoffice
alias -s {pdf}=okular
autoload -U pick-web-browser
alias -s {html,htm}=opera
{% endhighlight %}
```
<p>Here are "sudo" aliases:</p>
Here are "sudo" aliases:
{% highlight bash %}
```bash
# sudo alias
if [[ $EUID == 0 ]]; then
alias fat32mnt='show_which fat32mnt && mount -t vfat -o codepage=866,iocharset=utf8,umask=000'
@ -351,23 +358,24 @@ else
alias staging-i686-build='show_which staging-i686-build && sudo staging-i686-build'
alias staging-x86_64-build='show_which staging-x86_64-build && sudo staging-x86_64-build'
fi
{% endhighlight %}
```
<p>Here are global aliases. If they are enable the command <code>cat foo g bar</code> will be equivalent the command <code>cat foo | grep bar</code>:</p>
Here are global aliases. If they are enable the command `cat foo g bar` will be equivalent the command `cat foo | grep bar`:
{% highlight bash %}
```bash
# global alias
alias -g g="| grep"
alias -g l="| less"
alias -g t="| tail"
alias -g h="| head"
alias -g dn="&> /dev/null &"
{% endhighlight %}
```
<h2><a href="#functions" class="anchor" id="functions"><span class="octicon octicon-link"></span></a>Functions</h2>
<p>Here is a special function for <code>xrandr</code>:</p>
## <a href="#functions" class="anchor" id="functions"><span class="octicon octicon-link"></span></a>Functions
{% highlight bash %}
Here is a special function for `xrandr`:
```bash
# function to contorl xrandr
# EXAMPLE: projctl 1024x768
projctl () {
@ -388,11 +396,11 @@ projctl () {
xrandr --output VGA1 --mode 1366x768 --output LVDS1 --mode 1366x768
fi
}
{% endhighlight %}
```
<p>Unfortunately I can not remember <code>tar</code> flags thus I use special functions:</p>
Unfortunately I can not remember `tar` flags thus I use special functions:
{% highlight bash %}
```bash
# function to extract archives
# EXAMPLE: unpack file
unpack () {
@ -442,11 +450,11 @@ pack () {
echo "'$1' is not a valid file"
fi
}
{% endhighlight %}
```
<p>Here is a special function for <code>su</code>:</p>
Here is a special function for `su`:
{% highlight bash %}
```bash
su () {
CHECKSU=0
for FLAG in $*; do
@ -461,11 +469,11 @@ su () {
/usr/bin/su $*
fi
}
{% endhighlight %}
```
<p>Function that replaces original <code>rm</code> command. If you type <code>rm</code> it will be equivalent moving to trash an you can easily restore a file:</p>
Function that replaces original `rm` command. If you type `rm` it will be equivalent moving to trash an you can easily restore a file:
{% highlight bash %}
```bash
rm () {
# error check
[ $# -eq 0 ] && { echo "Files are not set!"; return 1 }
@ -505,11 +513,11 @@ rm () {
fi
done
}
{% endhighlight %}
```
<p>Functions with automatic rehash after installing/removing packages are:</p>
Functions with automatic rehash after installing/removing packages are:
{% highlight bash %}
```bash
pacman () {
/usr/bin/sudo /usr/bin/pacman $* && echo "$*" | grep -q "S\|R\|U" && rehash
}
@ -520,14 +528,15 @@ yaourt () {
yatest () {
/usr/bin/yaourt --config /etc/pactest.conf $* && echo "$*" | grep -q "S\|R\|U" && rehash
}
{% endhighlight %}
```
<h2><a href="#variables" class="anchor" id="variables"><span class="octicon octicon-link"></span></a>Variables</h2>
<p>It is recommended to set own variables in <code>~/.zshenv</code>. But I have everything stored in the single file.</p>
## <a href="#variables" class="anchor" id="variables"><span class="octicon octicon-link"></span></a>Variables
<p>Here are path, mask of new files, editor and pager:</p>
It is recommended to set own variables in `~/.zshenv`. But I have everything stored in the single file.
{% highlight bash %}
Here are path, mask of new files, editor and pager:
```bash
# path
export PATH="$PATH:$HOME/.local/bin"
# umask
@ -535,25 +544,27 @@ umask 022
# editor
export EDITOR="vim"
export PAGER="vimpager"
{% endhighlight %}
```
<p>Here is hashes. If they are enable the command <code>~global</code> will be equivalent the command <code>/mnt/global</code>:</p>
Here is hashes. If they are enable the command `~global` will be equivalent the command `/mnt/global`:
{% highlight bash %}
```bash
# hash
hash -d global=/mnt/global
hash -d windows=/mnt/windows
hash -d iso=/mnt/iso
hash -d u1=/mnt/usbdev1
hash -d u2=/mnt/usbdev
{% endhighlight %}
```
## <a href="#screenshot" class="anchor" id="screenshot"><span class="octicon octicon-link"></span></a>Screenshot
<h2><a href="#screenshot" class="anchor" id="screenshot"><span class="octicon octicon-link"></span></a>Screenshot</h2>
<div class="thumbnails">
{% assign scrdesc = "Zsh demonstation" %}
{% assign scrname = "zshrc_demo" %}
{% include prj_scr.html %}
</div>
<h2><a href="#file" class="anchor" id="file"><span class="octicon octicon-link"></span></a>File</h2>
<p><a href="//raw.github.com/arcan1s/dotfiles/master/zshrc" title="GitHub" type="text/plain">Here is</a> my <code>.zshrc</code>.</p>
## <a href="#file" class="anchor" id="file"><span class="octicon octicon-link"></span></a>File
[Here is](//raw.github.com/arcan1s/dotfiles/master/zshrc "GitHub") my `.zshrc`.

View File

@ -6,37 +6,43 @@ hastr: true
tags: archlinux, linux, building, qutim
title: Building Qutim using Qt5
short: building-qutim-using-qt5
description: <a href="//qutim.org" title="Qutim Homepage">Qutim</a> is a multiprotocol and cross platform messenger. It is written on <code>CPP</code> using Qt library. The project is actively developed. In this paper I will say about building this package in Archlinux using Qt5 library (instead of Qt4 which is used in current AUR packages).
---
<h2><a href="#problems" class="anchor" id="problems"><span class="octicon octicon-link"></span></a>What's wrong?</h2>
<p>This package uses <a href="//qt-project.org/wiki/qbs" title="Wiki">qbs</a> for building, which is a bit strange IMHO. A package, which is necessary for building, is <a href="//aur.archlinux.org/packages/qbs-git/" title="AUR">in AUR </a>. I recommend to use git version of the package. When I asked Andrea Scarpino (who maintains KDE and Qt packages into the official repos) about qbs, he told me "we will support it in time". And I agree with him, the project seems to be a little unstable.</p>
[Qutim](//qutim.org) is a multiprotocol and cross platform messenger. It is written on `CPP` using Qt library. The project is actively developed. In this paper I will say about building this package in Archlinux using Qt5 library (instead of Qt4 which is used in current AUR packages).
<h2><a href="#prepare" class="anchor" id="prepare"><span class="octicon octicon-link"></span></a>Prepare</h2>
<p>Install dependences. I had used <code>namcap</code>, so maybe I missed something:</p>
<!--more-->
{% highlight bash %}
# <a href="#problems" class="anchor" id="problems"><span class="octicon octicon-link"></span></a>What's wrong?
This package uses [qbs](//qt-project.org/wiki/qbs "Wiki") for building, which is a bit strange IMHO. A package, which is necessary for building, is [in AUR](//aur.archlinux.org/packages/qbs-git/ "AUR") . I recommend to use git version of the package. When I asked Andrea Scarpino (who maintains KDE and Qt packages into the official repos) about qbs, he told me "we will support it in time". And I agree with him, the project seems to be a little unstable.
# <a href="#prepare" class="anchor" id="prepare"><span class="octicon octicon-link"></span></a>Prepare
Install dependences. I had used `namcap`, so maybe I missed something:
```bash
pacman -Sy --asdeps clang git libc++abi qt5-quick1 qt5-x11extras
yaourt -S --asdeps jreen-git qbs-git
{% endhighlight %}
```
<h3><a href="#qbs" class="anchor" id="qbs"><span class="octicon octicon-link"></span></a>qbs settings</h3>
<p>You may read about qbs <a href="//qt-project.org/wiki/qbs" title="Wiki">on the link</a> or see examples which are provides by the package. qbs uses configuration file that firstly you must create and secondly it is stored in your home directory. In theory a configuration file creating ((<code>~/.config/QtProject/qbs.conf</code>)) looks like this:</p>
### <a href="#qbs" class="anchor" id="qbs"><span class="octicon octicon-link"></span></a>qbs settings
{% highlight bash %}
You may read about qbs [on the link](//qt-project.org/wiki/qbs "Wiki") or see examples which are provides by the package. qbs uses configuration file that firstly you must create and secondly it is stored in your home directory. In theory a configuration file creating (`~/.config/QtProject/qbs.conf`) looks like this:
```bash
qbs-setup-qt --detect
qbs-detect-toolchains
{% endhighlight %}
```
<p>Firstly we find Qt libraries. Then we find toolchains (such as compilers). And next we must insert a toolchain into Qt profile (for example, we need <code>clang</code> toolchain):</p>
Firstly we find Qt libraries. Then we find toolchains (such as compilers). And next we must insert a toolchain into Qt profile (for example, we need `clang` toolchain):
{% highlight bash %}
```bash
sed 's/clang\\/qt-5-2-0\\/g' -i ~/.config/QtProject/qbs.conf
{% endhighlight %}
```
<p>And there are other ways. You may edit the file manually or use <code>qbs-config-ui</code> or <code>qbs-config</code>.</p>
<p>So, we have created the configuration file and put it into build directory:</p>
And there are other ways. You may edit the file manually or use `qbs-config-ui` or `qbs-config`.
So, we have created the configuration file and put it into build directory:
{% highlight ini %}
```ini
[General]
[Qt]
@ -70,14 +76,15 @@ qutim\cpp\toolchainInstallPath=/usr/bin
qutim\qbs\architecture=x86_64
qutim\qbs\endianness=little
qutim\qbs\toolchain=clang, llvm, gcc
{% endhighlight %}
```
<p><a href="/resources/docs/qutim-qt5-git/qbs-qutim.conf" title="File" type="text/plain">qbs-qutim.conf</a></p>
[qbs-qutim.conf](/resources/docs/qutim-qt5-git/qbs-qutim.conf "File")
<h3><a href="#patch" class="anchor" id="patch"><span class="octicon octicon-link"></span></a>Patch for sources</h3>
<p>The first problem is <code>clang</code> (at least in Archlinux):</p>
### <a href="#patch" class="anchor" id="patch"><span class="octicon octicon-link"></span></a>Patch for sources
{% highlight diff %}
The first problem is `clang` (at least in Archlinux):
```diff
diff -ruN qutim.orig/core/libqutim.qbs qutim/core/libqutim.qbs
--- qutim.orig/core/libqutim.qbs 2014-01-06 15:39:56.000000000 +0400
+++ qutim/core/libqutim.qbs 2014-01-06 15:44:54.502175067 +0400
@ -90,11 +97,11 @@ diff -ruN qutim.orig/core/libqutim.qbs qutim/core/libqutim.qbs
return flags;
}
{% endhighlight %}
```
<p>And the second one is Vk plugin:</p>
And the second one is Vk plugin:
{% highlight diff %}
```diff
diff -ruN qutim.orig/protocols/vkontakte/vreen/vreen.qbs qutim/protocols/vkontakte/vreen/vreen.qbs
--- qutim.orig/protocols/vkontakte/vreen/vreen.qbs 2014-01-06 15:41:42.000000000 +0400
+++ qutim/protocols/vkontakte/vreen/vreen.qbs 2014-01-06 15:46:47.142178486 +0400
@ -106,13 +113,13 @@ diff -ruN qutim.orig/protocols/vkontakte/vreen/vreen.qbs qutim/protocols/vkontak
property string vreen_version_major: 1
property string vreen_version_minor: 9
{% endhighlight %}
```
<p><a href="/resources/docs/qutim-qt5-git/qutim-qbs-1.1.patch" title="File" type="text/plain">qutim-qbs-1.1.patch</a></p>
[qutim-qbs-1.1.patch](/resources/docs/qutim-qt5-git/qutim-qbs-1.1.patch "File")
<h3><a href="#sources" class="anchor" id="sources"><span class="octicon octicon-link"></span></a>Get sources</h3>
### <a href="#sources" class="anchor" id="sources"><span class="octicon octicon-link"></span></a>Get sources
{% highlight bash %}
```bash
# clone repo
git clone https://github.com/euroelessar/qutim
# save qbs.conf
@ -126,28 +133,28 @@ git submodule update --init --recursive
# patch
cd ..
patch -p0 -i qutim-qbs-1.1.patch
{% endhighlight %}
```
<h2><a href="#build" class="anchor" id="build"><span class="octicon octicon-link"></span></a>Building</h2>
## <a href="#build" class="anchor" id="build"><span class="octicon octicon-link"></span></a>Building
{% highlight bash %}
```bash
cd qutim
HOME=$(pwd) qbs -j $(nproc) -d ../build release profile:qutim
{% endhighlight %}
```
<p>I want to create a universal recipe for the building, thus we must set <code>$HOME</code> directory. Flag <code>-j</code> means number of jobs, <code>-d</code> means build directory, <code>release</code> means building type (debug, release), <code>profile</code> is used profile, which is described in the configuration file.</p>
I want to create a universal recipe for the building, thus we must set `$HOME` directory. Flag `-j` means number of jobs, `-d` means build directory, `release` means building type (debug, release), `profile` is used profile, which is described in the configuration file.
<h2><a href="#install" class="anchor" id="install"><span class="octicon octicon-link"></span></a>Installation</h2>
## <a href="#install" class="anchor" id="install"><span class="octicon octicon-link"></span></a>Installation
{% highlight bash %}
```bash
HOME=$(pwd) sudo qbs install -d ../build --install-root "/usr" profile:qutim
{% endhighlight %}
```
<p>We must set root directory (<code>--install-root</code>), because without this option the package will be installed into <code>/</code> (<code>/bin</code> and <code>/lib</code>).</p>
We must set root directory (`--install-root`), because without this option the package will be installed into `/` (`/bin` and `/lib`).
<h2><a href="#pkgbuild" class="anchor" id="pkgbuild"><span class="octicon octicon-link"></span></a>PKGBUILD</h2>
## <a href="#pkgbuild" class="anchor" id="pkgbuild"><span class="octicon octicon-link"></span></a>PKGBUILD
{% highlight bash %}
```bash
pkgname=qutim-qt5-git
_gitname=qutim
pkgver=v0.3.1.967.gc56d61e
@ -198,6 +205,6 @@ package() {
cd "${srcdir}/${_gitname}"
HOME="${srcdir}" qbs install -d ../build --install-root "${pkgdir}/usr" profile:qutim
}
{% endhighlight %}
```
<p><a href="/resources/docs/qutim-qt5-git/PKGBUILD" title="File" type="text/plain">PKGBUILD</a></p>
[PKGBUILD](/resources/docs/qutim-qt5-git/PKGBUILD "File")

View File

@ -1,74 +0,0 @@
---
category: en
type: paper
layout: paper
hastr: true
tags: site, github pages
title: Site changes
short: site-changes
description: I decided to change my site. You may find short list of changes below.
---
<h2><a href="#list" class="anchor" id="list"><span class="octicon octicon-link"></span></a>The list of changes:</h2>
<ul>
<li>I rented a <code>arcanis.me</code> domain. Now I have a normal address, as well as all normal people have it. Small description of how to do it. Firstly, you should rent domain and activate DNS editing (it is called <a href="//www.nic.ru/dns/service/dns_hosting/" title="Service page">DNS-master</a> for Ru-center). I pay about $30 in year. Then you should create CNAME file in your repository; this file has line with your domain name. And finally you should create two DNS records for your domain:
{% highlight bash %}
@ A 192.30.252.153
@ A 192.30.252.154
# redirection from www.*
www CNAME @
{% endhighlight %}
(Symbol <code>@</code> means you root domain.) And next wait for two hours. You may find out the result as follows:
{% highlight bash %}
$ dig domain.name +nostats +nocomments +nocmd
; <<>> DiG 9.9.2-P2 <<>> domain.name +nostats +nocomments +nocmd
;; global options: +cmd
;domain.name. IN A
domain.name. 912 IN A 192.30.252.153
domain.name. 912 IN A 192.30.252.154
...
{% endhighlight %}
</li>
<li>Also I've created <a href="ftp://repo.arcanis.me/repo" title="Repository">my own repo</a>, which will contain some AUR packages that I'm using. Support of both architectures is planned.</li>
<li>Since the repo requires ftp protocol, I've changed samba shared folders to ftp. The problem of access has been resolved by using mount options:
{% highlight bash %}
# only read rights
/home/arcanis/music /srv/ftp/music ext4 defaults,bind,ro 0 0
/home/arcanis/arch/repo /srv/ftp/repo ext4 defaults,bind,ro 0 0
# read and write rights (the file has size 2 Gb)
/home/arcanis/share.fs /srv/ftp/share ext4 defaults,rw 0 0
{% endhighlight %}
Login on special user and option <code>anon_world_readable_only=YES</code> are used for prevent access to the music directory. Also here is my <code>/etc/vsftpd.conf</code> configuration file:
{% highlight bash %}
anonymous_enable=YES
anon_root=/srv/ftp
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
anon_world_readable_only=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
nopriv_user=music
ascii_upload_enable=YES
ftpd_banner=Welcome to arcanis
chroot_local_user=YES
local_root=/srv/ftp/music
listen=YES
{% endhighlight %}
Now let's add redirection from <code>repo.arcanis.me</code> to the needed IP address. To do this, add the following entry in DNS:
{% highlight bash %}
repo A 89.249.170.38
{% endhighlight %}
</li>
<li>Also there are plans to buy a server for compiling packages and hosting the repository, filesharing and backups.</li>
</ul>

View File

@ -0,0 +1,76 @@
---
category: en
type: paper
layout: paper
hastr: true
tags: site, github pages
title: Site changes
short: site-changes
---
I decided to change my site. You may find short list of changes below.
<!--more-->
## <a href="#list" class="anchor" id="list"><span class="octicon octicon-link"></span></a>The list of changes:
* I rented a `arcanis.me` domain. Now I have a normal address, as well as all normal people have it. Small description of how to do it. Firstly, you should rent domain and activate DNS editing (it is called [DNS-master](//www.nic.ru/dns/service/dns_hosting/ "Service page") for Ru-center). I pay about $30 in year. Then you should create CNAME file in your repository; this file has line with your domain name. And finally you should create two DNS records for your domain:
```bash
@ A 192.30.252.153
@ A 192.30.252.154
# redirection from www.*
www CNAME @
```
(Symbol `@` means you root domain.) And next wait for two hours. You may find out the result as follows:
```bash
$ dig domain.name +nostats +nocomments +nocmd
; <<>> DiG 9.9.2-P2 <<>> domain.name +nostats +nocomments +nocmd
;; global options: +cmd
;domain.name. IN A
domain.name. 912 IN A 192.30.252.153
domain.name. 912 IN A 192.30.252.154
...
```
* Also I've created [my own repo](ftp://repo.arcanis.me/repo "Repository"), which will contain some AUR packages that I'm using. Support of both architectures is planned.
* Since the repo requires ftp protocol, I've changed samba shared folders to ftp. The problem of access has been resolved by using mount options:
```bash
# only read rights
/home/arcanis/music /srv/ftp/music ext4 defaults,bind,ro 0 0
/home/arcanis/arch/repo /srv/ftp/repo ext4 defaults,bind,ro 0 0
# read and write rights (the file has size 2 Gb)
/home/arcanis/share.fs /srv/ftp/share ext4 defaults,rw 0 0
```
Login on special user and option `anon_world_readable_only=YES` are used for prevent access to the music directory. Also here is my `/etc/vsftpd.conf` configuration file:
```bash
anonymous_enable=YES
anon_root=/srv/ftp
local_enable=YES
write_enable=YES
local_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
anon_world_readable_only=YES
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
nopriv_user=music
ascii_upload_enable=YES
ftpd_banner=Welcome to arcanis
chroot_local_user=YES
local_root=/srv/ftp/music
listen=YES
```
Now let's add redirection from `repo.arcanis.me` to the needed IP address. To do this, add the following entry in DNS:
```bash
repo A 89.249.170.38
```
* Also there are plans to buy a server for compiling packages and hosting the repository, filesharing and backups.

View File

@ -6,20 +6,24 @@ hastr: true
tags: archlinux, configuration, linux
title: Creating own repository
short: creating-custom-repo
description: It is a short paper devoted to creation own ArchLinux repository.
---
<h2><a href="#prepare" class="anchor" id="prepare"><span class="octicon octicon-link"></span></a>Prepare</h2>
<p>First find a server and desire to have sex with it. It is recommended to use Archlinux on it, but it is not necessarily - because you may create special root for Archlinux. Also you need two packages, <code>devtools</code> and <code>pacman</code>:</p>
It is a short paper devoted to creation own ArchLinux repository.
{% highlight bash %}
<!--more-->
## <a href="#prepare" class="anchor" id="prepare"><span class="octicon octicon-link"></span></a>Prepare
First find a server and desire to have sex with it. It is recommended to use Archlinux on it, but it is not necessarily - because you may create special root for Archlinux. Also you need two packages, `devtools` and `pacman`:
```bash
pacman -Sy devtools
{% endhighlight %}
```
<p><a href="//www.archlinux.org/packages/devtools/" title="Archlinux package">devtools</a> is script set for building automation in the clean chroot. I think most of Arch maintainers use it.</p>
[devtools](//www.archlinux.org/packages/devtools/ "Archlinux package") is script set for building automation in the clean chroot. I think most of Arch maintainers use it.
<p>Let's create working directories and set colors:</p>
Let's create working directories and set colors:
{% highlight bash %}
```bash
# colors
if [ ${USECOLOR} == "yes" ]; then
bblue='\e[1;34m'
@ -53,39 +57,40 @@ if [ ! -d "${STAGINGDIR}" ]; then
echo -e "${bwhite}[II] ${bblue}Creating directory ${bwhite}'${STAGINGDIR}'${cclose}"
mkdir -p "${STAGINGDIR}" || error_mes "unknown"
fi
{% endhighlight %}
```
<p><code>${REPODIR}/{i686,x86_64}</code> are directories for repository, <code>${PREPAREDIR}</code> is directory where compiled packages will be stored, <code>${STAGINGDIR}</code> is one where packages will be built.</p>
`${REPODIR}/{i686,x86_64}` are directories for repository, `${PREPAREDIR}` is directory where compiled packages will be stored, `${STAGINGDIR}` is one where packages will be built.
<h2><a href="#theory" class="anchor" id="theory"><span class="octicon octicon-link"></span></a>A bit of theory</h2>
<p>Create directory, share it (using <a href="/en/2014/03/06/site-changes/" title="Site changes paper">ftp</a>, for example). It has two subdirectories - <code>i686</code> and <code>x86_64</code> - for each architecture respectively. And fill them with a set of packages.</p>
## <a href="#theory" class="anchor" id="theory"><span class="octicon octicon-link"></span></a>A bit of theory
<p>Updating repository may be split into the following steps:</p>
<ol>
<li>Creating PKGBUILDs (or updating them from AUR).</li>
<li>Packages building for each architecture in clean chroot.</li>
<li>Packages signing.</li>
<li>Creating the list of packages.</li>
<li>Repository update:
<ol><li>Removal old packages from repository.</li>
<li>Copying new packages</li>
<li>Repository update.</li></ol>
</li>
<li>Cleaning.</li>
</ol>
Create directory, share it (using [ftp](/en/2014/03/06/site-changes/ "Site changes paper"), for example). It has two subdirectories - `i686` and `x86_64` - for each architecture respectively. And fill them with a set of packages.
<h3><a href="#pkgbuild" class="anchor" id="pkgbuild"><span class="octicon octicon-link"></span></a>Creating PKGBUILDs</h3>
<p>Download source tarballs from AUR:</p>
Updating repository may be split into the following steps:
{% highlight bash %}
1. Creating PKGBUILDs (or updating them from AUR).
2. Packages building for each architecture in clean chroot.
3. Packages signing.
4. Creating the list of packages.
5. Repository update:
1. Removal old packages from repository.
2. Copying new packages
3. Repository update.
6. Cleaning.
### <a href="#pkgbuild" class="anchor" id="pkgbuild"><span class="octicon octicon-link"></span></a>Creating PKGBUILDs
Download source tarballs from AUR:
```bash
cd "${STAGINGDIR}"
yaourt -G package-name
{% endhighlight %}
```
<h3><a href="#building" class="anchor" id="building"><span class="octicon octicon-link"></span></a>Packages building</h3>
<p>Build each package automatically:</p>
### <a href="#building" class="anchor" id="building"><span class="octicon octicon-link"></span></a>Packages building
{% highlight bash %}
Build each package automatically:
```bash
func_build() {
if [ ${USECOLOR} == "yes" ]; then
_bblue='\e[1;34m'
@ -121,19 +126,19 @@ export -f func_build
echo -e "${bwhite}[II]${cclose} Building packages"
cd "${STAGINGDIR}"
/usr/bin/find -name 'PKGBUILD' -type f -execdir /usr/bin/bash -c "func_build "${PREPAREDIR}" "${ROOTDIR}"" \;
{% endhighlight %}
```
<p>It is recommended to add the following lines to <code>/etc/sudoers</code>:</p>
It is recommended to add the following lines to `/etc/sudoers`:
{% highlight bash %}
```bash
username ALL=NOPASSWD: /usr/bin/staging-i686-build
username ALL=NOPASSWD: /usr/bin/staging-x86_64-build
username ALL=NOPASSWD: /usr/bin/multilib-staging-build
{% endhighlight %}
```
<h3><a href="#signing" class="anchor" id="signing"><span class="octicon octicon-link"></span></a>Packages signing</h3>
### <a href="#signing" class="anchor" id="signing"><span class="octicon octicon-link"></span></a>Packages signing
{% highlight bash %}
```bash
# signing
if [ ${USEGPG} == "yes" ]; then
echo -e "${bwhite}[II]${cclose} Signing"
@ -142,34 +147,35 @@ if [ ${USEGPG} == "yes" ]; then
/usr/bin/gpg -b ${PACKAGE}
done
fi
{% endhighlight %}
```
<p>It is recommended to configure <a href="//wiki.archlinux.org/index.php/GPG#gpg-agent" title="ArchWiki">gpg-agent</a>.</p>
It is recommended to configure [gpg-agent](//wiki.archlinux.org/index.php/GPG#gpg-agent "ArchWiki").
<h3><a href="#list" class="anchor" id="list"><span class="octicon octicon-link"></span></a>Creating the list of packages</h3>
### <a href="#list" class="anchor" id="list"><span class="octicon octicon-link"></span></a>Creating the list of packages
{% highlight bash %}
```bash
# creating packages list
cd "${PREPAREDIR}"
i686_PACKAGES=$(/usr/bin/find * -name '*-i686.pkg.tar.xz' -o -name '*-any.pkg.tar.xz')
x86_64_PACKAGES=$(/usr/bin/find * -name '*-x86_64.pkg.tar.xz' -o -name '*-any.pkg.tar.xz')
echo -e "${bwhite}[II] ${bblue}=>${cclose} i686 packages: \n${bwhite}${i686_PACKAGES}${cclose}"
echo -e "${bwhite}[II] ${bblue}=>${cclose} x86_64 packages: \n${bwhite}${x86_64_PACKAGES}${cclose}"
{% endhighlight %}
```
<h3><a href="#updating" class="anchor" id="updating"><span class="octicon octicon-link"></span></a>Repository update</h3>
<p>Here is a function for removal packages from database and repository:</p>
### <a href="#updating" class="anchor" id="updating"><span class="octicon octicon-link"></span></a>Repository update
{% highlight bash %}
Here is a function for removal packages from database and repository:
```bash
func_remove() {
_PACKAGE="$1"
/usr/bin/rm -f "${_PACKAGE}"{,.sig}
}
{% endhighlight %}
```
<p><code>i686</code> repository update:</p>
`i686` repository update:
{% highlight bash %}
```bash
# updating i686 repo
echo -e "${bwhite}[II]${cclose} Updating ${bwhite}i686${cclose} repo"
cd "${REPODIR}/i686"
@ -184,11 +190,11 @@ for PACKAGE in ${i686_PACKAGES}; do
/usr/bin/repo-add ${DBNAME}.db.tar.gz "${PACKAGE}"
/usr/bin/repo-add --files ${DBNAME}.files.tar.gz "${PACKAGE}"
done
{% endhighlight %}
```
<p><code>x86_64</code> repository update:</p>
`x86_64` repository update:
{% highlight bash %}
```bash
# updating x86_64 repo
echo -e "${bwhite}[II]${cclose} Updating ${bwhite}x86_64${cclose} repo"
cd "${REPODIR}/x86_64"
@ -203,22 +209,23 @@ for PACKAGE in ${x86_64_PACKAGES}; do
/usr/bin/repo-add ${DBNAME}.db.tar.gz "${PACKAGE}"
/usr/bin/repo-add --files ${DBNAME}.files.tar.gz "${PACKAGE}"
done
{% endhighlight %}
```
<h3><a href="#clear" class="anchor" id="clear"><span class="octicon octicon-link"></span></a>Cleaning</h3>
### <a href="#clear" class="anchor" id="clear"><span class="octicon octicon-link"></span></a>Cleaning
{% highlight bash %}
```bash
# clear
cd "${PREPAREDIR}"
/usr/bin/rm -rf *
cd "${STAGINGDIR}"
/usr/bin/rm -rf *
{% endhighlight %}
```
<h3><a href="#symlinks" class="anchor" id="symlinks"><span class="octicon octicon-link"></span></a>Creating symlinks</h3>
<p>You may want to create a directory, which will contain symlinks on actual packages with names, which does not contain version:</p>
### <a href="#symlinks" class="anchor" id="symlinks"><span class="octicon octicon-link"></span></a>Creating symlinks
{% highlight bash %}
You may want to create a directory, which will contain symlinks on actual packages with names, which does not contain version:
```bash
# creating symlinks
if [ ${SYMLINK} == "yes" ]; then
echo -e "${bwhite}[II]${cclose} Creating symlinks"
@ -237,15 +244,17 @@ if [ ${SYMLINK} == "yes" ]; then
/usr/bin/ln -sf "../x86_64/${PACKAGE}" "${PKGNAME}-x86_64.pkg.tar.xz"
done
fi
{% endhighlight %}
```
<h3><a href="#file" class="anchor" id="file"><span class="octicon octicon-link"></span></a>File</h3>
<p>Here is <a href="//github.com/arcan1s/repo-scripts" title="GitHub">the scripts</a>. Download source tarballs and run script (editing variables if it is necessary).</p>
### <a href="#file" class="anchor" id="file"><span class="octicon octicon-link"></span></a>File
<h2><a href="#using" class="anchor" id="using"><span class="octicon octicon-link"></span></a>Repository usage</h2>
<p>Just add following lines to <code>/etc/pacman.conf</code>:</p>
Here is [the scripts](//github.com/arcan1s/repo-scripts "GitHub"). Download source tarballs and run script (editing variables if it is necessary).
{% highlight bash %}
## <a href="#using" class="anchor" id="using"><span class="octicon octicon-link"></span></a>Repository usage
Just add following lines to `/etc/pacman.conf`:
```bash
[$REPONAME]
Server = ftp://$REPOADDRESS/repo/$arch
{% endhighlight %}
```

View File

@ -1,85 +0,0 @@
---
category: en
type: paper
layout: paper
hastr: true
tags: настройка, linux, archlinux
title: Apps which I use
short: my-desktop
description: Here is a short paper devoted to the set of applications and extensions that I use everyday on my home computer.
---
<h2><a href="#apps" class="anchor" id="apps"><span class="octicon octicon-link"></span></a>Applications</h2>
<ul>
<li><p><b>Shell</b> is zshrc and nothing else. You may find a small description of my settings <a href="/en/2014/01/14/about-zshrc/" title="About zshrc paper">here</a>. It is stored <a href="//raw.githubusercontent.com/arcan1s/dotfiles/master/zshrc" title="File" type="text/plain">here</a> (or <a href="//raw.githubusercontent.com/arcan1s/dotfiles/master/zshrc_server" title="File" type="text/plain">here</a>).</p></li>
<li><p><b>DE</b> - I use KDE as Desktop Environment. And that's why most of apps are qt-based. Some KDE settings are below.</p></li>
<li><p><b>Graphic editors</b> - <a href="//kde.org/applications/graphics/gwenview/" title="Gwenview Homepage">gwenview</a> is used for viewing images, <a href="//kde.org/applications/graphics/kolourpaint/" title="Kolourpaint Homepage">kolourpaint</a> is used for simple editing pixel images, <a href="//www.gimp.org/" title="Gimp Homepage">gimp</a> (without plugins, since they are not needed for me) - for editing and <a href="//www.inkscape.org/" title="Inkskape Homepage">inkskape</a> is used as editor of vector graphics.</p></li>
<li><p><b>Browser</b> - I use Firefox. Some Firefox settings are below. Chromium is used as additional browser, elinks is used as console browser.</p></li>
<li><p><b>IM client</b> is <a href="//qutim.org" title="Qutim Homepage">qutIM</a>. It is a cross-platform, multiprotocol and full featured client. <a href="//kde.org/applications/internet/kopete/" title="Kopete Homepage">Kopete</a>, which I used before it, crashes, does not work correctly and does not work normally with codepage. Also I don't use a console client since I use a tablet IM. And I use Skype for skype obviously.</p></li>
<li><p><b>Mail client</b> is <a href="//kde.org/applications/internet/kmail/" title="Kmail Homepage">kmail</a>. It is a full featured client (and I use most of them), looks pretty and it is easy to use. If it will be DE-undepended it will be better.</p></li>
<li><p><b>IRC client</b> is <a href="//konversation.kde.org/" title="Konversation Homepage">konversation</a>. It is a simple IRC client. Though as far as I remember qutIM also supports IRC protocol, I prefre to use a special IRC client.</p></li>
<li><p><b>Torrent client</b> is <a href="//www.transmissionbt.com/" title="Transmission Homepage">transmission</a> with Qt5 interface (it has gtk interface too). It is also used for server but without GUI.</p></li>
<li><p><b>Video player</b> is <a href="//mpv.io/" title="Mpv Homepage">mpv</a>, since mplayer died and mplayer2 was born deadborn. Graphical frontend are not needed.</p></li>
<li><p><b>Audio player</b> is <a href="//qmmp.ylsoftware.com/" title="Qmmp Homepage">qmmp</a>. It is a good winamp-like player. Flick of the wrist you may make a handy interface for it (simpleui).</p></li>
<li><p><b>Audio/video editors</b>: <a href="//kde-apps.org/content/show.php?content=29024" title="Kdenlive Homepage">kdenlive</a> is used as video editor, <a href="//kde-apps.org/content/show.php?content=29024">soundkonverter</a> is used as audio editor, <a href="//wiki.gnome.org/Apps/EasyTAG" title="Easytag Homepage">easytag</a> is used for editing audio tags (unfortunately, it is a gtk-based, but I didn't find a better tool for it). And command line and scripts written on bash are used too.</p></li>
<li><p><b>Office</b>: <a href="//wps-community.org/" title="KO Homepage">Kingsoft Office</a> is used as alternative of Microsoft Office; it has no any feature, but it looks normally, it is qt-based and it is said that it has a good support for standart formats. (Linux version has an alfa stage.) <a href="//kile.sourceforge.net/" title="Kile Homepage">Kile</a> is used as LaTeX frontend. <a href="//kde.org/applications/graphics/okular/" title="Okular Homepage">Okular</a> is used as document viewer. And I use <a href="//goldendict.org/" title="GoldenDict Homepage">GoldenDict</a> as dictionary.</p></li>
<li><p><b>Editors</b>: <a href="//www.kde.org/applications/utilities/kwrite/" title="Kwrite Homepage">kwrite</a> is used as a simple text editor, <a href="//www.kde.org/applications/utilities/kate/" title="Kate Homepage">kate</a> (and <a href="//zaufi.github.io/kate-cpp-helper-plugin.html" title="Plugin Homepage">cpp-helper</a> plugin) is used as advanced text editor. And of course I use vim in console.</p></li>
<li><p><b>Scientific soft</b>. Chemical visualizers are <a href="//www.ks.uiuc.edu/Research/vmd/" title="VMD Homepage">vmd</a>, <a href="//www.cgl.ucsf.edu/chimera/" title="Chimera Homepage">chimera</a> and <a href="//pymol.org/" title="Pymol Homepage">pymol</a>. Physics simulator is <a href="//kde.org/applications/education/step/" title="Step Homepage">step</a>. Calculator is <a href="//kde.org/applications/education/kalgebra/" title="Kalgebra Homepage">kalgebra</a> and console <a href="//ipython.org/" title="ipython Homepage">ipython</a>. <a href="//qtiplot.com/" title="Qtiplot Homepage">Qtiplot</a> is used for drawing graphs and data analysis (scidavis, which is its fork, unfortunately, is half-dead), <a href="//plasma-gate.weizmann.ac.il/Grace/" title="Grace Homepage">grace</a> is used for only drawing graphs. <a href="//ruby.chemie.uni-freiburg.de/~martin/chemtool/chemtool.html" title="Chemtool Homepage">Chemtool</a> is used as alternative of ChemDraw.</p></li>
<li><p><b>System applications</b>. File manager is <a href="//kde.org/applications/system/dolphin/" title="Dolphin Homepage">dolphin</a>, <a href="//doublecmd.sourceforge.net/" title="Doublecmd Homepage">doublecmd</a> is used as twin-panel manager. Terminal emulators are <a href="//yakuake.kde.org/" title="Yakuake Homepage">yakuake</a> and <a href="//software.schmorp.de/pkg/rxvt-unicode.html" title="Urxvt Homepage">urxvt</a> (as windowed emulator). Archiver graphical interface is <a href="//kde.org/applications/utilities/ark/" title="Ark Homepage">ark</a>.</p></li>
</ul>
<h2><a href="#kde" class="anchor" id="kde"><span class="octicon octicon-link"></span></a>KDE settings</h2>
<div class="thumbnails">
{% assign scrdesc = "KDE screenshot" %}
{% assign scrname = "kde" %}
{% include prj_scr.html %}
</div>
<p>QtCurve is used as Qt style, its settings may be found <a href="//github.com/arcan1s/dotfiles/tree/master/qtcurve" title="GitHub">here</a>, window decorations are presented by QtCurve too. Cursor theme is <a href="//kde-look.org/content/show.php/Ecliz?content=110340" title="Cursor Homepage">ecliz-small</a>. Plasma theme is <a href="//kde-look.org/content/show.php/Volatile?content=128110" title="Theme Homepage">volatile</a>. Icon pack is <a href="//nitrux.in/" title="Nitrux Homepage">compass</a>. I use fonts which are based on Liberation.</p>
<p><b>Used widgets</b> (from left to right, top to bottom) are: <a href="//launchpad.net/plasma-widget-menubar" title="Widget Homepage">menubar</a>, <a href="//userbase.kde.org/Homerun" title="Widget Homepage">homerun</a> with transparent icon, <a href="//kde-apps.org/content/show.php?content=144808" title="Widget Homepage">icontask</a>, <a href="/projects/netctl-gui/" title="Widget Homepage">netctl</a>, default KDE tray, <a href="//agateau.com/projects/colibri/" title="Widget Homepage">colibri</a> for notifications, <a href="/projects/awesome-widgets" title="Widget Homepage">Awesome Widgets</a>.</p>
<p>As a bonus material <a href="//github.com/arcan1s/dotfiles/blob/master/themes/yakuake/My%20color.colorscheme" title="GitHub">here</a> is a settings for konsole bright colors.</p>
<div class="thumbnails">
{% assign scrdesc = "Zsh demonstation" %}
{% assign scrname = "zshrc_demo" %}
{% include prj_scr.html %}
</div>
<h2><a href="#firefox" class="anchor" id="firefox"><span class="octicon octicon-link"></span></a>Firefox settings</h2>
<p>I do not use a special settings, thus I get you a list of used add-ons:</p>
<ul>
<li><p><b>Adblock plus</b>.</p></li>
<li><p><b>Add to search bar</b> is used for custom searchs.</p></li>
<li><p><b>Auto Refresh</b> is used for auto update pages.</p></li>
<li><p><b>Clone tab</b> adds "Clone tab" function.</p></li>
<li><p><b>Close tab by double click</b>.</p></li>
<li><p><b>New scrollbars</b> is used for customizing scrollbars, because original ones look horrible in Qt environment.</p></li>
<li><p><b>NoScript</b> is used for I2P and Tor, for example.</p></li>
<li><p><b>PrivateTab</b> adds private tab (not the window).</p></li>
<li><p><b>Proxy Selector</b> adds an ability to use multiple proxies.</p></li>
<li><p><b>QuickJava</b> is used with the same goal as NoScript.</p></li>
<li><p><b>RSS icon in url bar</b>.</p></li>
<li><p><b>Dictionaries for spellchecking</b> (eng/rus).</p></li>
<li><p><b>Space Next</b>. If I tap a space at the bottom of a page, it will be perceived as pushing the "Next" button.</p></li>
<li><p><b>Speed Dial</b> is a simple express panel.</p></li>
<li><p><b>Status-4-Evar</b> is a normal status bar.</p></li>
<li><p><b>tab delabelifier</b> minimizes inactive tabs.</p></li>
<li><p><b>Tab Scope + Tab Scope Tweaker</b> is tab tooltip.</p></li>
<li><p><b>accessKey</b> does not work now. But it is needed for easy navigation from keyboard (opera-like).</p></li>
<li><p><b>FXOpera</b> is a normal minimalistic appearance.</p></li>
</ul>

View File

@ -0,0 +1,75 @@
---
category: en
type: paper
layout: paper
hastr: true
tags: настройка, linux, archlinux
title: Apps which I use
short: my-desktop
---
Here is a short paper devoted to the set of applications and extensions that I use everyday on my home computer.
<!--more-->
## <a href="#apps" class="anchor" id="apps"><span class="octicon octicon-link"></span></a>Applications
* **Shell** is zshrc and nothing else. You may find a small description of my settings [here](/en/2014/01/14/about-zshrc/ "About zshrc paper"). It is stored [here](//raw.githubusercontent.com/arcan1s/dotfiles/master/zshrc "File") (or [here](//raw.githubusercontent.com/arcan1s/dotfiles/master/zshrc_server "File")).
* **DE** - I use KDE as Desktop Environment. And that's why most of apps are qt-based. Some KDE settings are below.
* **Graphic editors** - [gwenview](//kde.org/applications/graphics/gwenview/ "Gwenview Homepage") is used for viewing images, [kolourpaint](//kde.org/applications/graphics/kolourpaint/ "Kolourpaint Homepage") is used for simple editing pixel images, [gimp](//www.gimp.org/ "Gimp Homepage") (without plugins, since they are not needed for me) - for editing and [inkskape](//www.inkscape.org/ "Inkskape Homepage") is used as editor of vector graphics.
* **Browser** - I use Firefox. Some Firefox settings are below. Chromium is used as additional browser, elinks is used as console browser.
* **IM client** is [qutIM](//qutim.org "Qutim Homepage"). It is a cross-platform, multiprotocol and full featured client. [Kopete](//kde.org/applications/internet/kopete/ "Kopete Homepage"), which I used before it, crashes, does not work correctly and does not work normally with codepage. Also I don't use a console client since I use a tablet IM. And I use Skype for skype obviously.
* **Mail client** is [kmail](//kde.org/applications/internet/kmail/ "Kmail Homepage"). It is a full featured client (and I use most of them), looks pretty and it is easy to use. If it will be DE-undepended it will be better.
* **IRC client** is [konversation](//konversation.kde.org/ "Konversation Homepage"). It is a simple IRC client. Though as far as I remember qutIM also supports IRC protocol, I prefre to use a special IRC client.
* **Torrent client** is [transmission](//www.transmissionbt.com/ "Transmission Homepage") with Qt5 interface (it has gtk interface too). It is also used for server but without GUI.
* **Video player** is [mpv](//mpv.io/ "Mpv Homepage"), since mplayer died and mplayer2 was born deadborn. Graphical frontend are not needed.
* **Audio player** is [qmmp](//qmmp.ylsoftware.com/ "Qmmp Homepage"). It is a good winamp-like player. Flick of the wrist you may make a handy interface for it (simpleui).
* **Audio/video editors**: [kdenlive](//kde-apps.org/content/show.php?content=29024 "Kdenlive Homepage") is used as video editor, [soundkonverter](//kde-apps.org/content/show.php?content=29024) is used as audio editor, [easytag](//wiki.gnome.org/Apps/EasyTAG "Easytag Homepage") is used for editing audio tags (unfortunately, it is a gtk-based, but I didn't find a better tool for it). And command line and scripts written on bash are used too.
* **Office**: [Kingsoft Office](//wps-community.org/ "KO Homepage") is used as alternative of Microsoft Office; it has no any feature, but it looks normally, it is qt-based and it is said that it has a good support for standart formats. (Linux version has an alfa stage.) [Kile](//kile.sourceforge.net/ "Kile Homepage") is used as LaTeX frontend. [Okular](//kde.org/applications/graphics/okular/ "Okular Homepage") is used as document viewer. And I use [GoldenDict](//goldendict.org/ "GoldenDict Homepage") as dictionary.
* **Editors**: [kwrite](//www.kde.org/applications/utilities/kwrite/ "Kwrite Homepage") is used as a simple text editor, [kate](//www.kde.org/applications/utilities/kate/ "Kate Homepage") (and [cpp-helper](//zaufi.github.io/kate-cpp-helper-plugin.html "Plugin Homepage") plugin) is used as advanced text editor. And of course I use vim in console.
* **Scientific soft**. Chemical visualizers are [vmd](//www.ks.uiuc.edu/Research/vmd/ "VMD Homepage"), [chimera](//www.cgl.ucsf.edu/chimera/ "Chimera Homepage") and [pymol](//pymol.org/ "Pymol Homepage"). Physics simulator is [step](//kde.org/applications/education/step/ "Step Homepage"). Calculator is [kalgebra](//kde.org/applications/education/kalgebra/ "Kalgebra Homepage") and console [ipython](//ipython.org/ "ipython Homepage"). [Qtiplot](//qtiplot.com/ "Qtiplot Homepage") is used for drawing graphs and data analysis (scidavis, which is its fork, unfortunately, is half-dead), [grace](//plasma-gate.weizmann.ac.il/Grace/ "Grace Homepage") is used for only drawing graphs. [Chemtool](//ruby.chemie.uni-freiburg.de/~martin/chemtool/chemtool.html "Chemtool Homepage") is used as alternative of ChemDraw.
* **System applications**. File manager is [dolphin](//kde.org/applications/system/dolphin/ "Dolphin Homepage"), [doublecmd](//doublecmd.sourceforge.net/ "Doublecmd Homepage") is used as twin-panel manager. Terminal emulators are [yakuake](//yakuake.kde.org/ "Yakuake Homepage") and [urxvt](//software.schmorp.de/pkg/rxvt-unicode.html "Urxvt Homepage") (as windowed emulator). Archiver graphical interface is [ark](//kde.org/applications/utilities/ark/ "Ark Homepage").
## <a href="#kde" class="anchor" id="kde"><span class="octicon octicon-link"></span></a>KDE settings
<div class="thumbnails">
{% assign scrdesc = "KDE screenshot" %}
{% assign scrname = "kde" %}
{% include prj_scr.html %}
</div>
QtCurve is used as Qt style, its settings may be found [here](//github.com/arcan1s/dotfiles/tree/master/qtcurve "GitHub"), window decorations are presented by QtCurve too. Cursor theme is [ecliz-small](//kde-look.org/content/show.php/Ecliz?content=110340 "Cursor Homepage"). Plasma theme is [volatile](//kde-look.org/content/show.php/Volatile?content=128110 "Theme Homepage"). Icon pack is [compass](//nitrux.in/ "Nitrux Homepage"). I use fonts which are based on Liberation.
**Used widgets** (from left to right, top to bottom) are: [menubar](//launchpad.net/plasma-widget-menubar "Widget Homepage"), [homerun](//userbase.kde.org/Homerun "Widget Homepage") with transparent icon, [icontask](//kde-apps.org/content/show.php?content=144808 "Widget Homepage"), [netctl](/projects/netctl-gui/ "Widget Homepage"), default KDE tray, [colibri](//agateau.com/projects/colibri/ "Widget Homepage") for notifications, [Awesome Widgets](/projects/awesome-widgets "Widget Homepage").
As a bonus material [here](//github.com/arcan1s/dotfiles/blob/master/themes/yakuake/My%20color.colorscheme "GitHub") is a settings for konsole bright colors.
<div class="thumbnails">
{% assign scrdesc = "Zsh demonstation" %}
{% assign scrname = "zshrc_demo" %}
{% include prj_scr.html %}
</div>
## <a href="#firefox" class="anchor" id="firefox"><span class="octicon octicon-link"></span></a>Firefox settings
I do not use a special settings, thus I get you a list of used add-ons:
* **Adblock plus**.
* **Add to search bar** is used for custom searchs.
* **Auto Refresh** is used for auto update pages.
* **Clone tab** adds "Clone tab" function.
* **Close tab by double click**.
* **New scrollbars** is used for customizing scrollbars, because original ones look horrible in Qt environment.
* **NoScript** is used for I2P and Tor, for example.
* **PrivateTab** adds private tab (not the window).
* **Proxy Selector** adds an ability to use multiple proxies.
* **QuickJava** is used with the same goal as NoScript.
* **RSS icon in url bar**.
* **Dictionaries for spellchecking** (eng/rus).
* **Space Next**. If I tap a space at the bottom of a page, it will be perceived as pushing the "Next" button.
* **Speed Dial** is a simple express panel.
* **Status-4-Evar** is a normal status bar.
* **tab delabelifier** minimizes inactive tabs.
* **Tab Scope + Tab Scope Tweaker** is tab tooltip.
* **accessKey** does not work now. But it is needed for easy navigation from keyboard (opera-like).
* **FXOpera** is a normal minimalistic appearance.

View File

@ -1,41 +0,0 @@
---
category: en
type: paper
layout: paper
hastr: true
tags: linux, archlinux, building
title: Disabling baloo, gentoo-way
short: disabling-baloo
description: Paper, which describes how to remove the dependency on baloo in your system.
---
<h2><a href="#disclaimer" class="anchor" id="disclaimer"><span class="octicon octicon-link"></span></a>Disclaimer</h2>
<p>I do not use this patch, since I prefer less destructive methods. However, apparently all works fine, because there is no any claims. Since this patch was created in a few minutes, it removes all baloo's calls from source files (maybe I'll create a normal patch sometime).</p>
<p>On other hand, I highly recommend to people, who do not use baloo for some reason, disable it from the settings menu (it was added it 4.13.1) or read this <a href="//blog.andreascarpino.it/disabling-baloo-the-arch-way/" title="Scarpino's blog">article</a>.</p>
<h2><a href="#intro" class="anchor" id="intro"><span class="octicon octicon-link"></span></a>Introduction</h2>
<p>In Archlinux <b>gwenview</b> and <b>kdepim</b> (and <b>baloo-widgets</b>) depend on baloo currently (2014-05-18). In the version 4.13.0 <b>kactivities</b> depends on baloo too (and I don't know why); but this dependency was not required explicitly, so it was enough just to rebuild the package by removing baloo from the list of dependencies.</p>
<h2><a href="#gwenview" class="anchor" id="gwenview"><span class="octicon octicon-link"></span></a>gwenview</h2>
<p>It's all quite simple. Developers have taken care of the wishes of ordinary users and added a special flag:</p>
{% highlight cmake %}
//Semantic info backend for Gwenview (Baloo/Fake/None)
GWENVIEW_SEMANTICINFO_BACKEND:STRING=Baloo
{% endhighlight %}
<p>Thus, we add requred cmake flag to the build script:</p>
{% highlight bash %}
cmake ../gwenview-${pkgver} \
-DCMAKE_BUILD_TYPE=Release \
-DKDE4_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=/usr \
-DGWENVIEW_SEMANTICINFO_BACKEND=None
{% endhighlight %}
<h2><a href="#kdepim" class="anchor" id="kdepim"><span class="octicon octicon-link"></span></a>kdepim</h2>
<p>Since everything was done in a hurry, I prefer to look at the source code using grep and to find all references to baloo. Needed strings (they are links to ballo in CMakeLists.txt, baloo's function calls and header declarations) were commented (I added some fake calls to the source code). You may find the patch <a href="//gist.github.com/arcan1s/b698bb586faef627b3bb" title="Gist">here</a> (4.13.3). Download the patch, apply it to the source code and recompile kdepim.</p>
<h2><a href="#packages" class="anchor" id="packages"><span class="octicon octicon-link"></span></a>Packages</h2>
<p>All Archlinux packages for both architectures may be found in <a href="//wiki.archlinux.org/index.php/Unofficial_user_repositories#arcanisrepo" title="ArchWiki">my repository</a>.</p>

View File

@ -0,0 +1,49 @@
---
category: en
type: paper
layout: paper
hastr: true
tags: linux, archlinux, building
title: Disabling baloo, gentoo-way
short: disabling-baloo
---
Paper, which describes how to remove the dependency on baloo in your system.
<!--more-->
## <a href="#disclaimer" class="anchor" id="disclaimer"><span class="octicon octicon-link"></span></a>Disclaimer
I do not use this patch, since I prefer less destructive methods. However, apparently all works fine, because there is no any claims. Since this patch was created in a few minutes, it removes all baloo's calls from source files (maybe I'll create a normal patch sometime).
On other hand, I highly recommend to people, who do not use baloo for some reason, disable it from the settings menu (it was added it 4.13.1) or read this [article](//blog.andreascarpino.it/disabling-baloo-the-arch-way/ "Scarpino's blog").
## <a href="#intro" class="anchor" id="intro"><span class="octicon octicon-link"></span></a>Introduction
In Archlinux **gwenview** and **kdepim** (and **baloo-widgets**) depend on baloo currently (2014-05-18). In the version 4.13.0 **kactivities** depends on baloo too (and I don't know why); but this dependency was not required explicitly, so it was enough just to rebuild the package by removing baloo from the list of dependencies.
## <a href="#gwenview" class="anchor" id="gwenview"><span class="octicon octicon-link"></span></a>gwenview
It's all quite simple. Developers have taken care of the wishes of ordinary users and added a special flag:
```cmake
//Semantic info backend for Gwenview (Baloo/Fake/None)
GWENVIEW_SEMANTICINFO_BACKEND:STRING=Baloo
```
Thus, we add requred cmake flag to the build script:
```bash
cmake ../gwenview-${pkgver} \
-DCMAKE_BUILD_TYPE=Release \
-DKDE4_BUILD_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX=/usr \
-DGWENVIEW_SEMANTICINFO_BACKEND=None
```
## <a href="#kdepim" class="anchor" id="kdepim"><span class="octicon octicon-link"></span></a>kdepim
Since everything was done in a hurry, I prefer to look at the source code using grep and to find all references to baloo. Needed strings (they are links to ballo in CMakeLists.txt, baloo's function calls and header declarations) were commented (I added some fake calls to the source code). You may find the patch [here](//gist.github.com/arcan1s/b698bb586faef627b3bb "Gist") (4.13.3). Download the patch, apply it to the source code and recompile kdepim.
## <a href="#packages" class="anchor" id="packages"><span class="octicon octicon-link"></span></a>Packages
All Archlinux packages for both architectures may be found in [my repository](//wiki.archlinux.org/index.php/Unofficial_user_repositories#arcanisrepo "ArchWiki").

View File

@ -1,143 +0,0 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: linux, development
title: Writting own Shell completions. Zsh
short: writting-own-completions-p1
description: <figure class="img"><img src="/resources/papers/zsh_completion.png" alt="bash_completion"></figure> Some basics of creating a completion files for own application are described in these articles.
---
<h2><a href="#preamble" class="anchor" id="preamble"><span class="octicon octicon-link"></span></a>Preamble</h2>
<p>While developing <a href="/ru/projects/netctl-gui" title="Netctl-gui project page">one of my projects</a> I have wanted to add completion files. I have already tried to create these files, but I was too lazy to read some manuals about it.</p>
<h2><a href="#introduction" class="anchor" id="introduction"><span class="octicon octicon-link"></span></a>Introduction</h2>
<p>There are some possible ways to create zsh completion file. In this article I will describe only one of them, which provides a lot of opportunities, but does not require a lot of costs (such as regular expressions).</p>
<p>Lets consider the example of my application, which has a part of help message that looks like this:</p>
{% highlight bash %}
netctl-gui [ -h | --help ] [ -e ESSID | --essid ESSID ] [ -с FILE | --config FILE ]
[ -o PROFILE | --open PROFILE ] [ -t NUM | --tab NUM ] [ --set-opts OPTIONS ]
{% endhighlight %}
<p>Here is a flag list:</p>
<ul>
<li>flags <code>-h</code> and <code>--help</code> do not require any arguments;</li>
<li>flags <code>-e</code> and <code>--essid</code> require a string argument without completion;</li>
<li>flags <code>-c</code> and <code>--config</code> require a string argument, which is a file;</li>
<li>flags <code>-o</code> and <code>--open</code> require a string argument, there is a completion from files in the specified directory;</li>
<li>flags <code>-t</code> and <code>--tab</code> require a string argument, there is a completion from the specified array;</li>
<li>flag <code>--set-opts</code> requires a string argument, there is a completion from the specified array comma separated;</li>
</ul>
<h2><a href="#file" class="anchor" id="file"><span class="octicon octicon-link"></span></a>The file pattern</h2>
<p>It must be specified in the header that it is a completion file and application for which it will complete (may be string if this file provides completions for several applications):</p>
{% highlight bash %}
#compdef netctl-gui
{% endhighlight %}
<p>Next there is flags, additional functions and variables declarations. It should be noted that all functions and variables, which will be used for completions, <b>should return arrays</b>. In my case this scheme looks like this (I left empty these functions in this chapter):</p>
{% highlight bash %}
# variables
_netctl_gui_arglist=()
_netctl_gui_settings=()
_netctl_gui_tabs=()
_netctl_profiles() {}
{% endhighlight %}
<p>Then there are main functions, which will be called for completion of specific application. In my case this there is only one applications, so there is only one function:</p>
{% highlight bash %}
# work block
_netctl-gui() {}
{% endhighlight %}
<p>And finally <b>without isolation in a separate function</b> there is a small shamanism, which declares a dependence "application-function":</p>
{% highlight bash %}
case "$service" in
netctl-gui)
_netctl-gui "$@" && return 0
;;
esac
{% endhighlight %}
<h2><a href="#flags" class="anchor" id="flags"><span class="octicon octicon-link"></span></a>Flags</h2>
<p>As it was said above, there are some different ways to create these files. In particular they differ in the flag declaration and their further processing. In my case I will use <code>_arguments</code> command, which require a specific format of variables: <code>FLAG[description]:MESSAGE:ACTION</code>. The last two fields are not required and, as you will see below, are not needed in some cases. If you want to add two flags for an action (short and long format), then the format is a little bit complicated: <code>{(FLAG_2)FLAG_1,(FLAG_1)FLAG_2}[description]:MESSAGE:ACTION</code>. It should be noted that if you want to create completions for two flags but some flags have not a second format. you will should to add following line: <code>{FLAG,FLAG}[description]:MESSAGE:ACTION</code>. <code>MESSAGE</code> is a message which will be shown, <code>ACTION</code> is an action which will be performed after this flag. In this tutorial <code>ACTION</code> will be following: <code>->STATE</code>.</p>
<p>So, according to our requirements, flags declaration will be following:</p>
{% highlight bash %}
_netctl_gui_arglist=(
{'(--help)-h','(-h)--help'}'[show help and exit]'
{'(--essid)-e','(-e)--essid'}'[select ESSID]:type ESSID:->essid'
{'(--config)-c','(-c)--config'}'[read configuration from this file]:select file:->files'
{'(--open)-o','(-o)--open'}'[open profile]:select profile:->profiles'
{'(--tab)-t','(-t)--tab'}'[open a tab with specified number]:select tab:->tab'
{'--set-opts','--set-opts'}'[set options for this run, comma separated]:comma separated:->settings'
)
{% endhighlight %}
<h2><a href="#variables" class="anchor" id="variables"><span class="octicon octicon-link"></span></a>Arrays of variables</h2>
<p>In my case there are two static arrays (which will not be changed):</p>
{% highlight bash %}
_netctl_gui_settings=(
'CTRL_DIR'
'CTRL_GROUP'
)
_netctl_gui_tabs=(
'1'
'2'
)
{% endhighlight %}
<p>And there is a dynamic array, which should be generated each time. In my case it is a list of files in the specified directory (by the way it may be done by means of zsh):</p>
{% highlight bash %}
_netctl_profiles() {
print $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
}
{% endhighlight %}
<h2><a href="#body" class="anchor" id="body"><span class="octicon octicon-link"></span></a>Function</h2>
<p>Remember, there was something about a state above? It is stored in the variable <code>$state</code> and in this function we will check what it is to choose the appropriate action. At the beginning of the function we should call <code>_arguments</code> with our flags.</p>
{% highlight bash %}
_netctl-gui() {
_arguments $_netctl_gui_arglist
case "$state" in
essid)
# do not completion, wait for string
;;
files)
# completion from files in this directory
_files
;;
profiles)
# completion from function
# first variable is a description
# second variable is a completion array
_values 'profiles' $(_netctl_profiles)
;;
tab)
# completion from array
_values 'tab' $_netctl_gui_tabs
;;
settings)
# completion from array
# flag -s sets separator and enables multi-selection
_values -s ',' 'settings' $_netctl_gui_settings
;;
esac
}
{% endhighlight %}
<h2><a href="#conclusion" class="anchor" id="conclusion"><span class="octicon octicon-link"></span></a>Conclusion</h2>
<p>File should be places to <code>/usr/share/zsh/site-functions/</code> with any name (it is recommended to set prefix to <code>_</code>). You may found the example <a href="//raw.githubusercontent.com/arcan1s/netctl-gui/master/sources/gui/zsh-completions" title="File" type="text/plain">in my repository</a>.</p>
<p>The additional information may be found in <a href="//github.com/zsh-users/zsh-completions" title="GitHub">zsh-completions</a> repository. For example there is this <a href="//github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org" title="Tutorial">How-To</a>. And also there are a lot of examples.</p>

View File

@ -0,0 +1,151 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: linux, development
title: Writting own Shell completions. Zsh
short: writting-own-completions-p1
---
<figure class="img">![bash_completion](/resources/papers/zsh_completion.png)</figure> Some basics of creating a completion files for own application are described in these articles.
<!--more-->
## <a href="#preamble" class="anchor" id="preamble"><span class="octicon octicon-link"></span></a>Preamble
While developing [one of my projects](/ru/projects/netctl-gui "Netctl-gui project page") I have wanted to add completion files. I have already tried to create these files, but I was too lazy to read some manuals about it.
## <a href="#introduction" class="anchor" id="introduction"><span class="octicon octicon-link"></span></a>Introduction
There are some possible ways to create zsh completion file. In this article I will describe only one of them, which provides a lot of opportunities, but does not require a lot of costs (such as regular expressions).
Lets consider the example of my application, which has a part of help message that looks like this:
```bash
netctl-gui [ -h | --help ] [ -e ESSID | --essid ESSID ] [ -с FILE | --config FILE ]
[ -o PROFILE | --open PROFILE ] [ -t NUM | --tab NUM ] [ --set-opts OPTIONS ]
```
Here is a flag list:
* flags `-h` and `--help` do not require any arguments;
* flags `-e` and `--essid` require a string argument without completion;
* flags `-c` and `--config` require a string argument, which is a file;
* flags `-o` and `--open` require a string argument, there is a completion from files in the specified directory;
* flags `-t` and `--tab` require a string argument, there is a completion from the specified array;
* flag `--set-opts` requires a string argument, there is a completion from the specified array comma separated;
## <a href="#file" class="anchor" id="file"><span class="octicon octicon-link"></span></a>The file pattern
It must be specified in the header that it is a completion file and application for which it will complete (may be string if this file provides completions for several applications):
```bash
#compdef netctl-gui
```
Next there is flags, additional functions and variables declarations. It should be noted that all functions and variables, which will be used for completions, **should return arrays**. In my case this scheme looks like this (I left empty these functions in this chapter):
```bash
# variables
_netctl_gui_arglist=()
_netctl_gui_settings=()
_netctl_gui_tabs=()
_netctl_profiles() {}
```
Then there are main functions, which will be called for completion of specific application. In my case this there is only one applications, so there is only one function:
```bash
# work block
_netctl-gui() {}
```
And finally **without isolation in a separate function** there is a small shamanism, which declares a dependence "application-function":
```bash
case "$service" in
netctl-gui)
_netctl-gui "$@" && return 0
;;
esac
```
## <a href="#flags" class="anchor" id="flags"><span class="octicon octicon-link"></span></a>Flags
As it was said above, there are some different ways to create these files. In particular they differ in the flag declaration and their further processing. In my case I will use `_arguments` command, which require a specific format of variables: `FLAG[description]:MESSAGE:ACTION`. The last two fields are not required and, as you will see below, are not needed in some cases. If you want to add two flags for an action (short and long format), then the format is a little bit complicated: `{(FLAG_2)FLAG_1,(FLAG_1)FLAG_2}[description]:MESSAGE:ACTION`. It should be noted that if you want to create completions for two flags but some flags have not a second format. you will should to add following line: `{FLAG,FLAG}[description]:MESSAGE:ACTION`. `MESSAGE` is a message which will be shown, `ACTION` is an action which will be performed after this flag. In this tutorial `ACTION` will be following: `->STATE`.
So, according to our requirements, flags declaration will be following:
```bash
_netctl_gui_arglist=(
{'(--help)-h','(-h)--help'}'[show help and exit]'
{'(--essid)-e','(-e)--essid'}'[select ESSID]:type ESSID:->essid'
{'(--config)-c','(-c)--config'}'[read configuration from this file]:select file:->files'
{'(--open)-o','(-o)--open'}'[open profile]:select profile:->profiles'
{'(--tab)-t','(-t)--tab'}'[open a tab with specified number]:select tab:->tab'
{'--set-opts','--set-opts'}'[set options for this run, comma separated]:comma separated:->settings'
)
```
## <a href="#variables" class="anchor" id="variables"><span class="octicon octicon-link"></span></a>Arrays of variables
In my case there are two static arrays (which will not be changed):
```bash
_netctl_gui_settings=(
'CTRL_DIR'
'CTRL_GROUP'
)
_netctl_gui_tabs=(
'1'
'2'
)
```
And there is a dynamic array, which should be generated each time. In my case it is a list of files in the specified directory (by the way it may be done by means of zsh):
```bash
_netctl_profiles() {
print $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
}
```
## <a href="#body" class="anchor" id="body"><span class="octicon octicon-link"></span></a>Function
Remember, there was something about a state above? It is stored in the variable `$state` and in this function we will check what it is to choose the appropriate action. At the beginning of the function we should call `_arguments` with our flags.
```bash
_netctl-gui() {
_arguments $_netctl_gui_arglist
case "$state" in
essid)
# do not completion, wait for string
;;
files)
# completion from files in this directory
_files
;;
profiles)
# completion from function
# first variable is a description
# second variable is a completion array
_values 'profiles' $(_netctl_profiles)
;;
tab)
# completion from array
_values 'tab' $_netctl_gui_tabs
;;
settings)
# completion from array
# flag -s sets separator and enables multi-selection
_values -s ',' 'settings' $_netctl_gui_settings
;;
esac
}
```
## <a href="#conclusion" class="anchor" id="conclusion"><span class="octicon octicon-link"></span></a>Conclusion
File should be places to `/usr/share/zsh/site-functions/` with any name (it is recommended to set prefix to `_`). You may found the example [in my repository](//raw.githubusercontent.com/arcan1s/netctl-gui/master/sources/gui/zsh-completions "File").
The additional information may be found in [zsh-completions](//github.com/zsh-users/zsh-completions "GitHub") repository. For example there is this [How-To](//github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org "Tutorial"). And also there are a lot of examples.

View File

@ -1,136 +0,0 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: linux, development
title: Writting own Shell completions. Bash
short: writting-own-completions-p2
description: <figure class="img"><img src="/resources/papers/bash_completion.png" alt="bash_completion"></figure> Some basics of creating a completion files for own application are described in these articles.
---
<h2><a href="#preamble" class="anchor" id="preamble"><span class="octicon octicon-link"></span></a>Preamble</h2>
<p>While developing <a href="/ru/projects/netctl-gui" title="Netctl-gui project page">one of my projects</a> I have wanted to add completion files. I have already tried to create these files, but I was too lazy to read some manuals about it.</p>
<h2><a href="#introduction" class="anchor" id="introduction"><span class="octicon octicon-link"></span></a>Introduction</h2>
<p>Bash, <a href="/ru/2014/07/17/writting-own-completions-p1" title="Zsh completions paper">unlike zsh</a>, demands some dirty workarounds for completions. Cursory have Googled, I have not found a more or less normal tutorials, so it is based on the available <code>pacman</code> completion files in my system.</p>
<p>Lets consider the example of the same my application. I remind you that a part of help message is as follows:</p>
{% highlight bash %}
netctl-gui [ -h | --help ] [ -e ESSID | --essid ESSID ] [ -с FILE | --config FILE ]
[ -o PROFILE | --open PROFILE ] [ -t NUM | --tab NUM ] [ --set-opts OPTIONS ]
{% endhighlight %}
<p>Here is a flag list:</p>
<ul>
<li>flags <code>-h</code> and <code>--help</code> do not require any arguments;</li>
<li>flags <code>-e</code> and <code>--essid</code> require a string argument without completion;</li>
<li>flags <code>-c</code> and <code>--config</code> require a string argument, which is a file;</li>
<li>flags <code>-o</code> and <code>--open</code> require a string argument, there is a completion from files in the specified directory;</li>
<li>flags <code>-t</code> and <code>--tab</code> require a string argument, there is a completion from the specified array;</li>
<li>flag <code>--set-opts</code> requires a string argument, there is a completion from the specified array comma separated;</li>
</ul>
<h2><a href="#file" class="anchor" id="file"><span class="octicon octicon-link"></span></a>The file pattern</h2>
<p>Here <b>all</b> variables must return an array. And there no specific formats. First we declare the flags and then we describe all other variables. As I am not going to describe the functions in more detail below I remind you that <code>_netctl_profiles()</code> should be generated each time:</p>
{% highlight bash %}
# variables
_netctl_gui_arglist=()
_netctl_gui_settings=()
_netctl_gui_tabs=()
_netctl_profiles() {}
{% endhighlight %}
<p>Then there are main functions, which will be called for completion of specific application. In my case this there is only one applications, so there is only one function:</p>
{% highlight bash %}
# work block
_netctl-gui() {}
{% endhighlight %}
<p>And finally again <b>without isolation in a separate function</b> we create a dependence "function-application":</p>
{% highlight bash %}
complete -F _netctl_gui netctl-gui
{% endhighlight %}
<h2><a href="#flags" class="anchor" id="flags"><span class="octicon octicon-link"></span></a>Flags</h2>
<p>As it was said above there is no specific format, so all available flags declare by array:</p>
{% highlight bash %}
_netctl_gui_arglist=(
'-h'
'--help'
'-e'
'--essid'
'-c'
'--config'
'-o'
'--open'
'-t'
'--tab'
'--set-opts'
)
{% endhighlight %}
<h2><a href="#variables" class="anchor" id="variables"><span class="octicon octicon-link"></span></a>Arrays of variables</h2>
<p>I just give a function that looked like this in zsh:</p>
{% highlight bash %}
_netctl_profiles() {
print $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
}
{% endhighlight %}
<p>Bash does not allow to do so, so this function should be a little changed:</p>
{% highlight bash %}
_netctl_profiles() {
echo $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
}
{% endhighlight %}
<h2><a href="#body" class="anchor" id="body"><span class="octicon octicon-link"></span></a>Function</h2>
<p>The variable <code>COMPREPLY</code> responds for completion in Bash. To keep track of the current state function <code>_get_comp_words_by_ref</code> must be called with parameters <code>cur</code> (current flag) and <code>prev</code> (previous flag, it is the state). Also some point for case are needed (variables <code>want*</code>). Function <code>compgen</code> is used for completion generation. A list of words is given after flag <code>-W</code>. (Also there is flag <code>-F</code> which requires a function as argument, but it gives warning for me.) The last argument is a current string to which you want to generate completion.</p>
<p>So, here is our function:</p>
{% highlight bash %}
_netctl_gui() {
COMPREPLY=()
wantfiles='-@(c|-config)'
wantprofiles='-@(o|-open|s|-select)'
wantsettings='-@(-set-opts)'
wanttabs='-@(t|-tab)'
_get_comp_words_by_ref cur prev
if [[ $prev = $wantstring ]]; then
# do not completion, wait for string
COMPREPLY=()
elif [[ $prev = $wantfiles ]]; then
# completion from files in this directory
_filedir
elif [[ $prev = $wantprofiles ]]; then
# completion from function
COMPREPLY=($(compgen -W '${_netctl_profiles[@]}' -- "$cur"))
elif [[ $prev = $wanttabs ]]; then
# completion from array
COMPREPLY=($(compgen -W '${_netctl_gui_tabs[@]}' -- "$cur"))
elif [[ $prev = $wantsettings ]]; then
# completion from array
# flag -S add a comma after completion, but does not enable multi-selection =(
COMPREPLY=($(compgen -S ',' -W '${_netctl_gui_settings[@]}' -- "$cur"))
else
# show all available flags
COMPREPLY=($(compgen -W '${_netctl_gui_arglist[@]}' -- "$cur"))
fi
true
}
{% endhighlight %}
<h2><a href="#conclusion" class="anchor" id="conclusion"><span class="octicon octicon-link"></span></a>Conclusion</h2>
<p>File should be places to <code>/usr/share/bash-completion/completions/</code> with any name. You may found the example <a href="//raw.githubusercontent.com/arcan1s/netctl-gui/master/sources/gui/bash-completions" title="File" type="text/plain">in my repository</a>.</p>

View File

@ -0,0 +1,143 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: linux, development
title: Writting own Shell completions. Bash
short: writting-own-completions-p2
---
<figure class="img">![bash_completion](/resources/papers/bash_completion.png)</figure> Some basics of creating a completion files for own application are described in these articles.
<!--more-->
## <a href="#preamble" class="anchor" id="preamble"><span class="octicon octicon-link"></span></a>Preamble
While developing [one of my projects](/ru/projects/netctl-gui "Netctl-gui project page") I have wanted to add completion files. I have already tried to create these files, but I was too lazy to read some manuals about it.
## <a href="#introduction" class="anchor" id="introduction"><span class="octicon octicon-link"></span></a>Introduction
Bash, [unlike zsh](/ru/2014/07/17/writting-own-completions-p1 "Zsh completions paper"), demands some dirty workarounds for completions. Cursory have Googled, I have not found a more or less normal tutorials, so it is based on the available `pacman` completion files in my system.
Lets consider the example of the same my application. I remind you that a part of help message is as follows:
```bash
netctl-gui [ -h | --help ] [ -e ESSID | --essid ESSID ] [ -с FILE | --config FILE ]
[ -o PROFILE | --open PROFILE ] [ -t NUM | --tab NUM ] [ --set-opts OPTIONS ]
```
Here is a flag list:
* flags `-h` and `--help` do not require any arguments;
* flags `-e` and `--essid` require a string argument without completion;
* flags `-c` and `--config` require a string argument, which is a file;
* flags `-o` and `--open` require a string argument, there is a completion from files in the specified directory;
* flags `-t` and `--tab` require a string argument, there is a completion from the specified array;
* flag `--set-opts` requires a string argument, there is a completion from the specified array comma separated;
## <a href="#file" class="anchor" id="file"><span class="octicon octicon-link"></span></a>The file pattern
Here **all** variables must return an array. And there no specific formats. First we declare the flags and then we describe all other variables. As I am not going to describe the functions in more detail below I remind you that `_netctl_profiles()` should be generated each time:
```bash
# variables
_netctl_gui_arglist=()
_netctl_gui_settings=()
_netctl_gui_tabs=()
_netctl_profiles() {}
```
Then there are main functions, which will be called for completion of specific application. In my case this there is only one applications, so there is only one function:
```bash
# work block
_netctl-gui() {}
```
And finally again **without isolation in a separate function** we create a dependence "function-application":
```bash
complete -F _netctl_gui netctl-gui
```
## <a href="#flags" class="anchor" id="flags"><span class="octicon octicon-link"></span></a>Flags
As it was said above there is no specific format, so all available flags declare by array:
```bash
_netctl_gui_arglist=(
'-h'
'--help'
'-e'
'--essid'
'-c'
'--config'
'-o'
'--open'
'-t'
'--tab'
'--set-opts'
)
```
## <a href="#variables" class="anchor" id="variables"><span class="octicon octicon-link"></span></a>Arrays of variables
I just give a function that looked like this in zsh:
```bash
_netctl_profiles() {
print $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
}
```
Bash does not allow to do so, so this function should be a little changed:
```bash
_netctl_profiles() {
echo $(find /etc/netctl -maxdepth 1 -type f -printf "%f\n")
}
```
## <a href="#body" class="anchor" id="body"><span class="octicon octicon-link"></span></a>Function
The variable `COMPREPLY` responds for completion in Bash. To keep track of the current state function `_get_comp_words_by_ref` must be called with parameters `cur` (current flag) and `prev` (previous flag, it is the state). Also some point for case are needed (variables `want*`). Function `compgen` is used for completion generation. A list of words is given after flag `-W`. (Also there is flag `-F` which requires a function as argument, but it gives warning for me.) The last argument is a current string to which you want to generate completion.
So, here is our function:
```bash
_netctl_gui() {
COMPREPLY=()
wantfiles='-@(c|-config)'
wantprofiles='-@(o|-open|s|-select)'
wantsettings='-@(-set-opts)'
wanttabs='-@(t|-tab)'
_get_comp_words_by_ref cur prev
if [[ $prev = $wantstring ]]; then
# do not completion, wait for string
COMPREPLY=()
elif [[ $prev = $wantfiles ]]; then
# completion from files in this directory
_filedir
elif [[ $prev = $wantprofiles ]]; then
# completion from function
COMPREPLY=($(compgen -W '${_netctl_profiles[@]}' -- "$cur"))
elif [[ $prev = $wanttabs ]]; then
# completion from array
COMPREPLY=($(compgen -W '${_netctl_gui_tabs[@]}' -- "$cur"))
elif [[ $prev = $wantsettings ]]; then
# completion from array
# flag -S add a comma after completion, but does not enable multi-selection =(
COMPREPLY=($(compgen -S ',' -W '${_netctl_gui_settings[@]}' -- "$cur"))
else
# show all available flags
COMPREPLY=($(compgen -W '${_netctl_gui_arglist[@]}' -- "$cur"))
fi
true
}
```
## <a href="#conclusion" class="anchor" id="conclusion"><span class="octicon octicon-link"></span></a>Conclusion
File should be places to `/usr/share/bash-completion/completions/` with any name. You may found the example [in my repository](//raw.githubusercontent.com/arcan1s/netctl-gui/master/sources/gui/bash-completions "File").

View File

@ -1,38 +0,0 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: awesome-widgets, pytextmonitor
title: Migration Awesome Widgets (ex-PyTextMonitor) to version 2.0
short: migration-to-v2
description: <figure class="img"><img src="/resources/papers/broken-computer.jpg" alt="broken-computer"></figure>Some significant changes occur in the version 2.0 (really, I didn't do anything which can break your desktop!) and user API was rewritten. This paper should help to migrate from older PyTextMonitor versions (<1.11.0) to new one (>2.0).
---
<h2><a href="#new" class="anchor" id="new"><span class="octicon octicon-link"></span></a>New features</h2>
<p>Firstly, a series of new features, including:</p>
<ul>
<li>New widget - <b>Desktop panel</b>. It shows desktop list and select the active one. It can switch to the selected desktop by mouse clicking. Also it may set selected panels hidden.</li>
<li>New tags - <code>hddfreemb</code>, <code>hddfreegb</code>, <code>memusedmb</code>, <code>memusedgb</code>, <code>memfreemb</code>, <code>memfreegb</code>, <code>swapfreemb</code>, <code>swapfreegb</code>. And there are new tags related to new features - <code>desktop</code>, <code>ndesktop</code>, <code>tdesktops</code>.</li>
<li>New graphical tooltip - battery. It is twin colour (the colour depends on AC status).</li>
</ul>
<h2><a href="#changes" class="anchor" id="changes"><span class="octicon octicon-link"></span></a>Significant changes</h2>
<p>Secondly, there are some changes because of which the old settings <b>will not</b> more work. They are:</p>
<ul>
<li>The main widget was rewritten to <code>С++</code>, so the project was renamed to <b>Awesome Widgets</b>, and the main widget was done to <b>Awesome Widget</b></li>
<li>Configuration of battery and AC files <b>was moved to DataEngine</b>.</li>
<li><b>The labels was removed</b>. Now the widget is a single label. You may set up text in the special browser.</li>
<li>According to removal of the label, tooltip <b>should be configured separately</b>.</li>
<li>Align of text now can be configured only by using HTML tags.</li>
<li>According to fields combining several tags were renamed:
<ul>
<li><code>custom</code> (time) -&gt; <code>ctime</code></li>
<li><code>custom</code> (uptime) -&gt; <code>cuptime</code></li>
<li><code>time</code> (player) -&gt; <code>duration</code></li>
</ul>
</li>
</ul>
<p>On any issues related to the migration, feel free to leave a comment here.</p>

View File

@ -0,0 +1,36 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: awesome-widgets, pytextmonitor
title: Migration Awesome Widgets (ex-PyTextMonitor) to version 2.0
short: migration-to-v2
---
<figure class="img">![broken-computer](/resources/papers/broken-computer.jpg)</figure>Some significant changes occur in the version 2.0 (really, I didn't do anything which can break your desktop!) and user API was rewritten. This paper should help to migrate from older PyTextMonitor versions (<1.11.0) to new one (>2.0).
<!--more-->
## <a href="#new" class="anchor" id="new"><span class="octicon octicon-link"></span></a>New features
Firstly, a series of new features, including:
* New widget - **Desktop panel**. It shows desktop list and select the active one. It can switch to the selected desktop by mouse clicking. Also it may set selected panels hidden.
* New tags - `hddfreemb`, `hddfreegb`, `memusedmb`, `memusedgb`, `memfreemb`, `memfreegb`, `swapfreemb`, `swapfreegb`. And there are new tags related to new features - `desktop`, `ndesktop`, `tdesktops`.
* New graphical tooltip - battery. It is twin colour (the colour depends on AC status).
## <a href="#changes" class="anchor" id="changes"><span class="octicon octicon-link"></span></a>Significant changes
Secondly, there are some changes because of which the old settings **will not** more work. They are:
* The main widget was rewritten to `С++`, so the project was renamed to **Awesome Widgets**, and the main widget was done to **Awesome Widget**
* Configuration of battery and AC files **was moved to DataEngine**.
* **The labels was removed**. Now the widget is a single label. You may set up text in the special browser.
* According to removal of the label, tooltip **should be configured separately**.
* Align of text now can be configured only by using HTML tags.
* According to fields combining several tags were renamed:
* `custom` (time) -> `ctime`
* `custom` (uptime) -> `cuptime`
* `time` (player) -> `duration`
On any issues related to the migration, feel free to leave a comment here.

View File

@ -1,173 +0,0 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: linux, systemd, ecryptfs
title: How to encrypt home directory. For dummies
short: ecnryption-home-directory
description: <figure class="img"><img src="/resources/papers/single-door.jpg" alt="single-door"></figure>This paper is about encryption home directory using ecryptfs and automount settins using systemd and key on flash card.
---
<h2><a href="#preparation" class="anchor" id="preparation"><span class="octicon octicon-link"></span></a>Step 0: Preparation</h2>
<ol>
<li>Logout as user.</li>
<li>Login as root on tty. The following actions should be done as root.</li>
<li>Move your home directory and create empty directory (<code>s/$USER/user name/</code>):
{% highlight bash %}
mv /home/{$USER,$USER-org}
mkdir /home/$USER
chmod 700 /home/$USER
chown $USER:users /home/$USER
{% endhighlight %}
</li>
</ol>
<h2><a href="#step1" class="anchor" id="step1"><span class="octicon octicon-link"></span></a>Step 1: Encryption</h2>
<p>The widespread solution in the Internet is to use automatic utilities to do it. However in our case they are not suitable, since we need to import key / password signature, which is not possible in this case.</p>
<p>The encryption can be done by the following command (lol):</p>
{% highlight bash %}
mount -t ecryptfs /home/$USER /home/$USER
{% endhighlight %}
<p>While process it asks some question (I suggest to do first mounting in the interactive mode). The answers may be like following (see the comments),
please note that if you change something, it will be changed in some lines below too:</p>
{% highlight bash %}
# key or certificate. The second one is more reliable while you don't lose it %)
Select key type to use for newly created files:
1) passphrase
2) openssl
Selection: 1
# password
Passphrase:
# cipher, select default
Select cipher:
1) aes: blocksize = 16; min keysize = 16; max keysize = 32
2) blowfish: blocksize = 8; min keysize = 16; max keysize = 56
3) des3_ede: blocksize = 8; min keysize = 24; max keysize = 24
4) twofish: blocksize = 16; min keysize = 16; max keysize = 32
5) cast6: blocksize = 16; min keysize = 16; max keysize = 32
6) cast5: blocksize = 8; min keysize = 5; max keysize = 16
Selection [aes]: 1
# key size, select default
Select key bytes:
1) 16
2) 32
3) 24
Selection [16]: 1
# enable reading/writing to the non-encrypted files
Enable plaintext passthrough (y/n) [n]: n
# enable filename encryption
Enable filename encryption (y/n) [n]: y
Filename Encryption Key (FNEK) Signature [XXXXX]:
# toolongdontread
Attempting to mount with the following options:
ecryptfs_unlink_sigs
ecryptfs_fnek_sig=XXXXX
ecryptfs_key_bytes=16
ecryptfs_cipher=aes
ecryptfs_sig=XXXXX
WARNING: Based on the contents of [/root/.ecryptfs/sig-cache.txt],
it looks like you have never mounted with this key
before. This could mean that you have typed your
passphrase wrong.
# accept, quit
Would you like to proceed with the mount (yes/no)? : yes
Would you like to append sig [XXXXX] to
[/root/.ecryptfs/sig-cache.txt]
in order to avoid this warning in the future (yes/no)? : yes
Successfully appended new sig to user sig cache file
Mounted eCryptfs
{% endhighlight %}
<p>Then copy files from home directory to encrypted one:</p>
{% highlight bash %}
cp -a /home/$USER-org/. /home/$USER
{% endhighlight %}
<h2><a href="#step2" class="anchor" id="step2"><span class="octicon octicon-link"></span></a>Step 2: systemd automounting</h2>
<p>Create file on flash card (I've used microSD) with the following text (you should insert your password):</p>
{% highlight bash %}
passphrase_passwd=someverystronguniqpassword
{% endhighlight %}
<p>Add card automount (mount point is <code>/mnt/key</code>) to <code>fstab</code> with option <code>ro</code>, for example:</p>
{% highlight bash %}
UUID=dc3ecb41-bc40-400a-b6bf-65c5beeb01d7 /mnt/key ext2 ro,defaults 0 0
{% endhighlight %}
<p>Let's configure home directory mounting. The mount options can be found in the following output:</p>
{% highlight bash %}
mount | grep ecryptfs
{% endhighlight %}
<p>I should note that there are not all options there, you need add <code>key</code>, <code>no_sig_cache</code>, <code>ecryptfs_passthrough</code> too. Thus systemd mount-unit should be like the following (if you are systemd-hater you can write the own daemon, because it doesn't work over <code>fstab</code> without modification (see below)).</p>
{% highlight bash %}
# cat /etc/systemd/system/home-$USER.mount
[Unit]
Before=local-fs.target
After=mnt-key.mount
[Mount]
What=/home/$USER
Where=/home/$USER
Type=ecryptfs
Options=rw,nosuid,nodev,relatime,key=passphrase:passphrase_passwd_file=/mnt/key/keyfile,no_sig_cache,ecryptfs_fnek_sig=XXXXX,ecryptfs_sig=XXXXX,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_passthrough=n,ecryptfs_unlink_sigs
[Install]
WantedBy=local-fs.target
{% endhighlight %}
<p><code>XXXXX</code> should be replaced to signature from options with which directory are currently mounting. Also you need to insert user name and edit path to file with password (and unit name) if it is needed. Autoload:</p>
{% highlight bash %}
systemctl enable home-$USER.mount
{% endhighlight %}
<p>Here is a service to unmount flash card when it will be unneeded:</p>
{% highlight bash %}
# cat /etc/systemd/system/umount-key.service
[Unit]
Description=Unmount key card
Before=local-fs.target
After=home-arcanis.mount
[Service]
Type=oneshot
ExecStart=/usr/bin/umount /mnt/key
[Install]
WantedBy=local-fs.target
{% endhighlight %}
<p>Enable:</p>
{% highlight bash %}
systemctl enable umount-key.service
{% endhighlight %}
<p>Reboot. Remove backups if all is ok. If not then you did a mistake, resurrect system from emergency mode.</p>
<h2><a href="#whynotfstab" class="anchor" id="whynotfstab"><span class="octicon octicon-link"></span></a>Why not fstab?</h2>
<p>In my case I could not to make flash mounting before home decryption. Thus I saw emergency mode on load in which I should just continue loading. There are two solutions in the Internet:</p>
<ul>
<li>Create entry with noauto option and then mount using the special command in <code>rc.local</code>.</li>
<li>Create entry with nofail option and then remount all partitions in <code>rc.local</code>.</li>
</ul>
<p>In my opinion both of them are workarounds too much.</p>
<h2><a href="#whynotpam" class="anchor" id="whynotpam"><span class="octicon octicon-link"></span></a>Why not pam?</h2>
<p>Other solution is to mount using pam entry. In my case I have authentication without password on fingerprint so it doesn't work for me.</p>

View File

@ -0,0 +1,175 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: linux, systemd, ecryptfs
title: How to encrypt home directory. For dummies
short: ecnryption-home-directory
---
<figure class="img">![single-door](/resources/papers/single-door.jpg)</figure>This paper is about encryption home directory using ecryptfs and automount settins using systemd and key on flash card.
<!--more-->
## <a href="#preparation" class="anchor" id="preparation"><span class="octicon octicon-link"></span></a>Step 0: Preparation
1. Logout as user.
2. Login as root on tty. The following actions should be done as root.
3. Move your home directory and create empty directory (`s/$USER/user name/`):
```bash
mv /home/{$USER,$USER-org}
mkdir /home/$USER
chmod 700 /home/$USER
chown $USER:users /home/$USER
```
## <a href="#step1" class="anchor" id="step1"><span class="octicon octicon-link"></span></a>Step 1: Encryption
The widespread solution in the Internet is to use automatic utilities to do it. However in our case they are not suitable, since we need to import key / password signature, which is not possible in this case.
The encryption can be done by the following command (lol):
```bash
mount -t ecryptfs /home/$USER /home/$USER
```
While process it asks some question (I suggest to do first mounting in the interactive mode). The answers may be like following (see the comments),
please note that if you change something, it will be changed in some lines below too:
```bash
# key or certificate. The second one is more reliable while you don't lose it %)
Select key type to use for newly created files:
1) passphrase
2) openssl
Selection: 1
# password
Passphrase:
# cipher, select default
Select cipher:
1) aes: blocksize = 16; min keysize = 16; max keysize = 32
2) blowfish: blocksize = 8; min keysize = 16; max keysize = 56
3) des3_ede: blocksize = 8; min keysize = 24; max keysize = 24
4) twofish: blocksize = 16; min keysize = 16; max keysize = 32
5) cast6: blocksize = 16; min keysize = 16; max keysize = 32
6) cast5: blocksize = 8; min keysize = 5; max keysize = 16
Selection [aes]: 1
# key size, select default
Select key bytes:
1) 16
2) 32
3) 24
Selection [16]: 1
# enable reading/writing to the non-encrypted files
Enable plaintext passthrough (y/n) [n]: n
# enable filename encryption
Enable filename encryption (y/n) [n]: y
Filename Encryption Key (FNEK) Signature [XXXXX]:
# toolongdontread
Attempting to mount with the following options:
ecryptfs_unlink_sigs
ecryptfs_fnek_sig=XXXXX
ecryptfs_key_bytes=16
ecryptfs_cipher=aes
ecryptfs_sig=XXXXX
WARNING: Based on the contents of [/root/.ecryptfs/sig-cache.txt],
it looks like you have never mounted with this key
before. This could mean that you have typed your
passphrase wrong.
# accept, quit
Would you like to proceed with the mount (yes/no)? : yes
Would you like to append sig [XXXXX] to
[/root/.ecryptfs/sig-cache.txt]
in order to avoid this warning in the future (yes/no)? : yes
Successfully appended new sig to user sig cache file
Mounted eCryptfs
```
Then copy files from home directory to encrypted one:
```bash
cp -a /home/$USER-org/. /home/$USER
```
## <a href="#step2" class="anchor" id="step2"><span class="octicon octicon-link"></span></a>Step 2: systemd automounting
Create file on flash card (I've used microSD) with the following text (you should insert your password):
```bash
passphrase_passwd=someverystronguniqpassword
```
Add card automount (mount point is `/mnt/key`) to `fstab` with option `ro`, for example:
```bash
UUID=dc3ecb41-bc40-400a-b6bf-65c5beeb01d7 /mnt/key ext2 ro,defaults 0 0
```
Let's configure home directory mounting. The mount options can be found in the following output:
```bash
mount | grep ecryptfs
```
I should note that there are not all options there, you need add `key`, `no_sig_cache`, `ecryptfs_passthrough` too. Thus systemd mount-unit should be like the following (if you are systemd-hater you can write the own daemon, because it doesn't work over `fstab` without modification (see below)).
```bash
# cat /etc/systemd/system/home-$USER.mount
[Unit]
Before=local-fs.target
After=mnt-key.mount
[Mount]
What=/home/$USER
Where=/home/$USER
Type=ecryptfs
Options=rw,nosuid,nodev,relatime,key=passphrase:passphrase_passwd_file=/mnt/key/keyfile,no_sig_cache,ecryptfs_fnek_sig=XXXXX,ecryptfs_sig=XXXXX,ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_passthrough=n,ecryptfs_unlink_sigs
[Install]
WantedBy=local-fs.target
```
`XXXXX` should be replaced to signature from options with which directory are currently mounting. Also you need to insert user name and edit path to file with password (and unit name) if it is needed. Autoload:
```bash
systemctl enable home-$USER.mount
```
Here is a service to unmount flash card when it will be unneeded:
```bash
# cat /etc/systemd/system/umount-key.service
[Unit]
Description=Unmount key card
Before=local-fs.target
After=home-arcanis.mount
[Service]
Type=oneshot
ExecStart=/usr/bin/umount /mnt/key
[Install]
WantedBy=local-fs.target
```
Enable:
```bash
systemctl enable umount-key.service
```
Reboot. Remove backups if all is ok. If not then you did a mistake, resurrect system from emergency mode.
## <a href="#whynotfstab" class="anchor" id="whynotfstab"><span class="octicon octicon-link"></span></a>Why not fstab?
In my case I could not to make flash mounting before home decryption. Thus I saw emergency mode on load in which I should just continue loading. There are two solutions in the Internet:
* Create entry with noauto option and then mount using the special command in `rc.local`.
* Create entry with nofail option and then remount all partitions in `rc.local`.
In my opinion both of them are workarounds too much.
## <a href="#whynotpam" class="anchor" id="whynotpam"><span class="octicon octicon-link"></span></a>Why not pam?
Other solution is to mount using pam entry. In my case I have authentication without password on fingerprint so it doesn't work for me.

View File

@ -1,327 +0,0 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: awesome-widgets, pytextmonitor
title: Awesome Widgets - bells and whistles
short: aw-v21-bells-and-whistles
description: The paper deals with settings of a custom scripts and graphical bars in the new version of Awesome Widgets (2.1).
---
<h2><a href="#intro" class="anchor" id="intro"><span class="octicon octicon-link"></span></a>Introduction</h2>
<p>For a start it is highly recommended copy file <code>$HOME/.kde4/share/config/extsysmon.conf</code> after widget update before you open widget settings, because old and new script settings are incompatible. Also I should note that these features can be configured from graphical interface, but I will describe how it can be done by simply editing the desktop file.</p>
<h2><a href="#general" class="anchor" id="general"><span class="octicon octicon-link"></span></a>General</h2>
<p>Items are stored in the two directories: <code>/usr/share/awesomewidgets/%TYPE%/</code> and <code>$HOME/.local/share/awesomewidgets/%TYPE%/</code> (path may be differ in depend from your distro). Settings in the home directory have a higher priority that global ones.</p>
<h2><a href="#bars" class="anchor" id="bars"><span class="octicon octicon-link"></span></a>Bars</h2>
<p>Directory is <code>desktops</code>, configuration files have the following fields:</p>
<table>
<tr>
<th>Field</th>
<th>Required</th>
<th>Value</th>
<th>Default</th>
</tr>
<tr>
<th>Name</th>
<td>yes</td>
<td>bar name. It should be as <code>barN</code> and should be unique</td>
<td>none</td>
</tr>
<tr>
<th>Comment</th>
<td>no</td>
<td>comment</td>
<td>empty</td>
</tr>
<tr>
<th>X-AW-Value</th>
<td>yes</td>
<td>bar value. The following tags are available <code>cpu*</code>, <code>gpu</code>, <code>mem</code>, <code>swap</code>, <code>hdd*</code>, <code>bat</code></td>
<td>cpu</td>
</tr>
<tr>
<th>X-AW-ActiveColor</th>
<td>yes</td>
<td>active part fill in format <code>R,G,B,A</code></td>
<td>0,0,0,130</td>
</tr>
<tr>
<th>X-AW-InactiveColor</th>
<td>yes</td>
<td>inactive part fill in format <code>R,G,B,A</code></td>
<td>255,255,255,130</td>
</tr>
<tr>
<th>X-AW-Type</th>
<td>yes</td>
<td>bar type. The following types are supported <code>Horizontal</code>, <code>Vertical</code>, <code>Circle</code>, <code>Graph</code></td>
<td>Horizontal</td>
</tr>
<tr>
<th>X-AW-Direction</th>
<td>yes</td>
<td>the fill direction. The following variants are supported <code>LeftToRight</code>, <code>RightToLeft</code></td>
<td>LeftToRight</td>
</tr>
<tr>
<th>X-AW-Height</th>
<td>yes</td>
<td>height, pixels</td>
<td>100</td>
</tr>
<tr>
<th>X-AW-Width</th>
<td>yes</td>
<td>width, pixels</td>
<td>100</td>
</tr>
<tr>
<th>X-AW-Number</th>
<td>yes</td>
<td>unique number which will be associated with the bar. The property has been introduced to provide compatibility with others items. Should be the same as number in Name is</td>
<td>number from Name</td>
</tr>
</table>
<h2><a href="#quotes" class="anchor" id="quotes"><span class="octicon octicon-link"></span></a>Quotes</h2>
<p>Directory is <code>quotes</code>, configuration files have the following fields:</p>
<table>
<tr>
<th>Field</th>
<th>Required</th>
<th>Value</th>
<th>Default</th>
</tr>
<tr>
<th>Name</th>
<td>yes</td>
<td>quotes name</td>
<td>none</td>
</tr>
<tr>
<th>Comment</th>
<td>no</td>
<td>comment</td>
<td>empty</td>
</tr>
<tr>
<th>X-AW-Ticker</th>
<td>yes</td>
<td>ticker from Yahoo! Finance system</td>
<td>EURUSD=X</td>
</tr>
<tr>
<th>X-AW-Active</th>
<td>no</td>
<td>whether or not the quotes is active</td>
<td>true</td>
</tr>
<tr>
<th>X-AW-Interval</th>
<td>no</td>
<td>update interval in standard widget intervals</td>
<td>1</td>
</tr>
<tr>
<th>X-AW-Number</th>
<td>yes</td>
<td>unique number which will be associated with the script</td>
<td>random number which is less than 1000</td>
</tr>
</table>
<h2><a href="#scripts" class="anchor" id="scripts"><span class="octicon octicon-link"></span></a>Scripts</h2>
<p>Directory is <code>scripts</code>, configuration files have the following fields:</p>
<table>
<tr>
<th>Field</th>
<th>Required</th>
<th>Value</th>
<th>Default</th>
</tr>
<tr>
<th>Name</th>
<td>yes</td>
<td>script name</td>
<td>none</td>
</tr>
<tr>
<th>Comment</th>
<td>no</td>
<td>comment</td>
<td>empty</td>
</tr>
<tr>
<th>Exec</th>
<td>yes</td>
<td>path to executable file</td>
<td>/usr/bin/true</td>
</tr>
<tr>
<th>X-AW-Prefix</th>
<td>no</td>
<td>prefix to executable file. Usually it's not required, but in other you may want to specify interpreter for example</td>
<td></td>
</tr>
<tr>
<th>X-AW-Active</th>
<td>no</td>
<td>whether or not the script is active</td>
<td>true</td>
</tr>
<tr>
<th>X-AW-Redirect</th>
<td>no</td>
<td>stream redirection. The following variants are available <code>stderr2stdout</code>, <code>nothing</code>, <code>stdout2stderr</code>, <code>swap</code>. stderr will be available, if you run application in the debug mode</td>
<td>nothing</td>
</tr>
<tr>
<th>X-AW-Interval</th>
<td>no</td>
<td>update interval in standard widget intervals</td>
<td>1</td>
</tr>
<tr>
<th>X-AW-Number</th>
<td>yes</td>
<td>unique number which will be associated with the script</td>
<td>random number which is less than 1000</td>
</tr>
<tr>
<th>X-AW-Filters</th>
<td>no</td>
<td>comma separated filters from <code>awesomewidgets-extscripts-filters.json</code></td>
<td></td>
</tr>
</table>
<h2><a href="#upgrade" class="anchor" id="upgrade"><span class="octicon octicon-link"></span></a>Upgrade</h2>
<p>Directory is <code>upgrade</code>, configuration files have the following fields:</p>
<table>
<tr>
<th>Field</th>
<th>Required</th>
<th>Value</th>
<th>Default</th>
</tr>
<tr>
<th>Name</th>
<td>yes</td>
<td>upgrade name</td>
<td>none</td>
</tr>
<tr>
<th>Comment</th>
<td>no</td>
<td>comment</td>
<td>empty</td>
</tr>
<tr>
<th>Exec</th>
<td>yes</td>
<td>path to executable file</td>
<td>/usr/bin/true</td>
</tr>
<tr>
<th>X-AW-Filter</th>
<td>no</td>
<td>the regexp which will be applied to command output. If set <code>X-AW-Null</code> will be ignored</td>
<td></td>
</tr>
<tr>
<th>X-AW-Active</th>
<td>no</td>
<td>whether or not the upgrade script is active</td>
<td>true</td>
</tr>
<tr>
<th>X-AW-Null</th>
<td>no</td>
<td>the number of lines which should be skipped in output</td>
<td>0</td>
</tr>
<tr>
<th>X-AW-Interval</th>
<td>no</td>
<td>update interval in standard widget intervals</td>
<td>1</td>
</tr>
<tr>
<th>X-AW-Number</th>
<td>yes</td>
<td>unique number which will be associated with the upgrade script</td>
<td>random number which is less than 1000</td>
</tr>
</table>
<h2><a href="#weather" class="anchor" id="weather"><span class="octicon octicon-link"></span></a>Weather</h2>
<p>The weather uses data and API from <a href="//openweathermap.org/" title="OpenWeatherMap site">OpenWeatherMap</a>. Directory is <code>weather</code>, configuration files have the following fields:</p>
<table>
<tr>
<th>Field</th>
<th>Required</th>
<th>Value</th>
<th>Default</th>
</tr>
<tr>
<th>Name</th>
<td>yes</td>
<td>weather name</td>
<td>none</td>
</tr>
<tr>
<th>Comment</th>
<td>no</td>
<td>comment</td>
<td>empty</td>
</tr>
<tr>
<th>X-AW-City</th>
<td>yes</td>
<td>city</td>
<td>London</td>
</tr>
<tr>
<th>X-AW-Country</th>
<td>yes</td>
<td>two-letter country code</td>
<td>uk</td>
</tr>
<tr>
<th>X-AW-Image</th>
<td>no</td>
<td>use images as weather icon or text.</td>
<td>false</td>
</tr>
<tr>
<th>X-AW-TS</th>
<td>yes</td>
<td>time to which weather should be. <code>0</code> is a current weather, <code>1</code> - weather 3 hours later, etc</td>
<td>0</td>
</tr>
<tr>
<th>X-AW-Active</th>
<td>no</td>
<td>whether or not the monitor is active</td>
<td>true</td>
</tr>
<tr>
<th>X-AW-Interval</th>
<td>no</td>
<td>update interval in standard widget intervals</td>
<td>1</td>
</tr>
<tr>
<th>X-AW-Number</th>
<td>yes</td>
<td>unique number which will be associated with the upgrade weather</td>
<td>random number which is less than 1000</td>
</tr>
</table>

View File

@ -0,0 +1,97 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: awesome-widgets, pytextmonitor
title: Awesome Widgets - bells and whistles
short: aw-v21-bells-and-whistles
---
The paper deals with settings of a custom scripts and graphical bars in the new version of Awesome Widgets (2.1).
<!--more-->
## <a href="#intro" class="anchor" id="intro"><span class="octicon octicon-link"></span></a>Introduction
For a start it is highly recommended copy file `$HOME/.kde4/share/config/extsysmon.conf` after widget update before you open widget settings, because old and new script settings are incompatible. Also I should note that these features can be configured from graphical interface, but I will describe how it can be done by simply editing the desktop file.
## <a href="#general" class="anchor" id="general"><span class="octicon octicon-link"></span></a>General
Items are stored in the two directories: `/usr/share/awesomewidgets/%TYPE%/` and `$HOME/.local/share/awesomewidgets/%TYPE%/` (path may be differ in depend from your distro). Settings in the home directory have a higher priority that global ones.
## <a href="#bars" class="anchor" id="bars"><span class="octicon octicon-link"></span></a>Bars
Directory is `desktops`, configuration files have the following fields:
| Field | Required | Value | Default |
| -------------------|----------|----------------------------------|------------|
| Name | yes | bar name. It should be as `barN` and should be unique | none |
| Comment | no | comment | empty |
| X-AW-Value | yes | bar value. The following tags are available `cpu*`, `gpu`, `mem`, `swap`, `hdd*`, `bat` | cpu |
| X-AW-ActiveColor | yes | active part fill in format `R,G,B,A` | 0,0,0,130 |
| X-AW-InactiveColor | yes | inactive part fill in format `R,G,B,A` | 255,255,255,130 |
| X-AW-Type | yes | bar type. The following types are supported `Horizontal`, `Vertical`, `Circle`, `Graph` | Horizontal |
| X-AW-Direction | yes | the fill direction. The following variants are supported `LeftToRight`, `RightToLeft` | LeftToRight |
| X-AW-Height | yes | height, pixels | 100 |
| X-AW-Width | yes | width, pixels | 100 |
| X-AW-Number | yes | unique number which will be associated with the bar. The property has been introduced to provide compatibility with others items. Should be the same as number in Name is | number from Name |
## <a href="#quotes" class="anchor" id="quotes"><span class="octicon octicon-link"></span></a>Quotes
Directory is `quotes`, configuration files have the following fields:
| Field | Required | Value | Default |
|-------|----------|-------|---------|
| Name | yes | quotes name | none |
| Comment | no | comment | empty |
| X-AW-Ticker | yes | ticker from Yahoo! Finance system | EURUSD=X |
| X-AW-Active | no | whether or not the quotes is active | true |
| X-AW-Interval | no | update interval in standard widget intervals | 1 |
| X-AW-Number | yes | unique number which will be associated with the script | random number which is less than 1000 |
## <a href="#scripts" class="anchor" id="scripts"><span class="octicon octicon-link"></span></a>Scripts
Directory is `scripts`, configuration files have the following fields:
| Field | Required | Value | Default |
|-------|----------|-------|---------|
| Name | yes | script name | none |
| Comment | no | comment | empty |
| Exec | yes | path to executable file | /usr/bin/true |
| X-AW-Prefix | no | prefix to executable file. Usually it's not required, but in other you may want to specify interpreter for example |
| X-AW-Active | no | whether or not the script is active | true |
| X-AW-Redirect | no | stream redirection. The following variants are available `stderr2stdout`, `nothing`, `stdout2stderr`, `swap`. stderr will be available, if you run application in the debug mode | nothing |
| X-AW-Interval | no | update interval in standard widget intervals | 1 |
| X-AW-Number | yes | unique number which will be associated with the script | random number which is less than 1000 |
| X-AW-Filters | no | comma separated filters from `awesomewidgets-extscripts-filters.json` |
## <a href="#upgrade" class="anchor" id="upgrade"><span class="octicon octicon-link"></span></a>Upgrade
Directory is `upgrade`, configuration files have the following fields:
| Field | Required | Value | Default |
|-------|----------|-------|---------|
| Name | yes | upgrade name | none |
| Comment | no | comment | empty |
| Exec | yes | path to executable file | /usr/bin/true |
| X-AW-Filter | no | the regexp which will be applied to command output. If set `X-AW-Null` will be ignored |
| X-AW-Active | no | whether or not the upgrade script is active | true |
| X-AW-Null | no | the number of lines which should be skipped in output | 0 |
| X-AW-Interval | no | update interval in standard widget intervals | 1 |
| X-AW-Number | yes | unique number which will be associated with the upgrade script | random number which is less than 1000 |
## <a href="#weather" class="anchor" id="weather"><span class="octicon octicon-link"></span></a>Weather
The weather uses data and API from [OpenWeatherMap](//openweathermap.org/ "OpenWeatherMap site"). Directory is `weather`, configuration files have the following fields:
| Field | Required | Value | Default |
|-------|----------|-------|---------|
| Name | yes | weather name | none |
| Comment | no | comment | empty |
| X-AW-City | yes | city | London |
| X-AW-Country | yes | two-letter country code | uk |
| X-AW-Image | no | use images as weather icon or text. | false |
| X-AW-TS | yes | time to which weather should be. `0` is a current weather, `1` - weather 3 hours later, etc | 0 |
| X-AW-Active | no | whether or not the monitor is active | true |
| X-AW-Interval | no | update interval in standard widget intervals | 1 |
| X-AW-Number | yes | unique number which will be associated with the upgrade weather | random number which is less than 1000 |

View File

@ -1,161 +0,0 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: development, c++, cmake
title: Add cppcheck and clang-format for a cmake project
short: cppcheck-and-clang-format
description: A small How-To which describes how to add automatic code style checking and static analyser to a project on <code>C++</code> which uses <code>cmake</code> as a build system.
---
<h2><a href="#project" class="anchor" id="project"><span class="octicon octicon-link"></span></a>Project</h2>
<p>The project has the following structure:</p>
{% highlight bash %}
sources/
|- CMakeLists.txt
|- 3rdparty/
|- first_component/
|- second_component/
{% endhighlight %}
<p><b>3rdparty</b> is a directory which contains additional libraries and which should be excluded from checking (<code>PROJECT_TRDPARTY_DIR</code> cmake variable is used to indicate path to this directory). Also let's assume that we have additional files (e.g. <code>*.qml</code>) in addition to common source files (<code>*.cpp</code>, <code>*.h</code>).</p>
<p>In addition the described below commands may be inserted to pre-commit hook; it allows us to troll colleagues which will be able to commit nothing till they read <code>CONTRIBUTING.md</code>.</p>
<h2><a href="#cppcheck" class="anchor" id="cppcheck"><span class="octicon octicon-link"></span></a>cppcheck</h2>
<p>As far as there are no good (out-of-box) static analysers in open source we will use it. Knowledgeable people say that <a href="//cppcheck.sourceforge.net/" title="cppcheck site">cppcheck</a> in case of good configuration it is better than the any alternative, but its configuration is the same that the new project creation. <code>cppcheck</code> shows obvious errors and recommend to fix them.</p>
<h3><a href="#cppcheck-run" class="anchor" id="cppcheck-run"><span class="octicon octicon-link"></span></a>Example of run</h3>
<p>Here it is:</p>
{% highlight bash %}
cppcheck --enable=warning,performance,portability,information,missingInclude --std=c++11 --library=qt.cfg --template="[{severity}][{id}] {message} {callstack} (On {file}:{line})" --verbose --quiet path/to/source/files/or/directory
{% endhighlight %}
<ul>
<li><code>--enable</code> says which notifications should be enabled. I've disabled <code>style</code> (we will use <code>clang-format</code> to do it), <code>unusedFunction</code> which shows false-positive for some methods.</li>
<li><code>--std</code> says which standard should be used.</li>
<li><code>--library=qt.cfg</code> a configuration file, which describes how to check files. The developers recommend to read the following <a href="//cppcheck.sourceforge.net/manual.pdf" title="cppcheck manual">manual</a>. I've used the ready template from <code>/usr/share/cppcheck/cfg/</code>.</li>
<li><code>--template</code> is notification template.</li>
<li><code>---verbose --quiet</code> are two "conflicting" options. The first one enables more verbose messages, the second one disables progress reports.</li>
</ul>
<h3><a href="#cppcheck-cmake" class="anchor" id="cppcheck-cmake"><span class="octicon octicon-link"></span></a>cmake integration</h3>
<p><code>cppcheck.cmake</code> file in the project root:</p>
{% highlight cmake %}
# additional target to perform cppcheck run, requires cppcheck
# get all project files
# HACK this workaround is required to avoid qml files checking ^_^
file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h)
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
string(FIND ${SOURCE_FILE} ${PROJECT_TRDPARTY_DIR} PROJECT_TRDPARTY_DIR_FOUND)
if (NOT ${PROJECT_TRDPARTY_DIR_FOUND} EQUAL -1)
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
endif ()
endforeach ()
add_custom_target(
cppcheck
COMMAND /usr/bin/cppcheck
--enable=warning,performance,portability,information,missingInclude
--std=c++11
--library=qt.cfg
--template="[{severity}][{id}] {message} {callstack} \(On {file}:{line}\)"
--verbose
--quiet
${ALL_SOURCE_FILES}
)
{% endhighlight %}
<p><code>cppcheck</code> may work with directories recursive, but I need to skip qml-files checking in my example, because this <code>cppcheck</code> will segfault on some of them. To do it source files search is used followed by the ejection of unnecessary files.</p>
<p>Include to the project (<code>CMakeLists.txt</code>)...</p>
{% highlight cmake %}
include(cppcheck.cmake)
{% endhighlight %}
<p>...and run:</p>
{% highlight bash %}
cmake
make cppcheck
{% endhighlight %}
<p>Then edit files to avoid warnings in the future.</p>
<h3><a href="#cppcheck-adds" class="anchor" id="cppcheck-adds"><span class="octicon octicon-link"></span></a>Adds</h3>
<ul>
<li>You may add own directories to includes search, using <code>-I dir</code> option</li>
<li>You may drop files and/or directories from checking by using <code>-i path/to/file/or/directory</code> option.</li>
</ul>
<h2><a href="#clang" class="anchor" id="clang"><span class="octicon octicon-link"></span></a>clang-format</h2>
<p><a href="//clang.llvm.org/docs/ClangFormat.html" title="clang-format site">clang-format</a> is used to automatic code style checking and correction. <a href="//astyle.sourceforge.net/" title="astyle site">astyle</a>, which has a very modest capabilities, and <a href="//uncrustify.sourceforge.net/" title="uncrustify site">uncrustify</a>, which on the contrary has too many options, should be mentioned from analogues.</p>
<h3><a href="#clang-run" class="anchor" id="clang-run"><span class="octicon octicon-link"></span></a>Example of run</h3>
{% highlight bash %}
clang-format -i -style=LLVM /path/to/source/files
{% endhighlight %}
<p>(Unfortunately it <b>could not</b> work with directories recursive.)</p>
<ul>
<li><code>-i</code> enables files auto replace (otherwise the result will be printed to stdout).</li>
<li><code>-style</code> is a style preset selection or from file (<code>file</code>), see below.</li>
</ul>
<h3><a href="#clang-cmake" class="anchor" id="clang-cmake"><span class="octicon octicon-link"></span></a>cmake integration</h3>
<p><code>clang-format.cmake</code> file in the project root:</p>
{% highlight cmake %}
# additional target to perform clang-format run, requires clang-format
# get all project files
file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h)
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
string(FIND ${SOURCE_FILE} ${PROJECT_TRDPARTY_DIR} PROJECT_TRDPARTY_DIR_FOUND)
if (NOT ${PROJECT_TRDPARTY_DIR_FOUND} EQUAL -1)
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
endif ()
endforeach ()
add_custom_target(
clangformat
COMMAND /usr/bin/clang-format
-style=LLVM
-i
${ALL_SOURCE_FILES}
)
{% endhighlight %}
<p>There is the same method to get source files list as for <code>cppcheck</code>, because <code>clang-format</code> doesn't support recursive directory search.</p>
<p>Include to the project (<code>CMakeLists.txt</code>)...</p>
{% highlight cmake %}
include(clang-format.cmake)
{% endhighlight %}
<p>...and run:</p>
{% highlight bash %}
cmake
make clangformat
{% endhighlight %}
<p>No other actions required.</p>
<h3><a href="#clang-adds" class="anchor" id="clang-adds"><span class="octicon octicon-link"></span></a>Adds</h3>
<ul>
<li>Configuration. You may see all options on the <a href="//clang.llvm.org/docs/ClangFormat.html" title="clang-format site">official site</a>. Also you may use <a href="//clangformat.com/" title="Site">interactive tool</a> to search for required options. To use the preset for your style use the following command:
{% highlight bash %}
clang-format -style=LLVM -dump-config > .clang-format
{% endhighlight %}
Then edit generated file <code>.clang-format</code>. To enable it you need set <code>-style=file</code> option, file should be placed to the any parent directory of each source file (e.g., to the project root). Also you may send required options to the command line directly, e.g. <code>-style="{BasedOnStyle: llvm, IndentWidth: 8}"</code></li>
</ul>

View File

@ -0,0 +1,165 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: development, c++, cmake
title: Add cppcheck and clang-format for a cmake project
short: cppcheck-and-clang-format
---
A small How-To which describes how to add automatic code style checking and static analyser to a project on `C++` which uses `cmake` as a build system.
<!--more-->
## <a href="#project" class="anchor" id="project"><span class="octicon octicon-link"></span></a>Project
The project has the following structure:
```bash
sources/
|- CMakeLists.txt
|- 3rdparty/
|- first_component/
|- second_component/
```
**3rdparty** is a directory which contains additional libraries and which should be excluded from checking (`PROJECT_TRDPARTY_DIR` cmake variable is used to indicate path to this directory). Also let's assume that we have additional files (e.g. `*.qml`) in addition to common source files (`*.cpp`, `*.h`).
In addition the described below commands may be inserted to pre-commit hook; it allows us to troll colleagues which will be able to commit nothing till they read `CONTRIBUTING.md`.
## <a href="#cppcheck" class="anchor" id="cppcheck"><span class="octicon octicon-link"></span></a>cppcheck
As far as there are no good (out-of-box) static analysers in open source we will use it. Knowledgeable people say that [cppcheck](//cppcheck.sourceforge.net/ "cppcheck site") in case of good configuration it is better than the any alternative, but its configuration is the same that the new project creation. `cppcheck` shows obvious errors and recommend to fix them.
### <a href="#cppcheck-run" class="anchor" id="cppcheck-run"><span class="octicon octicon-link"></span></a>Example of run
Here it is:
```bash
cppcheck --enable=warning,performance,portability,information,missingInclude --std=c++11 --library=qt.cfg --template="[{severity}][{id}] {message} {callstack} (On {file}:{line})" --verbose --quiet path/to/source/files/or/directory
```
* `--enable` says which notifications should be enabled. I've disabled `style` (we will use `clang-format` to do it), `unusedFunction` which shows false-positive for some methods.
* `--std` says which standard should be used.
* `--library=qt.cfg` a configuration file, which describes how to check files. The developers recommend to read the following [manual](//cppcheck.sourceforge.net/manual.pdf "cppcheck manual"). I've used the ready template from `/usr/share/cppcheck/cfg/`.
* `--template` is notification template.
* `---verbose --quiet` are two "conflicting" options. The first one enables more verbose messages, the second one disables progress reports.
### <a href="#cppcheck-cmake" class="anchor" id="cppcheck-cmake"><span class="octicon octicon-link"></span></a>cmake integration
`cppcheck.cmake` file in the project root:
```cmake
# additional target to perform cppcheck run, requires cppcheck
# get all project files
# HACK this workaround is required to avoid qml files checking ^_^
file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h)
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
string(FIND ${SOURCE_FILE} ${PROJECT_TRDPARTY_DIR} PROJECT_TRDPARTY_DIR_FOUND)
if (NOT ${PROJECT_TRDPARTY_DIR_FOUND} EQUAL -1)
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
endif ()
endforeach ()
add_custom_target(
cppcheck
COMMAND /usr/bin/cppcheck
--enable=warning,performance,portability,information,missingInclude
--std=c++11
--library=qt.cfg
--template="[{severity}][{id}] {message} {callstack} \(On {file}:{line}\)"
--verbose
--quiet
${ALL_SOURCE_FILES}
)
```
`cppcheck` may work with directories recursive, but I need to skip qml-files checking in my example, because this `cppcheck` will segfault on some of them. To do it source files search is used followed by the ejection of unnecessary files.
Include to the project (`CMakeLists.txt`)...
```cmake
include(cppcheck.cmake)
```
...and run:
```bash
cmake
make cppcheck
```
Then edit files to avoid warnings in the future.
### <a href="#cppcheck-adds" class="anchor" id="cppcheck-adds"><span class="octicon octicon-link"></span></a>Adds
* You may add own directories to includes search, using `-I dir` option
* You may drop files and/or directories from checking by using `-i path/to/file/or/directory` option.
## <a href="#clang" class="anchor" id="clang"><span class="octicon octicon-link"></span></a>clang-format
[clang-format](//clang.llvm.org/docs/ClangFormat.html "clang-format site") is used to automatic code style checking and correction. [astyle](//astyle.sourceforge.net/ "astyle site"), which has a very modest capabilities, and [uncrustify](//uncrustify.sourceforge.net/ "uncrustify site"), which on the contrary has too many options, should be mentioned from analogues.
### <a href="#clang-run" class="anchor" id="clang-run"><span class="octicon octicon-link"></span></a>Example of run
```bash
clang-format -i -style=LLVM /path/to/source/files
```
(Unfortunately it **could not** work with directories recursive.)
* `-i` enables files auto replace (otherwise the result will be printed to stdout).
* `-style` is a style preset selection or from file (`file`), see below.
### <a href="#clang-cmake" class="anchor" id="clang-cmake"><span class="octicon octicon-link"></span></a>cmake integration
`clang-format.cmake` file in the project root:
```cmake
# additional target to perform clang-format run, requires clang-format
# get all project files
file(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h)
foreach (SOURCE_FILE ${ALL_SOURCE_FILES})
string(FIND ${SOURCE_FILE} ${PROJECT_TRDPARTY_DIR} PROJECT_TRDPARTY_DIR_FOUND)
if (NOT ${PROJECT_TRDPARTY_DIR_FOUND} EQUAL -1)
list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})
endif ()
endforeach ()
add_custom_target(
clangformat
COMMAND /usr/bin/clang-format
-style=LLVM
-i
${ALL_SOURCE_FILES}
)
```
There is the same method to get source files list as for `cppcheck`, because `clang-format` doesn't support recursive directory search.
Include to the project (`CMakeLists.txt`)...
```cmake
include(clang-format.cmake)
```
...and run:
```bash
cmake
make clangformat
```
No other actions required.
### <a href="#clang-adds" class="anchor" id="clang-adds"><span class="octicon octicon-link"></span></a>Adds
* Configuration. You may see all options on the [official site](//clang.llvm.org/docs/ClangFormat.html "clang-format site"). Also you may use [interactive tool](//clangformat.com/ "Site") to search for required options. To use the preset for your style use the following command:
```bash
clang-format -style=LLVM -dump-config > .clang-format
```
Then edit generated file `.clang-format`. To enable it you need set `-style=file` option, file should be placed to the any parent directory of each source file (e.g., to the project root). Also you may send required options to the command line directly, e.g. `-style="{BasedOnStyle: llvm, IndentWidth: 8}"`

View File

@ -1,10 +0,0 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: site
title: URL changes
short: url-changes
description: I would like to inform you that I've changed site and repository URL from <a href="//arcanis.name">arcanis.name</a> to <a href="//arcanis.me">arcanis.me</a>. It was done just because ME domain is more pretty. The old URLs will be still valid till Mar 2016 (date of the domain name registration), but at the moment I've setup URL redirection to the new URL. Sorry for any inconvenience.
---

View File

@ -0,0 +1,11 @@
---
category: en
type: paper
hastr: true
layout: paper
tags: site
title: URL changes
short: url-changes
---
I would like to inform you that I've changed site and repository URL from [arcanis.name](//arcanis.name) to [arcanis.me](//arcanis.me). It was done just because ME domain is more pretty. The old URLs will be still valid till Mar 2016 (date of the domain name registration), but at the moment I've setup URL redirection to the new URL. Sorry for any inconvenience.