commit c5f5e8cf33c928c71d520b891ff524a67eb8ce51 Author: J. Elfring Date: Thu Oct 31 22:09:39 2024 +0100 Starting over my dotfiles diff --git a/README.md b/README.md new file mode 100644 index 0000000..dfc83df --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +# dotfiles +Theese are my dotfiles... + +## VIM Plugins +- Add vundle plugin with `git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vi` +- Start vim and install plugins with `PlugInstall` + +## Tweaks +Some things are not (yet) scripted. + +### Firefox Preferences +Add this to `$fierfox-profile/user.js` +``` +user_pref("privacy.donottrackheader.enabled", true ); // Send Do-not-track +user_pref("findbar.highlightAll", true ); // Highlight all partial results in search +user_pref("browser.sessionstore.max_resumed_crashes", -1 ); // Do not show "Upps, we could not recover" +user_pref("browser.fixup.fallback-to-https", false ); // Do not try https after http failed +user_pref("extensions.pocket.enabled", false ); // Disable Pocket +user_pref("browser.vpn_promo.enabled", false ); // Hide VPN adds +user_pref("cookiebanners.service.mode", 2 ); +user_pref("cookiebanners.service.mode.privateBrowsing", 2 ); +user_pref("cookiebanners.ui.desktop.enabled", true ); +user_pref("signon.firefoxRelay.feature", "0" ); +user_pref("signon.includeOtherSubdomainsInLookup" false ); // Credentials only for the actual site +``` + +### GTK FileCHooser sort order +Execute: +``` +gsettings set org.gtk.Settings.FileChooser sort-directories-first true +``` diff --git a/dotfiles/.gitignore b/dotfiles/.gitignore new file mode 100644 index 0000000..94e66d7 --- /dev/null +++ b/dotfiles/.gitignore @@ -0,0 +1 @@ +vim/dot-vim/bundle diff --git a/dotfiles/.stowrc b/dotfiles/.stowrc new file mode 100644 index 0000000..299cca0 --- /dev/null +++ b/dotfiles/.stowrc @@ -0,0 +1,2 @@ +--target=~ +--dotfiles diff --git a/dotfiles/alacritty/dot-config/alacritty/alacritty.toml b/dotfiles/alacritty/dot-config/alacritty/alacritty.toml new file mode 100644 index 0000000..323c0d7 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/alacritty.toml @@ -0,0 +1,24 @@ + +[cursor.style] +shape = "Beam" + +[cursor.vi_mode_style] +shape = "Underline" + +[font] +size = 10 + +[font.bold] +family = "EnvyCodeR Nerd Font Mono" +style = "Bold" + +[font.italic] +family = "EnvyCodeR Nerd Font Mono" +style = "Italic" + +[font.normal] +family = "EnvyCodeR Nerd Font Mono" +style = "Regular" + +[general] +import = ["~/.local/alacritty_colors.toml"] diff --git a/dotfiles/alacritty/dot-config/alacritty/color/Papertheme.toml b/dotfiles/alacritty/dot-config/alacritty/color/Papertheme.toml new file mode 100644 index 0000000..0c192b1 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/Papertheme.toml @@ -0,0 +1,28 @@ +# Colors (Paper Theme) + +# Default colors +[colors.primary] +background = '#F2EEDE' +foreground = '#000000' + +# Normal colors +[colors.normal] +black = '#000000' +red = '#CC3E28' +green = '#216609' +yellow = '#B58900' +blue = '#1E6FCC' +magenta = '#5C21A5' +cyan = '#158C86' +white = '#AAAAAA' + +# Bright colors +[colors.bright] +black = '#555555' +red = '#CC3E28' +green = '#216609' +yellow = '#B58900' +blue = '#1E6FCC' +magenta = '#5C21A5' +cyan = '#158C86' +white = '#AAAAAA' diff --git a/dotfiles/alacritty/dot-config/alacritty/color/Tokyo_night.toml b/dotfiles/alacritty/dot-config/alacritty/color/Tokyo_night.toml new file mode 100644 index 0000000..0642a90 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/Tokyo_night.toml @@ -0,0 +1,29 @@ +# Colors (Tokyo Night) +# Source https//github.com/zatchheems/tokyo-night-alacritty-theme + +# Default colors +[colors.primary] +background = '#1a1b26' +foreground = '#a9b1d6' + +# Normal colors +[colors.normal] +black = '#32344a' +red = '#f7768e' +green = '#9ece6a' +yellow = '#e0af68' +blue = '#7aa2f7' +magenta = '#ad8ee6' +cyan = '#449dab' +white = '#787c99' + +# Bright colors +[colors.bright] +black = '#444b6a' +red = '#ff7a93' +green = '#b9f27c' +yellow = '#ff9e64' +blue = '#7da6ff' +magenta = '#bb9af7' +cyan = '#0db9d7' +white = '#acb0d0' diff --git a/dotfiles/alacritty/dot-config/alacritty/color/baitong.toml b/dotfiles/alacritty/dot-config/alacritty/color/baitong.toml new file mode 100644 index 0000000..4057041 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/baitong.toml @@ -0,0 +1,55 @@ +# Colors (Baitong) + +[colors.primary] +background = '#112a2a' +foreground = '#33ff33' + +[colors.cursor] +text = '#112a2a' +cursor = '#ff00ff' + +[colors.vi_mode_cursor] +text = '#112a2a' +cursor = '#ff00ff' + +[colors.search] +matches = { foreground = '#000000', background = '#1AE642' } +focused_match = { foreground = '#000000', background = '#ff00ff' } + +[colors.hints] +start = { foreground = '#1d1f21', background = '#1AE642' } +end = { foreground = '#1AE642', background = '#1d1f21' } + +[colors.line_indicator] +foreground = '#33ff33' +background = '#1d1f21' + +[colors.footer_bar] +background = '#731d8b' +foreground = '#ffffff' + +[colors.selection] +text = '#112a2a' +background = '#1AE642' + +# Normal colors +[colors.normal] +black = '#000000' +red = '#f77272' +green = '#33ff33' +yellow = '#1AE642' +blue = '#68FDFE' +magenta = '#ff66ff' +cyan = '#87CEFA' +white = '#dbdbd9' + +# Bright colors +[colors.bright] +black = '#ffffff' +red = '#f77272' +green = '#33ff33' +yellow = '#1AE642' +blue = '#68FDFE' +magenta = '#ff66ff' +cyan = '#68FDFE' +white = '#dbdbd9' diff --git a/dotfiles/alacritty/dot-config/alacritty/color/cyber_punk_neon.toml b/dotfiles/alacritty/dot-config/alacritty/color/cyber_punk_neon.toml new file mode 100644 index 0000000..0424e47 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/cyber_punk_neon.toml @@ -0,0 +1,33 @@ +# Cyber Punk Neon +# Source https//github.com/Roboron3042/Cyberpunk-Neon + +# Default colors +[colors.primary] +background = '#000b1e' +foreground = '#0abdc6' + +[colors.cursor] +text = '#000b1e' +cursor = '#0abdc6' + +# Normal colors +[colors.normal] +black = '#123e7c' +red = '#ff0000' +green = '#d300c4' +yellow = '#f57800' +blue = '#123e7c' +magenta = '#711c91' +cyan = '#0abdc6' +white = '#d7d7d5' + +# Bright colors +[colors.bright] +black = '#1c61c2' +red = '#ff0000' +green = '#d300c4' +yellow = '#f57800' +blue = '#00ff00' +magenta = '#711c91' +cyan = '#0abdc6' +white = '#d7d7d5' diff --git a/dotfiles/alacritty/dot-config/alacritty/color/dark_pride.toml b/dotfiles/alacritty/dot-config/alacritty/color/dark_pride.toml new file mode 100644 index 0000000..6cfba47 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/dark_pride.toml @@ -0,0 +1,34 @@ +# Dark Pride +# A dark trans pride colour inspired theme + +# Primary colors +[colors.primary] +background = '#0d0d1b' +foreground = '#ccccce' + +# Colors used for 'custom_cursor_colors' +[colors.cursor] +text = '#bbbbbb' +cursor = '#ff0017' + +# Colors 0 through 7 +[colors.normal] +black = '#282828' +red = '#ca1444' +green = '#789aba' +yellow = '#b3879f' +blue = '#95569b' +magenta = '#cb6fa1' +cyan = '#fb6e93' +white = '#cf98c1' + +# Colors 8 through 15 +[colors.bright] +black = '#98218e' +red = '#cb515d' +green = '#5a87b1' +yellow = '#9c61ab' +blue = '#9a77b1' +magenta = '#f2a297' +cyan = '#f4436f' +white = '#ebdbb2' diff --git a/dotfiles/alacritty/dot-config/alacritty/color/gnome_terminal.toml b/dotfiles/alacritty/dot-config/alacritty/color/gnome_terminal.toml new file mode 100644 index 0000000..a6d21fb --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/gnome_terminal.toml @@ -0,0 +1,28 @@ +# Gnome (Gnome Terminal Default) + +# Default colors +[colors.primary] +background = '#1e1e1e' +foreground = '#ffffff' + +# Normal colors +[colors.normal] +black = '#171421' +red = '#c01c28' +green = '#26a269' +yellow = '#a2734c' +blue = '#12488b' +magenta = '#a347ba' +cyan = '#2aa1b3' +white = '#d0cfcc' + +# Bright colors +[colors.bright] +black = '#5e5c64' +red = '#f66151' +green = '#33d17a' +yellow = '#e9ad0c' +blue = '#2a7bde' +magenta = '#c061cb' +cyan = '#33c7de' +white = '#ffffff' diff --git a/dotfiles/alacritty/dot-config/alacritty/color/palenight.toml b/dotfiles/alacritty/dot-config/alacritty/color/palenight.toml new file mode 100644 index 0000000..fb9ccfc --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/palenight.toml @@ -0,0 +1,29 @@ +# iTerm2 Material Design - Palenight theme for Alacritty +# Source https//github.com/JonathanSpeek/palenight-iterm2 + +# Default colors +[colors.primary] +background = '#292d3e' +foreground = '#d0d0d0' + +# Normal colors +[colors.normal] +black = '#292d3e' +red = '#f07178' +green = '#c3e88d' +yellow = '#ffcb6b' +blue = '#82aaff' +magenta = '#c792ea' +cyan = '#89ddff' +white = '#d0d0d0' + +# Bright colors +[colors.bright] +black = '#434758' +red = '#ff8b92' +green = '#ddffa7' +yellow = '#ffe585' +blue = '#9cc4ff' +magenta = '#e1acff' +cyan = '#a3f7ff' +white = '#ffffff' diff --git a/dotfiles/alacritty/dot-config/alacritty/color/rose_pine.toml b/dotfiles/alacritty/dot-config/alacritty/color/rose_pine.toml new file mode 100644 index 0000000..0c5ffc2 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/rose_pine.toml @@ -0,0 +1,39 @@ +[colors.primary] +background = '#191724' +foreground = '#e0def4' + +[colors.cursor] +text = '#e0def4' +cursor = '#524f67' + +[colors.vi_mode_cursor] +text = '#e0def4' +cursor = '#524f67' + +[colors.selection] +text = '#e0def4' +background = '#403d52' + +[colors.normal] +black = '#26233a' +red = '#eb6f92' +green = '#31748f' +yellow = '#f6c177' +blue = '#9ccfd8' +magenta = '#c4a7e7' +cyan = '#ebbcba' +white = '#e0def4' + +[colors.bright] +black = '#6e6a86' +red = '#eb6f92' +green = '#31748f' +yellow = '#f6c177' +blue = '#9ccfd8' +magenta = '#c4a7e7' +cyan = '#ebbcba' +white = '#e0def4' + +[colors.hints] +start = {foreground = '#908caa', background = '#1f1d2e' } +end = { foreground = '#6e6a86', background = '#1f1d2e' } diff --git a/dotfiles/alacritty/dot-config/alacritty/color/rose_pine_dawn.toml b/dotfiles/alacritty/dot-config/alacritty/color/rose_pine_dawn.toml new file mode 100644 index 0000000..a0ee855 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/rose_pine_dawn.toml @@ -0,0 +1,39 @@ +[colors.primary] +background = '#faf4ed' +foreground = '#575279' + +[colors.cursor] +text = '#575279' +cursor = '#cecacd' + +[colors.vi_mode_cursor] +text = '#575279' +cursor = '#cecacd' + +[colors.selection] +text = '#575279' +background = '#dfdad9' + +[colors.normal] +black = '#f2e9e1' +red = '#b4637a' +green = '#286983' +yellow = '#ea9d34' +blue = '#56949f' +magenta = '#907aa9' +cyan = '#d7827e' +white = '#575279' + +[colors.bright] +black = '#9893a5' +red = '#b4637a' +green = '#286983' +yellow = '#ea9d34' +blue = '#56949f' +magenta = '#907aa9' +cyan = '#d7827e' +white = '#575279' + +[colors.hints] +start = { foreground = '#797593', background = '#fffaf3' } +end = { foreground = '#9893a5', background = '#fffaf3' } diff --git a/dotfiles/alacritty/dot-config/alacritty/color/rose_pine_moon.toml b/dotfiles/alacritty/dot-config/alacritty/color/rose_pine_moon.toml new file mode 100644 index 0000000..f816e1e --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/rose_pine_moon.toml @@ -0,0 +1,38 @@ +[colors.primary] +background = '#232136' +foreground = '#e0def4' + +[colors.cursor] +text = '#e0def4' +cursor = '#56526e' + +[colors.vi_mode_cursor] +text = '#e0def4' +cursor = '#56526e' + +[colors.selection] +text = '#e0def4' +background = '#44415a' +[colors.normal] +black = '#393552' +red = '#eb6f92' +green = '#3e8fb0' +yellow = '#f6c177' +blue = '#9ccfd8' +magenta = '#c4a7e7' +cyan = '#ea9a97' +white = '#e0def4' + +[colors.bright] +black = '#6e6a86' +red = '#eb6f92' +green = '#3e8fb0' +yellow = '#f6c177' +blue = '#9ccfd8' +magenta = '#c4a7e7' +cyan = '#ea9a97' +white = '#e0def4' + +[colors.hints] +start = { foreground = '#908caa', background = '#2a273f' } +end = { foreground = '#6e6a86', background = '#2a273f' } diff --git a/dotfiles/alacritty/dot-config/alacritty/color/seashells.toml b/dotfiles/alacritty/dot-config/alacritty/color/seashells.toml new file mode 100644 index 0000000..0db2734 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/seashells.toml @@ -0,0 +1,37 @@ +# Colors (SeaShells) +# Source https//raw.githubusercontent.com/mbadolato/iTerm2-Color-Schemes/master/schemes/SeaShells.itermcolors + +# Default colors +[colors.primary] +background = '#061923' +foreground = '#e5c49e' + +[colors.cursor] +text = '#061822' +cursor = '#feaf3c' + +[colors.selection] +text = '#ffe9d7' +background = '#265b75' + +# Normal colors +[colors.normal] +black = '#1d485f' +red = '#db662d' +green = '#008eab' +yellow = '#feaf3c' +blue = '#255a62' +magenta = '#77dbf4' +cyan = '#5fb1c2' +white = '#e5c49e' + +# Bright colors +[colors.bright] +black = '#545d65' +red = '#dd998a' +green = '#739da8' +yellow = '#fedaae' +blue = '#0bc7e3' +magenta = '#c6e8f1' +cyan = '#97b9c0' +white = '#ffe9d7' diff --git a/dotfiles/alacritty/dot-config/alacritty/color/sourcerer.toml b/dotfiles/alacritty/dot-config/alacritty/color/sourcerer.toml new file mode 100644 index 0000000..04777bf --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/sourcerer.toml @@ -0,0 +1,27 @@ +[colors.bright] +black = "#181818" +blue = "#90b0d1" +cyan = "#87ceeb" +green = "#b1d631" +magenta = "#8181a6" +red = "#ff6a6a" +white = "#c1cdc1" +yellow = "#ff9800" + +[colors.cursor] +cursor = "#c2c2b0" +text = "#c2c2b0" + +[colors.normal] +black = "#111111" +blue = "#6688aa" +cyan = "#528b8b" +green = "#719611" +magenta = "#8f6f8f" +red = "#aa4450" +white = "#d3d3d3" +yellow = "#cc8800" + +[colors.primary] +background = "#222222" +foreground = "#c2c2b0" diff --git a/dotfiles/alacritty/dot-config/alacritty/color/spacegray.toml b/dotfiles/alacritty/dot-config/alacritty/color/spacegray.toml new file mode 100644 index 0000000..3543c83 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/spacegray.toml @@ -0,0 +1,33 @@ +# Spacegray, from Sublime Text +# Source https://github.com/SublimeText/Spacegray + +# Default colors +[colors.primary] +background = '#20242d' +foreground = '#b3b8c3' + +[colors.cursor] +text = '#b3b8c3' +cursor = '#b3b8c3' + +# Normal colors +[colors.normal] +black = '#000000' +red = '#b04b57' +green = '#87b379' +yellow = '#e5c179' +blue = '#7d8fa4' +magenta = '#a47996' +cyan = '#85a7a5' +white = '#b3b8c3' + +# Bright colors +[colors.bright] +black = '#000000' +red = '#b04b57' +green = '#87b379' +yellow = '#e5c179' +blue = '#7d8fa4' +magenta = '#a47996' +cyan = '#85a7a5' +white = '#ffffff' diff --git a/dotfiles/alacritty/dot-config/alacritty/color/synthwave_84.toml b/dotfiles/alacritty/dot-config/alacritty/color/synthwave_84.toml new file mode 100644 index 0000000..89df666 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/synthwave_84.toml @@ -0,0 +1,23 @@ +[colors.primary] +foreground = "#ffffff" +background = "#262335" + +[colors.normal] +black = "#262335" +red = "#fe4450" +green = "#72f1b8" +yellow = "#f3e70f" +blue = "#03edf9" +magenta = "#ff7edb" +cyan = "#03edf9" +white = "#ffffff" + +[colors.bright] +black = "#614d85" +red = "#fe4450" +green = "#72f1b8" +yellow = "#fede5d" +blue = "#03edf9" +magenta = "#ff7edb" +cyan = "#03edf9" +white = "#ffffff" diff --git a/dotfiles/alacritty/dot-config/alacritty/color/tokyo_night_enhanced.toml b/dotfiles/alacritty/dot-config/alacritty/color/tokyo_night_enhanced.toml new file mode 100644 index 0000000..90ba82b --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/tokyo_night_enhanced.toml @@ -0,0 +1,30 @@ +[colors.primary] +background = "#08080b" +foreground = "#787c99" + +[colors.cursor] +cursor = "#787c99" + +[colors.selection] +text = "CellForeground" +background = "#515c7e" + +[colors.normal] +black = "#363b54" +red = "#f7768e" +green = "#41a6b5" +yellow = "#e0af68" +blue = "#7aa2f7" +magenta = "#bb9af7" +cyan = "#7dcfff" +white = "#787c99" + +[colors.bright] +black = "#363b54" +red = "#f7768e" +green = "#41a6b5" +yellow = "#e0af68" +blue = "#7aa2f7" +magenta = "#bb9af7" +cyan = "#7dcfff" +white = "#787c99" diff --git a/dotfiles/alacritty/dot-config/alacritty/color/tokyo_night_storm.toml b/dotfiles/alacritty/dot-config/alacritty/color/tokyo_night_storm.toml new file mode 100644 index 0000000..992f1d3 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/tokyo_night_storm.toml @@ -0,0 +1,29 @@ +# Colors (Tokyo Night Storm variant) +# Source https//github.com/zatchheems/tokyo-night-alacritty-theme + +# Default colors +[colors.primary] +background = '#24283b' +foreground = '#a9b1d6' + +# Normal colors +[colors.normal] +black = '#32344a' +red = '#f7768e' +green = '#9ece6a' +yellow = '#e0af68' +blue = '#7aa2f7' +magenta = '#ad8ee6' +cyan = '#449dab' +white = '#9699a8' + +# Bright colors +[colors.bright] +black = '#444b6a' +red = '#ff7a93' +green = '#b9f27c' +yellow = '#ff9e64' +blue = '#7da6ff' +magenta = '#bb9af7' +cyan = '#0db9d7' +white = '#acb0d0' diff --git a/dotfiles/alacritty/dot-config/alacritty/color/ubuntu.toml b/dotfiles/alacritty/dot-config/alacritty/color/ubuntu.toml new file mode 100644 index 0000000..952cc07 --- /dev/null +++ b/dotfiles/alacritty/dot-config/alacritty/color/ubuntu.toml @@ -0,0 +1,33 @@ +# 0x From the Ubuntu terminal color palette + +# 0x Default colors +[colors.primary] +background = '#300a24' +foreground = '#eeeeec' + +# 0x Colors the cursor will use if `custom_cursor_colors` is true +[colors.cursor] +text = '#bbbbbb' +cursor = '#b4d5ff' + +# 0x Normal colors +[colors.normal] +black = '#2e3436' +red = '#cc0000' +green = '#4e9a06' +yellow = '#c4a000' +blue = '#3465a4' +magenta = '#75507b' +cyan = '#06989a' +white = '#d3d7cf' + +# 0x Bright colors +[colors.bright] +black = '#555753' +red = '#ef2929' +green = '#8ae234' +yellow = '#fce94f' +blue = '#729fcf' +magenta = '#ad7fa8' +cyan = '#34e2e2' +white = '#eeeeec' diff --git a/dotfiles/gnucash/dot-local/share/applications/gnucash.desktop b/dotfiles/gnucash/dot-local/share/applications/gnucash.desktop new file mode 100755 index 0000000..c16b347 --- /dev/null +++ b/dotfiles/gnucash/dot-local/share/applications/gnucash.desktop @@ -0,0 +1,14 @@ +[Desktop Entry] +Type=Application +MimeType=application/x-gnucash; +Name[de]=GnuCash +Name=GnuCash +GenericName[de]=Finanzmanagement +GenericName=Finance Management +Comment[de]=Verwaltung der Finanzen von Privatanwendern und Kleinbetrieben. +Comment=Manage your finances, accounts, and investments +Exec=env LC_MESSAGES=de_DE.UTF-8 gnucash %f +Icon=gnucash-icon +StartupNotify=true +Terminal=false +Categories=Office;Finance; diff --git a/dotfiles/i3/dot-config/i3/config b/dotfiles/i3/dot-config/i3/config new file mode 100644 index 0000000..2495836 --- /dev/null +++ b/dotfiles/i3/dot-config/i3/config @@ -0,0 +1,230 @@ +# i3 config file (v4) +# +# Please see http://i3wm.org/docs/userguide.html for a complete reference! + +set $mod Mod4 +set $alt Mod1 + +# Font for window titles. Will also be used by the bar unless a different font +# is used in the bar {} block below. +#font pango:B612 Mono 12 +font pango:Hack Nerd Font 10 + +# Green Colors +## class border backgr. text indicator child_border +client.focused #77994B #547628 #EEEEEE #41FF00 +client.focused_inactive #333333 #5F676A #EEEEEE #333333 + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# start a terminal +bindsym $mod+Return exec i3-sensible-terminal + +# kill focused window +bindsym $mod+Shift+c kill + +# start dmenu (a program launcher) +#bindsym $mod+d exec --no-startup-id "i3-dmenu-desktop -dmenu='dmenu -i -fn B612' --entry-type name" + +## Rofi replaces dmenu... +bindsym $mod+d exec --no-startup-id "rofi -show drun" +bindsym $mod+Tab exec --no-startup-id "rofi -show window" +bindsym $mod+s exec --no-startup-id "rofi -show ssh" + +# Local Hotkeys +bindsym $mod+x exec --no-startup-id "test -x ~/.local/bin/lhotkey-x && ~/.local/bin/lhotkey-x" +bindsym $mod+y exec --no-startup-id "test -x ~/.local/bin/lhotkey-y && ~/.local/bin/lhotkey-y" +bindsym $mod+F1 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F01 && ~/.local/bin/lhotkey-F01" +bindsym $mod+F2 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F02 && ~/.local/bin/lhotkey-F02" +bindsym $mod+F3 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F03 && ~/.local/bin/lhotkey-F03" +bindsym $mod+F4 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F04 && ~/.local/bin/lhotkey-F04" +bindsym $mod+F5 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F05 && ~/.local/bin/lhotkey-F05" +bindsym $mod+F6 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F06 && ~/.local/bin/lhotkey-F06" +bindsym $mod+F7 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F07 && ~/.local/bin/lhotkey-F07" +bindsym $mod+F8 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F08 && ~/.local/bin/lhotkey-F08" +bindsym $mod+F9 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F09 && ~/.local/bin/lhotkey-F09" +bindsym $mod+F10 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F10 && ~/.local/bin/lhotkey-F10" +bindsym $mod+F11 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F11 && ~/.local/bin/lhotkey-F11" +bindsym $mod+F12 exec --no-startup-id "test -x ~/.local/bin/lhotkey-F12 && ~/.local/bin/lhotkey-F12" + +# change focus +bindsym $mod+h focus left +bindsym $mod+j focus down +bindsym $mod+k focus up +bindsym $mod+l focus right +bindsym $mod+Left focus left +bindsym $mod+Down focus down +bindsym $mod+Up focus up +bindsym $mod+Right focus right + +# move focused window +bindsym $mod+Shift+h move left +bindsym $mod+Shift+j move down +bindsym $mod+Shift+k move up +bindsym $mod+Shift+l move right +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+Up move up +bindsym $mod+Shift+Right move right + +# move the whole workspace to an other display +bindsym $mod+$alt+h move workspace to output left +bindsym $mod+$alt+l move workspace to output right +bindsym $mod+$alt+Left move workspace to output left +bindsym $mod+$alt+Right move workspace to output right + +# enter fullscreen mode for the focused container +bindsym $mod+f fullscreen toggle + +# change container layout (stacked, tabbed, toggle split) +bindsym $mod+$alt+e layout toggle split +bindsym $mod+$alt+s layout stacking +bindsym $mod+$alt+w layout tabbed + +# toggle tiling / floating +bindsym $mod+Shift+space floating toggle + +# change focus between tiling / floating windows +bindsym $mod+space focus mode_toggle + +# focus the parent container with PageUp/Down +bindsym $mod+Prior focus parent +bindsym $mod+Next focus child + +# switch to workspace +bindsym $mod+1 workspace 1 +bindsym $mod+2 workspace 2 +bindsym $mod+3 workspace 3 +bindsym $mod+4 workspace 4 +bindsym $mod+5 workspace 5 +bindsym $mod+6 workspace 6 +bindsym $mod+7 workspace 7 +bindsym $mod+8 workspace 8 +bindsym $mod+9 workspace 9 +bindsym $mod+0 workspace 10 + +# move focused container to workspace +bindsym $mod+Shift+1 move container to workspace 1 +bindsym $mod+Shift+2 move container to workspace 2 +bindsym $mod+Shift+3 move container to workspace 3 +bindsym $mod+Shift+4 move container to workspace 4 +bindsym $mod+Shift+5 move container to workspace 5 +bindsym $mod+Shift+6 move container to workspace 6 +bindsym $mod+Shift+7 move container to workspace 7 +bindsym $mod+Shift+8 move container to workspace 8 +bindsym $mod+Shift+9 move container to workspace 9 +bindsym $mod+Shift+0 move container to workspace 10 + +# restart i3 inplace (preserves your layout/session, can be used to upgrade i3) +bindsym $mod+Shift+r restart + +# exit i3 (logs you out of your X session) +bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'" + +# resize window (you can also use the mouse for that) +mode "resize" { + # These bindings trigger as soon as you enter the resize mode + bindsym h resize shrink width 10 px or 10 ppt + bindsym j resize grow height 10 px or 10 ppt + bindsym k resize shrink height 10 px or 10 ppt + bindsym l resize grow width 10 px or 10 ppt + bindsym Left resize shrink width 10 px or 10 ppt + bindsym Down resize grow height 10 px or 10 ppt + bindsym Up resize shrink height 10 px or 10 ppt + bindsym Right resize grow width 10 px or 10 ppt + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+r mode "resize" + +bar { + colors { + focused_workspace #77994B #547628 #EEEEEE #41FF00 + } + #font pango:Hack Nerd Font 10 + position top + status_command i3status-rs ~/.config/i3/i3status-rs.conf +} + +# PW Audio controls +bindsym XF86AudioRaiseVolume exec --no-startup-id "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%+" +bindsym XF86AudioLowerVolume exec --no-startup-id "wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" +bindsym XF86AudioMute exec --no-startup-id "wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle" + +# Sreen brightness controls +bindsym XF86MonBrightnessUp exec light -A 5 +bindsym XF86MonBrightnessDown exec light -U 5 + +# Toggle WiFi +# [ _$(nmcli radio wifi) == _enabled ] && nmcli radio wifi off || nmcli radio wifi on + +# Screenlock +bindsym $alt+Ctrl+l exec "~/.bin/screenlock.sh" +bindsym XF86Sleep exec "~/.bin/screenlock.sh" +exec --no-startup-id xautolock -time 15 -locker "~/.bin/screenlock.sh" & + +# quick terminal +bindsym $mod+$alt+Shift+F1 exec --no-startup-id $TERMINAL --class metask -e bash -o ignoreeof +exec --no-startup-id $TERMINAL --class metask -e bash -o ignoreeof +for_window [instance="metask"] floating enable; +for_window [instance="metask"] move scratchpad; \ + [instance="metask"] scratchpad show; \ + move position 0px 22px; \ + resize shrink height 150px; \ + resize grow width 683px; \ + move scratchpad +bindsym F1 [instance="metask"] scratchpad show + +# Touchpad controls +#bindsym XF86TouchpadToggle exec /some/path/toggletouchpad.sh # toggle touchpad + +# Media player controls +#bindsym XF86AudioPlay exec playerctl play +#bindsym XF86AudioPause exec playerctl pause +#bindsym XF86AudioNext exec playerctl next +#bindsym XF86AudioPrev exec playerctl previous + +# Misc keybindings +bindsym --release Print exec "scrot --select" +bindsym $mod+c exec free42 +bindsym $mod+plus exec .bin/switchTermColours.sh +bindsym $mod+XF86Calc exec free42 +bindsym $mod+b exec ~/.bin/startBrowser.sh +bindsym $mod+$alt+b exec ~/.bin/startAltBrowser.sh +bindsym $mod+n exec ~/.bin/startBrowserPrivat.sh +bindsym $mod+$alt+n exec ~/.bin/startAltBrowserPrivat.sh +bindsym $mod+m exec ~/.bin/dmenu_dir2menu.sh ~/.screenlayout/ + +# Clipboard +bindsym $mod+q exec --no-startup-id "~/.bin/xcqr" +bindsym $mod+v exec --no-startup-id "clipmenu" + + +# Autostart +exec --no-startup-id "blueman-applet" +exec --no-startup-id "nm-applet" +exec --no-startup-id "clipmenud" +exec --no-startup-id "dunst -config ~/.config/i3/dunstrc" +exec --no-startup-id "qpwgraph --minimized" +exec --no-startup-id test -x ~/.local/bin/i3autostart.sh && ~/.local/bin/i3autostart.sh +exec --no-startup-id gsettings set org.gtk.Settings.FileChooser sort-directories-first true + +## Spirallayout for new windows +exec_always --no-startup-id /usr/bin/autotiling + +## Window Config +for_window [class="Arandr"] floating enable +for_window [class="Argon"] floating enable +for_window [class="Blueman-manager"] floating enable +for_window [class="Ghidra"] floating enable +for_window [class="Plus42"] floating enable +for_window [class="QjackCtl"] floating enable +for_window [class="Qsynth"] floating enable +for_window [class="VMPK"] floating enable +for_window [class="Vlc"] floating enable +for_window [class="X3270"] floating enable +for_window [class="pavucontrol"] floating enable +for_window [class="smplayer"] floating enable diff --git a/dotfiles/i3/dot-config/i3/dunstrc b/dotfiles/i3/dot-config/i3/dunstrc new file mode 100644 index 0000000..cf52197 --- /dev/null +++ b/dotfiles/i3/dot-config/i3/dunstrc @@ -0,0 +1,48 @@ +[global] + font = Hack Nerd Font 10 + allow_markup = yes + format = "%s\n%b" + sort = yes + indicate_hidden = yes + alignment = right + bounce_freq = 0 + show_age_threshold = 60 + word_wrap = yes + ignore_newline = no + geometry = "200x5-6+30" + transparency = 0 + idle_threshold = 120 + monitor = 0 + follow = mouse + sticky_history = yes + line_height = 0 + separator_height = 2 + padding = 8 + horizontal_padding = 8 + separator_color = "#585858" + startup_notification = false + +[frame] + width = 1 + color = "#383838" + +[shortcuts] + close = ctrl+space + close_all = ctrl+shift+space + # history = ctrl+h + context = ctrl+shift+period + +[urgency_low] + background = "#181818" + foreground = "#E3C7AF" + timeout = 5 + +[urgency_normal] + background = "#181818" + foreground = "#E3C7AF" + timeout = 20 + +[urgency_critical] + background = "#181818" + foreground = "#FF2121" + timeout = 0 diff --git a/dotfiles/i3/dot-config/i3/i3-status.conf b/dotfiles/i3/dot-config/i3/i3-status.conf new file mode 100644 index 0000000..6dae735 --- /dev/null +++ b/dotfiles/i3/dot-config/i3/i3-status.conf @@ -0,0 +1,80 @@ +# i3status configuration file. +# see "man i3status" for documentation. + +# It is important that this file is edited as UTF-8. +# The following line should contain a sharp s: +# ß +# If the above line is not correctly displayed, fix your editor first! + +general { + colors = true + interval = 2 +} + +order += "disk /" +order += "ipv6" +order += "wireless _first_" +order += "ethernet _first_" +order += "cpu_temperature 0" +order += "cpu_usage" +order += "load" +order += "volume master" +order += "battery 0" +order += "tztime local" + +ipv6 { + format_down = "" +} + +wireless _first_ { + format_up = "⚵ %ip (%quality at %essid)" + format_down = "" +} + +ethernet _first_ { + ## if you use %speed, i3status requires root privileges + format_up = "♆ %ip (%speed)" + format_down = "" +} + +battery 0 { + format = "%status%percentage %remaining" + format_down = "" + status_chr = "⚡▴ " + status_bat = "⚡▾ " + status_full = "⚡ " + low_threshold = 30 + threshold_type = time + hide_seconds = true + integer_battery_capacity = true +} + +tztime local { + format = "KW%V %Y-%m-%d %H:%M" +} + +load { + format = "📊 %1min %5min %15min" +} + +cpu_usage { + format = "🚀 %usage" +} + +cpu_temperature 0 { + format = "♨ %degrees °C" + path = "~/.local/systemp" +} + +disk "/" { + format = "/ %avail" + prefix_type = custom +} + +volume master { + format = "♪ %volume" + format_muted = "♪ mute (%volume)" + device = "default" + mixer = "Master" + mixer_idx = 0 +} diff --git a/dotfiles/i3/dot-config/i3/i3status-rs.conf b/dotfiles/i3/dot-config/i3/i3status-rs.conf new file mode 100644 index 0000000..83333fa --- /dev/null +++ b/dotfiles/i3/dot-config/i3/i3status-rs.conf @@ -0,0 +1,69 @@ +[theme] +theme = "modern" + +[icons] +icons = "awesome6" + +[[block]] +block = "privacy" + +[[block.driver]] +name = "v4l" + +[[block.driver]] +name = "pipewire" +exclude_input = ["openrgb"] +display = "nickname" + + +[[block]] +block = "disk_space" +info_type = "available" +alert_unit = "GB" +alert = 10.0 +warning = 15.0 +format = " $icon $available " +format_alt = " $icon $available / $total " + +[[block]] +block = "net" +format = " $icon $ip ({$signal_strength $ssid|Wired}) " + +#[[block]] +#block = "external_ip" +#format = " $ip $country_code " +#interval = 900 + +[[block]] +block = "temperature" +format = " $icon $max max " +format_alt = " $icon $min min, $max max, $average avg " +interval = 10 +chip = "*-isa-*" + +[[block]] +block = "cpu" +interval = 1 +format = " $icon $barchart $utilization " +format_alt = " $icon $frequency{ $boost|} " +info_cpu = 30 +warning_cpu = 50 +critical_cpu = 90 + +[[block]] +block = "load" +format = " $icon $1m.eng(w:4) $5m.eng(w:4) $15m.eng(w:4) " +interval = 2 + +[[block]] +block = "sound" +step_width = 3 + +[[block]] +block = "battery" +format = "$icon $percentage {$time |}" + +[[block]] +block = "time" +interval = 60 +format = " $icon $timestamp.datetime(f:'KW%V %Y-%m-%d %H:%M', l:de_DE) " diff --git a/dotfiles/my-binaries/dot-bin/256colors.pl b/dotfiles/my-binaries/dot-bin/256colors.pl new file mode 100755 index 0000000..c070b00 --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/256colors.pl @@ -0,0 +1,64 @@ +#!/usr/bin/perl +# Author: Todd Larason +# $XFree86: xc/programs/xterm/vttests/256colors2.pl,v 1.2 2002/03/26 01:46:43 dickey Exp $ + +# use the resources for colors 0-15 - usually more-or-less a +# reproduction of the standard ANSI colors, but possibly more +# pleasing shades + +# colors 16-231 are a 6x6x6 color cube +for ($red = 0; $red < 6; $red++) { + for ($green = 0; $green < 6; $green++) { + for ($blue = 0; $blue < 6; $blue++) { + printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 16 + ($red * 36) + ($green * 6) + $blue, + ($red ? ($red * 40 + 55) : 0), + ($green ? ($green * 40 + 55) : 0), + ($blue ? ($blue * 40 + 55) : 0)); + } + } +} + +# colors 232-255 are a grayscale ramp, intentionally leaving out +# black and white +for ($gray = 0; $gray < 24; $gray++) { + $level = ($gray * 10) + 8; + printf("\x1b]4;%d;rgb:%2.2x/%2.2x/%2.2x\x1b\\", + 232 + $gray, $level, $level, $level); +} + + +# display the colors + +# first the system ones: +print "System colors:\n"; +for ($color = 0; $color < 8; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n"; +for ($color = 8; $color < 16; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n\n"; + +# now the color cube +print "Color cube, 6x6x6:\n"; +for ($green = 0; $green < 6; $green++) { + for ($red = 0; $red < 6; $red++) { + for ($blue = 0; $blue < 6; $blue++) { + $color = 16 + ($red * 36) + ($green * 6) + $blue; + print "\x1b[48;5;${color}m "; + } + print "\x1b[0m "; + } + print "\n"; +} + + +# now the grayscale ramp +print "Grayscale ramp:\n"; +for ($color = 232; $color < 256; $color++) { + print "\x1b[48;5;${color}m "; +} +print "\x1b[0m\n";w + diff --git a/dotfiles/my-binaries/dot-bin/decryptNdump_pass b/dotfiles/my-binaries/dot-bin/decryptNdump_pass new file mode 100755 index 0000000..ae3735c --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/decryptNdump_pass @@ -0,0 +1,21 @@ +#!/bin/bash + +## A script to decrypt and dump the passwordstore to +## save it to a trusted volume + +prefix=${PASSWORD_STORE_DIR:=~/.password-store} + +## Set the IFS to account for spaces in filenames +IFS=$(echo -en "\n\b") + +for file in $(find $prefix -name '*.gpg') +do + nicename=$(echo $file \ + | cut --characters ${#prefix}- \ + | cut --characters 3- \ + | rev | cut --characters 5- | rev + ) + echo + echo "==> "$nicename + gpg --quiet --decrypt $file +done diff --git a/dotfiles/my-binaries/dot-bin/dmenu_dir2menu.sh b/dotfiles/my-binaries/dot-bin/dmenu_dir2menu.sh new file mode 100755 index 0000000..bd879a0 --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/dmenu_dir2menu.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +directory=$1 + +## ARG1 needs to be a directory +if [ ! -d $directory ] +then + echo Usage: $0 [Directory with menuitems] + exit 1 +fi + +$directory/$(ls --color=never -1 $directory | rofi -dmenu -p "Select screen layout") diff --git a/dotfiles/my-binaries/dot-bin/fzpass b/dotfiles/my-binaries/dot-bin/fzpass new file mode 100755 index 0000000..36c49d0 --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/fzpass @@ -0,0 +1,55 @@ +#!/bin/bash + +## A wrapper for pass to use fzf to find passwords. + +prefix=${PASSWORD_STORE_DIR:=~/.password-store} + +## Get all the gpg files in all directories and subdirs... +## remove the prefix, some 3 extra chars and the .gpg ending +password_files=$( find $prefix -name '*.gpg' \ + | cut --characters ${#prefix}- \ + | cut --characters 3- \ + | rev | cut --characters 5- | rev + ) + +## Some functions to call from inside the fzf menu +fzpass_update () { + echo "--Pulling..." 2>&1 >/dev/tty + pass git pull 2>&1 >/dev/tty + echo "--Pushing..." 2>&1 >/dev/tty + pass git push 2>&1 >/dev/tty + echo "--Any key to continue..." 2>&1 >/dev/tty + read +} +export -f fzpass_update + + +## Send the filelist to fzf, +## disable the fzf mouse to use the primary selection +password=$( printf '%s\n' "${password_files[@]}" \ + | fzf --bind='ctrl-s:toggle-preview' \ + --bind='ctrl-u:execute(fzpass_update)' \ + --bind='ctrl-r:execute(pass rm {})' \ + --bind='ctrl-e:execute(pass edit {} < /dev/tty > /dev/tty)' \ + --preview='pass show {}' \ + --preview-window="hidden" \ + --no-mouse \ + --header=' +Ret: Copy pass, show OTP; C-s: Show entry; C-e: Edit entry +C-u: Update (pull, push); C-r: Remove' + $@ \ + ) + +## Exit if nothing was selected +test "_$password" = "_" && exit + + +## Disable clipman +command -v clipctl >/dev/null && clipctl disable + +## Copy pass and show otp, exit silently if anything fails +pass show -c "$password" +pass otp "$password" 2>/dev/null || exit 0 + +## Re-Enable clipman +command -v clipctl >/dev/null && clipctl enable diff --git a/dotfiles/my-binaries/dot-bin/lock-keyring b/dotfiles/my-binaries/dot-bin/lock-keyring new file mode 100755 index 0000000..e5094de Binary files /dev/null and b/dotfiles/my-binaries/dot-bin/lock-keyring differ diff --git a/dotfiles/my-binaries/dot-bin/lock-keyring.c b/dotfiles/my-binaries/dot-bin/lock-keyring.c new file mode 100644 index 0000000..9dc7684 --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/lock-keyring.c @@ -0,0 +1,16 @@ +#include +#include + +// To be compiled with: +// cc lock-keyring.c -o lock-keyring -Wall $(pkg-config gnome-keyring-1 --cflags --libs) + +int main() { + GnomeKeyringResult lock_result = gnome_keyring_lock_all_sync(); + if (lock_result == GNOME_KEYRING_RESULT_OK) { + printf("Successfully locked\n"); + return 0; + } else { + printf("Error locking keyring: %d\n", lock_result); + return 1; + } +} diff --git a/dotfiles/my-binaries/dot-bin/reconnectfritzbox.sh b/dotfiles/my-binaries/dot-bin/reconnectfritzbox.sh new file mode 100755 index 0000000..07646ed --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/reconnectfritzbox.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +# Reconnect a Fritz.Box with activated UPnP + +oldIp=$(curl -s https://v4.ident.me) + +curl "http://fritz.box:49000/igdupnp/control/WANIPConn1" \ + -H 'Content-Type: text/xml; charset="utf-8"' \ + -H 'SoapAction: urn:schemas-upnp-org:service:WANIPConnection:1#ForceTermination' \ + -d ' + + + + + ' \ + -s + +sleep 5 + +newIp=$(curl -s https://v4.ident.me) + + +notify-send "Renew IP" "Old IP: $oldIp\nNew IP: $newIp" diff --git a/dotfiles/my-binaries/dot-bin/sanitize_files.sh b/dotfiles/my-binaries/dot-bin/sanitize_files.sh new file mode 100755 index 0000000..d9ed410 --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/sanitize_files.sh @@ -0,0 +1,19 @@ +#! /bin/bash + +sanitize() { + shopt -s extglob; + + filename=$(basename "$1") + directory=$(dirname "$1") + + #filename_clean="${filename//+([^[:alnum:]_-\.])/_}" + filename_clean=$(echo -n $filename | tr --complement --squeeze-repeats "[:alnum:]./" "_") + + if (test "$filename" != "$filename_clean") + then + mv -v --backup=numbered "$1" "$directory/$filename_clean" + fi +} + +export -f sanitize +find $1 -depth -exec bash -c 'sanitize "$0"' {} \; diff --git a/dotfiles/my-binaries/dot-bin/screenlock.sh b/dotfiles/my-binaries/dot-bin/screenlock.sh new file mode 100755 index 0000000..2d8b2f6 --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/screenlock.sh @@ -0,0 +1,16 @@ +#!/bin/sh -e + +## Take a screenshot and create a lockscreen +rm -f /tmp/screen_locked.png +scrot /tmp/screen_locked.png +mogrify -scale 10% -scale 1000% /tmp/screen_locked.png +#convert /tmp/screen_locked.png -swirl 360 -paint 1 /tmp/screen_locked.png + +## Lock the gnome-keyring +#test -x ~/.bin/lock-keyring && ~/.bin/lock-keyring + +## Lock screen displaying this image. +i3lock --show-failed-attempts --image=/tmp/screen_locked.png + +## Turn the screen off after a delay. +sleep 300; pgrep i3lock && xset dpms force off diff --git a/dotfiles/my-binaries/dot-bin/server.py b/dotfiles/my-binaries/dot-bin/server.py new file mode 100755 index 0000000..1e22a3c --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/server.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python3 + +import http.server as SimpleHTTPServer +import socketserver as SocketServer +import logging + +PORT = 8000 + +class GetHandler( + SimpleHTTPServer.SimpleHTTPRequestHandler + ): + + def do_GET(self): + logging.error(self.headers) + SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self) + + +Handler = GetHandler +httpd = SocketServer.TCPServer(("", PORT), Handler) + +httpd.serve_forever() + diff --git a/dotfiles/my-binaries/dot-bin/startAltBrowser.sh b/dotfiles/my-binaries/dot-bin/startAltBrowser.sh new file mode 100755 index 0000000..f5866f2 --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/startAltBrowser.sh @@ -0,0 +1,15 @@ +#!/bin/sh +############################################################################### +## +# Starts the correct browser +# +# +# +############################################################################### + +test -x ~/.local/bin/startAltBrowser.sh && (~/.local/bin/startAltBrowser.sh $@) && exit 0 +test -x /usr/bin/firefox && (/usr/bin/firefox $@ &) && exit 0 +test -x /usr/bin/chromium && (/usr/bin/chromium --force-dark-mode $@ &) && exit 0 + +i3-nagbar -m "None of your favorite browsers were found :-(" +exit 1 diff --git a/dotfiles/my-binaries/dot-bin/startAltBrowserPrivat.sh b/dotfiles/my-binaries/dot-bin/startAltBrowserPrivat.sh new file mode 100755 index 0000000..74f2776 --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/startAltBrowserPrivat.sh @@ -0,0 +1,18 @@ +#!/bin/sh +############################################################################### +## +# Starts the correct browser in private-mode +# +# +# +############################################################################### + +export MOZ_USE_XINPUT2=1 + + +test -x ~/.local/bin/startAltBrowserPrivat.sh && (~/.local/bin/startAltBrowserPrivat.sh $@) && exit 0 +test -x /usr/bin/firefox && (/usr/bin/firefox --private-window $@ &) && exit 0 +test -x /usr/bin/chromium && (/usr/bin/chromium --force-dark-mode --incognito $@ &) && exit 0 + +i3-nagbar -m "None of your favorite browsers were found :-(" +exit 1 diff --git a/dotfiles/my-binaries/dot-bin/startBrowser.sh b/dotfiles/my-binaries/dot-bin/startBrowser.sh new file mode 100755 index 0000000..075192b --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/startBrowser.sh @@ -0,0 +1,19 @@ +#!/bin/sh +############################################################################### +## +# Starts the correct browser +# +# +# +############################################################################### + + +export MOZ_USE_XINPUT2=1 + + +test -x ~/.local/bin/startBrowser.sh && (~/.local/bin/startBrowser.sh $@) && exit 0 +test -x /usr/bin/firefox && (/usr/bin/firefox $@ &) && exit 0 +test -x /usr/bin/chromium && (/usr/bin/chromium --force-dark-mode $@ &) && exit 0 + +i3-nagbar -m "None of your favorite browsers were found :-(" +exit 1 diff --git a/dotfiles/my-binaries/dot-bin/startBrowserPrivat.sh b/dotfiles/my-binaries/dot-bin/startBrowserPrivat.sh new file mode 100755 index 0000000..ef0ee69 --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/startBrowserPrivat.sh @@ -0,0 +1,15 @@ +#!/bin/sh +############################################################################### +## +# Starts the correct browser in private-mode +# +# +# +############################################################################### + +test -x ~/.local/bin/startBrowserPrivat.sh && (~/.local/bin/startBrowserPrivat.sh $@) && exit 0 +test -x /usr/bin/firefox && (/usr/bin/firefox --private-window $@ &) && exit 0 +test -x /usr/bin/chromium && (/usr/bin/chromium --force-dark-mode --incognito $@ &) && exit 0 + +i3-nagbar -m "None of your favorite browsers were found :-(" +exit 1 diff --git a/dotfiles/my-binaries/dot-bin/switchTermColours.sh b/dotfiles/my-binaries/dot-bin/switchTermColours.sh new file mode 100755 index 0000000..6d931be --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/switchTermColours.sh @@ -0,0 +1,32 @@ +#!/bin/sh +############################################################################### +## +# Switch alacritty colourscheme +# +############################################################################### + + +theme=$(ls -1 ~/.config/alacritty/color | rofi -dmenu -p "Select alacritty theme") +rc=$? + +echo "Selected theme: ~/.config/alacritty/color/$theme" + +## Exit if error in selection (e.g. ESC) +if [ $rc -ne 0 ] +then + echo "Operation canceled." + echo "" + exit 125 +fi + +## Exit if selection is no file from the colors directory +if [ ! -f ~/.config/alacritty/color/$theme ] +then + echo "Selected theme not found." + echo "" + exit 2 +fi + +#sed -i "{s+.*#MARK-color$+import = [\"color/$theme\"] #MARK-color+}" ~/.config/alacritty/alacritty.toml + +ln -fs ~/.config/alacritty/color/$theme ~/.local/alacritty_colors.toml diff --git a/dotfiles/my-binaries/dot-bin/tsaClient.sh b/dotfiles/my-binaries/dot-bin/tsaClient.sh new file mode 100755 index 0000000..a218b7d --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/tsaClient.sh @@ -0,0 +1,67 @@ +#!/bin/bash +######################################################################### +## tsaClient.sh +# +# Clientscript for the FreeTSA Timestamping Service +# This script generates a tgz archive containing a given file and the +# timestamping information from freetsa.org including tsr, tsq, log and +# the ca certificates. +# +# devops@elfring.ms - 2019-05-29 +# +# + +echo "Clientscript for the FreeTSA Timestamping Service" +echo "https://www.freetsa.org" +echo + +fileToStamp=$1 + +if [ _$# != _1 ] +then + echo "Usage: $0 [file to timestamp]" + echo + exit 1 +fi + +if [ ! -e $fileToStamp ] +then + echo "$fileToStamp does not exist." + echo + exit 2 +fi + +{ +echo "Timestamping file $fileToStamp" +echo + +echo "-------> Create SHA512 checksum (informational)" +echo "# sha512sum $fileToStamp" +sha512sum $fileToStamp 2>&1 | sed 's/^/ /' +echo + +echo "-------> Create and display timestamp query (TSQ)" +echo "# openssl ts -query -data $fileToStamp -no_nonce -sha512 -cert -out $fileToStamp.tsq" +echo "# openssl ts -query -in $fileToStamp.tsq -text" +openssl ts -query -data $fileToStamp -no_nonce -sha512 -cert -out $fileToStamp.tsq 2>&1 | sed 's/^/ /' +openssl ts -query -in $fileToStamp.tsq -text 2>&1 | sed 's/^/ /' +echo + +echo "-------> Have the TSQ signed and display the reply (TSR)" +echo "# curl --silent --header "Content-Type: application/timestamp-query" --data-binary "@$fileToStamp.tsq" https://freetsa.org/tsr --output $fileToStamp.tsr" +echo "# openssl ts -reply -in $fileToStamp.tsq -text" +curl --silent --header "Content-Type: application/timestamp-query" --data-binary "@$fileToStamp.tsq" https://freetsa.org/tsr --output $fileToStamp.tsr 2>&1 | sed 's/^/ /' +openssl ts -reply -in $fileToStamp.tsr -text 2>&1 | sed 's/^/ /' +echo + +echo "-------> Verify TSR (informational)" +echo "# curl --silent --output freetsa_cacert.pem https://freetsa.org/files/cacert.pem" +echo "# openssl ts -verify -data $fileToStamp -in $fileToStamp.tsr -CAfile freetsa_cacert.pem" +curl --silent --output freetsa_cacert.pem https://freetsa.org/files/cacert.pem 2>&1 | sed 's/^/ /' +openssl ts -verify -data $fileToStamp -in $fileToStamp.tsr -CAfile freetsa_cacert.pem 2>&1 | sed 's/^/ /' + +} | tee $fileToStamp.log + +tar czf $fileToStamp.tsa.tgz $fileToStamp.tsq $fileToStamp.tsr $fileToStamp.log freetsa_cacert.pem $fileToStamp +rm $fileToStamp.tsq $fileToStamp.tsr $fileToStamp.log freetsa_cacert.pem +echo diff --git a/dotfiles/my-binaries/dot-bin/wdavmaild b/dotfiles/my-binaries/dot-bin/wdavmaild new file mode 100755 index 0000000..4affdbd --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/wdavmaild @@ -0,0 +1,17 @@ +#!/bin/bash +############################################################################ +## +# wddavmaild +# +# +# + +## Check for a tmux session with docker fo:wqr root is already running +if tmux has-session -t wdavmaild +then + echo "A wdavmaild session is already running. Attaching." + tmux attach -t wdavmaild +else + echo "Starting a new wdavmaild tmux-session." + tmux new-session -d -s wdavmaild davmail ~/.local/etc/davmail.conf +fi diff --git a/dotfiles/my-binaries/dot-bin/wdockerd b/dotfiles/my-binaries/dot-bin/wdockerd new file mode 100755 index 0000000..4a37d26 --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/wdockerd @@ -0,0 +1,26 @@ +#!/bin/bash +############################################################################ +## +# wdockerd +# Start dockerd inside a tmux session for use in WSL +# +# + +## Ask for sudo credentials +sudo --validate + +if ! $(sudo --non-interactive /bin/true) +then + echo "We cannot become root with sudo. Exiting." + exit 1 +fi + +## Check for a tmux session with docker fo:wqr root is already running +if $(sudo --non-interactive bash -c 'tmux has-session -t wdockerd') +then + echo "A wdockerd session is already running. Attaching." + sudo --non-interactive tmux attach -t wdockerd +else + echo "Starting a new dockerd tmux-session." + sudo --non-interactive tmux new-session -d -s wdockerd dockerd +fi diff --git a/dotfiles/my-binaries/dot-bin/xcqr b/dotfiles/my-binaries/dot-bin/xcqr new file mode 100755 index 0000000..03e7abe --- /dev/null +++ b/dotfiles/my-binaries/dot-bin/xcqr @@ -0,0 +1,10 @@ +#!/bin/sh +# Credit to Maddison Hellstrom (@b0o on Github) +text=$(xclip -out -selection clipboard) +notify-send --expire-time 3000 "Clipboard" "$text" +qrencode --output - --size 1 "$text" \ + | feh --zoom max \ + --fullscreen \ + --force-aliasing \ + --image-bg white \ + - diff --git a/dotfiles/pikaur/dot-config/pikaur.conf b/dotfiles/pikaur/dot-config/pikaur.conf new file mode 100644 index 0000000..2fe1a2b --- /dev/null +++ b/dotfiles/pikaur/dot-config/pikaur.conf @@ -0,0 +1,57 @@ +[sync] +alwaysshowpkgorigin = no +develpkgsexpiration = 301 +upgradesorting = versiondiff +showdownloadsize = yes +ignoreoutofdateaurupgrades = no + +[build] +keepbuilddir = no +keepdevbuilddir = yes +skipfailedbuild = no +keepbuilddeps = no +ignorearch = no +gpgdir = +dynamicusers = root + +[colors] +version = 10 +versiondiffold = 11 +versiondiffnew = 9 + +[ui] +requireenterconfirm = no +printcommands = no +aursearchsorting = hottest +displaylastupdated = yes +groupbyrepository = yes +reversesearchsorting = no +warnaboutpackageupdates = +warnaboutnondefaultprivilegeescalationtool = yes + +[misc] +sudoloopinterval = 1 +pacmanpath = pacman +debug = no +privilegeescalationtool = sudo +privilegeescalationtarget = pikaur +userid = 0 +preserveenv = PKGDEST,VISUAL,EDITOR,http_proxy,https_proxy,ftp_proxy,HTTP_PROXY,HTTPS_PROXY,FTP_PROXY,ALL_PROXY +cachepath = /home/je/.cache +datapath = /home/je/.local/share + +[review] +noedit = yes +donteditbydefault = yes +nodiff = yes +gitdiffargs = --ignore-space-change,--ignore-all-space +diffpager = auto +hidedifffiles = .SRCINFO + +[network] +aururl = https://aur.archlinux.org +newsurl = https://archlinux.org/feeds/news/ +socks5proxy = +aurhttpproxy = +aurhttpsproxy = + diff --git a/dotfiles/ranger/dot-config/commands.py b/dotfiles/ranger/dot-config/commands.py new file mode 100644 index 0000000..97b7909 --- /dev/null +++ b/dotfiles/ranger/dot-config/commands.py @@ -0,0 +1,62 @@ +# This is a sample commands.py. You can add your own commands here. +# +# Please refer to commands_full.py for all the default commands and a complete +# documentation. Do NOT add them all here, or you may end up with defunct +# commands when upgrading ranger. + +# A simple command for demonstration purposes follows. +# ----------------------------------------------------------------------------- + +from __future__ import (absolute_import, division, print_function) + +# You can import any python module as needed. +import os + +# You always need to import ranger.api.commands here to get the Command class: +from ranger.api.commands import Command + + +# Any class that is a subclass of "Command" will be integrated into ranger as a +# command. Try typing ":my_edit" in ranger! +class my_edit(Command): + # The so-called doc-string of the class will be visible in the built-in + # help that is accessible by typing "?c" inside ranger. + """:my_edit + + A sample command for demonstration purposes that opens a file in an editor. + """ + + # The execute method is called when you run this command in ranger. + def execute(self): + # self.arg(1) is the first (space-separated) argument to the function. + # This way you can write ":my_edit somefilename". + if self.arg(1): + # self.rest(1) contains self.arg(1) and everything that follows + target_filename = self.rest(1) + else: + # self.fm is a ranger.core.filemanager.FileManager object and gives + # you access to internals of ranger. + # self.fm.thisfile is a ranger.container.file.File object and is a + # reference to the currently selected file. + target_filename = self.fm.thisfile.path + + # This is a generic function to print text in ranger. + self.fm.notify("Let's edit the file " + target_filename + "!") + + # Using bad=True in fm.notify allows you to print error messages: + if not os.path.exists(target_filename): + self.fm.notify("The given file does not exist!", bad=True) + return + + # This executes a function from ranger.core.acitons, a module with a + # variety of subroutines that can help you construct commands. + # Check out the source, or run "pydoc ranger.core.actions" for a list. + self.fm.edit_file(target_filename) + + # The tab method is called when you press tab, and should return a list of + # suggestions that the user will tab through. + # tabnum is 1 for and -1 for by default + def tab(self, tabnum): + # This is a generic tab-completion function that iterates through the + # content of the current directory. + return self._tab_directory_content() diff --git a/dotfiles/ranger/dot-config/commands_full.py b/dotfiles/ranger/dot-config/commands_full.py new file mode 100644 index 0000000..a3837d8 --- /dev/null +++ b/dotfiles/ranger/dot-config/commands_full.py @@ -0,0 +1,1769 @@ +# -*- coding: utf-8 -*- +# This file is part of ranger, the console file manager. +# This configuration file is licensed under the same terms as ranger. +# =================================================================== +# +# NOTE: If you copied this file to ~/.config/ranger/commands_full.py, +# then it will NOT be loaded by ranger, and only serve as a reference. +# +# =================================================================== +# This file contains ranger's commands. +# It's all in python; lines beginning with # are comments. +# +# Note that additional commands are automatically generated from the methods +# of the class ranger.core.actions.Actions. +# +# You can customize commands in the file ~/.config/ranger/commands.py. +# It has the same syntax as this file. In fact, you can just copy this +# file there with `ranger --copy-config=commands' and make your modifications. +# But make sure you update your configs when you update ranger. +# +# =================================================================== +# Every class defined here which is a subclass of `Command' will be used as a +# command in ranger. Several methods are defined to interface with ranger: +# execute(): called when the command is executed. +# cancel(): called when closing the console. +# tab(tabnum): called when is pressed. +# quick(): called after each keypress. +# +# tab() argument tabnum is 1 for and -1 for by default +# +# The return values for tab() can be either: +# None: There is no tab completion +# A string: Change the console to this string +# A list/tuple/generator: cycle through every item in it +# +# The return value for quick() can be: +# False: Nothing happens +# True: Execute the command afterwards +# +# The return value for execute() and cancel() doesn't matter. +# +# =================================================================== +# Commands have certain attributes and methods that facilitate parsing of +# the arguments: +# +# self.line: The whole line that was written in the console. +# self.args: A list of all (space-separated) arguments to the command. +# self.quantifier: If this command was mapped to the key "X" and +# the user pressed 6X, self.quantifier will be 6. +# self.arg(n): The n-th argument, or an empty string if it doesn't exist. +# self.rest(n): The n-th argument plus everything that followed. For example, +# if the command was "search foo bar a b c", rest(2) will be "bar a b c" +# self.start(n): Anything before the n-th argument. For example, if the +# command was "search foo bar a b c", start(2) will be "search foo" +# +# =================================================================== +# And this is a little reference for common ranger functions and objects: +# +# self.fm: A reference to the "fm" object which contains most information +# about ranger. +# self.fm.notify(string): Print the given string on the screen. +# self.fm.notify(string, bad=True): Print the given string in RED. +# self.fm.reload_cwd(): Reload the current working directory. +# self.fm.thisdir: The current working directory. (A File object.) +# self.fm.thisfile: The current file. (A File object too.) +# self.fm.thistab.get_selection(): A list of all selected files. +# self.fm.execute_console(string): Execute the string as a ranger command. +# self.fm.open_console(string): Open the console with the given string +# already typed in for you. +# self.fm.move(direction): Moves the cursor in the given direction, which +# can be something like down=3, up=5, right=1, left=1, to=6, ... +# +# File objects (for example self.fm.thisfile) have these useful attributes and +# methods: +# +# tfile.path: The path to the file. +# tfile.basename: The base name only. +# tfile.load_content(): Force a loading of the directories content (which +# obviously works with directories only) +# tfile.is_directory: True/False depending on whether it's a directory. +# +# For advanced commands it is unavoidable to dive a bit into the source code +# of ranger. +# =================================================================== + +from __future__ import (absolute_import, division, print_function) + +from collections import deque +import os +import re + +from ranger.api.commands import Command + + +class alias(Command): + """:alias + + Copies the oldcommand as newcommand. + """ + + context = 'browser' + resolve_macros = False + + def execute(self): + if not self.arg(1) or not self.arg(2): + self.fm.notify('Syntax: alias ', bad=True) + return + + self.fm.commands.alias(self.arg(1), self.rest(2)) + + +class echo(Command): + """:echo + + Display the text in the statusbar. + """ + + def execute(self): + self.fm.notify(self.rest(1)) + + +class cd(Command): + """:cd [-r] + + The cd command changes the directory. + The command 'cd -' is equivalent to typing ``. + Using the option "-r" will get you to the real path. + """ + + def execute(self): + if self.arg(1) == '-r': + self.shift() + destination = os.path.realpath(self.rest(1)) + if os.path.isfile(destination): + self.fm.select_file(destination) + return + else: + destination = self.rest(1) + + if not destination: + destination = '~' + + if destination == '-': + self.fm.enter_bookmark('`') + else: + self.fm.cd(destination) + + def _tab_args(self): + # dest must be rest because path could contain spaces + if self.arg(1) == '-r': + start = self.start(2) + dest = self.rest(2) + else: + start = self.start(1) + dest = self.rest(1) + + if dest: + head, tail = os.path.split(os.path.expanduser(dest)) + if head: + dest_exp = os.path.join(os.path.normpath(head), tail) + else: + dest_exp = tail + else: + dest_exp = '' + return (start, dest_exp, os.path.join(self.fm.thisdir.path, dest_exp), + dest.endswith(os.path.sep)) + + @staticmethod + def _tab_paths(dest, dest_abs, ends_with_sep): + if not dest: + try: + return next(os.walk(dest_abs))[1], dest_abs + except (OSError, StopIteration): + return [], '' + + if ends_with_sep: + try: + return [os.path.join(dest, path) for path in next(os.walk(dest_abs))[1]], '' + except (OSError, StopIteration): + return [], '' + + return None, None + + def _tab_match(self, path_user, path_file): + if self.fm.settings.cd_tab_case == 'insensitive': + path_user = path_user.lower() + path_file = path_file.lower() + elif self.fm.settings.cd_tab_case == 'smart' and path_user.islower(): + path_file = path_file.lower() + return path_file.startswith(path_user) + + def _tab_normal(self, dest, dest_abs): + dest_dir = os.path.dirname(dest) + dest_base = os.path.basename(dest) + + try: + dirnames = next(os.walk(os.path.dirname(dest_abs)))[1] + except (OSError, StopIteration): + return [], '' + + return [os.path.join(dest_dir, d) for d in dirnames if self._tab_match(dest_base, d)], '' + + def _tab_fuzzy_match(self, basepath, tokens): + """ Find directories matching tokens recursively """ + if not tokens: + tokens = [''] + paths = [basepath] + while True: + token = tokens.pop() + matches = [] + for path in paths: + try: + directories = next(os.walk(path))[1] + except (OSError, StopIteration): + continue + matches += [os.path.join(path, d) for d in directories + if self._tab_match(token, d)] + if not tokens or not matches: + return matches + paths = matches + + return None + + def _tab_fuzzy(self, dest, dest_abs): + tokens = [] + basepath = dest_abs + while True: + basepath_old = basepath + basepath, token = os.path.split(basepath) + if basepath == basepath_old: + break + if os.path.isdir(basepath_old) and not token.startswith('.'): + basepath = basepath_old + break + tokens.append(token) + + paths = self._tab_fuzzy_match(basepath, tokens) + if not os.path.isabs(dest): + paths_rel = basepath + paths = [os.path.relpath(path, paths_rel) for path in paths] + else: + paths_rel = '' + return paths, paths_rel + + def tab(self, tabnum): + from os.path import sep + + start, dest, dest_abs, ends_with_sep = self._tab_args() + + paths, paths_rel = self._tab_paths(dest, dest_abs, ends_with_sep) + if paths is None: + if self.fm.settings.cd_tab_fuzzy: + paths, paths_rel = self._tab_fuzzy(dest, dest_abs) + else: + paths, paths_rel = self._tab_normal(dest, dest_abs) + + paths.sort() + + if self.fm.settings.cd_bookmarks: + paths[0:0] = [ + os.path.relpath(v.path, paths_rel) if paths_rel else v.path + for v in self.fm.bookmarks.dct.values() for path in paths + if v.path.startswith(os.path.join(paths_rel, path) + sep) + ] + + if not paths: + return None + if len(paths) == 1: + return start + paths[0] + sep + return [start + dirname for dirname in paths] + + +class chain(Command): + """:chain ; ; ... + + Calls multiple commands at once, separated by semicolons. + """ + + def execute(self): + if not self.rest(1).strip(): + self.fm.notify('Syntax: chain ; ; ...', bad=True) + return + for command in [s.strip() for s in self.rest(1).split(";")]: + self.fm.execute_console(command) + + +class shell(Command): + escape_macros_for_shell = True + + def execute(self): + if self.arg(1) and self.arg(1)[0] == '-': + flags = self.arg(1)[1:] + command = self.rest(2) + else: + flags = '' + command = self.rest(1) + + if command: + self.fm.execute_command(command, flags=flags) + + def tab(self, tabnum): + from ranger.ext.get_executables import get_executables + if self.arg(1) and self.arg(1)[0] == '-': + command = self.rest(2) + else: + command = self.rest(1) + start = self.line[0:len(self.line) - len(command)] + + try: + position_of_last_space = command.rindex(" ") + except ValueError: + return (start + program + ' ' for program + in get_executables() if program.startswith(command)) + if position_of_last_space == len(command) - 1: + selection = self.fm.thistab.get_selection() + if len(selection) == 1: + return self.line + selection[0].shell_escaped_basename + ' ' + return self.line + '%s ' + + before_word, start_of_word = self.line.rsplit(' ', 1) + return (before_word + ' ' + file.shell_escaped_basename + for file in self.fm.thisdir.files or [] + if file.shell_escaped_basename.startswith(start_of_word)) + + +class open_with(Command): + + def execute(self): + app, flags, mode = self._get_app_flags_mode(self.rest(1)) + self.fm.execute_file( + files=[f for f in self.fm.thistab.get_selection()], + app=app, + flags=flags, + mode=mode) + + def tab(self, tabnum): + return self._tab_through_executables() + + def _get_app_flags_mode(self, string): # pylint: disable=too-many-branches,too-many-statements + """Extracts the application, flags and mode from a string. + + examples: + "mplayer f 1" => ("mplayer", "f", 1) + "atool 4" => ("atool", "", 4) + "p" => ("", "p", 0) + "" => None + """ + + app = '' + flags = '' + mode = 0 + split = string.split() + + if len(split) == 1: + part = split[0] + if self._is_app(part): + app = part + elif self._is_flags(part): + flags = part + elif self._is_mode(part): + mode = part + + elif len(split) == 2: + part0 = split[0] + part1 = split[1] + + if self._is_app(part0): + app = part0 + if self._is_flags(part1): + flags = part1 + elif self._is_mode(part1): + mode = part1 + elif self._is_flags(part0): + flags = part0 + if self._is_mode(part1): + mode = part1 + elif self._is_mode(part0): + mode = part0 + if self._is_flags(part1): + flags = part1 + + elif len(split) >= 3: + part0 = split[0] + part1 = split[1] + part2 = split[2] + + if self._is_app(part0): + app = part0 + if self._is_flags(part1): + flags = part1 + if self._is_mode(part2): + mode = part2 + elif self._is_mode(part1): + mode = part1 + if self._is_flags(part2): + flags = part2 + elif self._is_flags(part0): + flags = part0 + if self._is_mode(part1): + mode = part1 + elif self._is_mode(part0): + mode = part0 + if self._is_flags(part1): + flags = part1 + + return app, flags, int(mode) + + def _is_app(self, arg): + return not self._is_flags(arg) and not arg.isdigit() + + @staticmethod + def _is_flags(arg): + from ranger.core.runner import ALLOWED_FLAGS + return all(x in ALLOWED_FLAGS for x in arg) + + @staticmethod + def _is_mode(arg): + return all(x in '0123456789' for x in arg) + + +class set_(Command): + """:set