implement templates

This commit is contained in:
Daniel Mevec 2023-08-29 21:37:28 +02:00
parent 7d9e4e79cf
commit 9c9e8b71f2
3 changed files with 616 additions and 0 deletions

View file

@ -0,0 +1,438 @@
# -*- coding: utf-8 -*-
import os
import re
import socket
import subprocess
from libqtile import qtile
from libqtile.config import Click, Drag, Group, KeyChord, Key, Match, Screen, ScratchPad, DropDown
from libqtile.command import lazy
from libqtile import layout, bar, widget, hook
from libqtile.lazy import lazy
from libqtile.utils import guess_terminal
from typing import List # noqa: F401from typing import List # noqa: F401
from qtile_extras import widget
from qtile_extras.widget import UPowerWidget
from qtile_extras.widget.decorations import PowerLineDecoration
from qutils import get_num_screens, get_network_interface, get_batteries, Colors
mod = "mod4" # Sets mod key to SUPER/WINDOWS
myTerm = "alacritty"
myBrowser = "firefox"
{{ if eq .chezmoi.hostname "t450s" }}
myExplorer = "thunar"
sound_ctrl = "pavucontrol"
update_distro_key = "Arch"
{{ else }}
myExplorer = "nemo"
sound_ctrl = "cinnamon-settings sound"
update_distro_key = "Ubuntu"
{{ end }}
keys = [
# ## The essentials
Key([mod], "Return", lazy.spawn(myTerm), desc='Launches My Terminal'),
Key([mod], "space", lazy.spawn("rofi -show run"), desc='Run Launcher'),
Key([mod], "b", lazy.spawn(myBrowser), desc='Qutebrowser'),
Key([mod], "l", lazy.spawn("cinnamon-screensaver-command -a"), desc='Qutebrowser'),
Key([mod], "Tab", lazy.next_layout(), desc='Toggle through layouts'),
Key([mod, "shift"], "c", lazy.window.kill(), desc='Kill active window'),
Key([mod, "shift"], "r", lazy.restart(), desc='Restart Qtile'),
Key([mod, "shift"], "q", lazy.shutdown(), desc='Shutdown Qtile'),
Key([mod, "shift"], "p", lazy.spawn("""rofi -show p -modi p:'rofi-power-menu \\
--symbols-font \"Symbols Nerd Font Mono\" \\
--choices=shutdown/reboot/suspend/logout' \\
-theme-str 'window {width: 12em;} listview {lines: 4;}'"""),
desc='Run Shutdown Menu'),
Key([mod], "period", lazy.spawn("rofimoji"), desc='Emoji Picker'),
# ## Switch focus of monitors
Key([mod, "control"], "Right", lazy.next_screen(), desc='Move focus to next monitor'),
Key([mod, "control"], "Left", lazy.prev_screen(), desc='Move focus to prev monitor'),
# ## Window controls
Key([mod], "Up", lazy.layout.up(), desc='Move focus up'),
Key([mod], "Down", lazy.layout.down(), desc='Move focus down'),
Key([mod], "Left", lazy.layout.left(), desc='Move focus left'),
Key([mod], "Right", lazy.layout.right(), desc='Move focus right'),
Key([mod, "shift"], "Up", lazy.layout.shuffle_up(), lazy.layout.section_up(),
desc='Move windows up in current stack'),
Key([mod, "shift"], "Down", lazy.layout.shuffle_down(), lazy.layout.section_down(),
desc='Move windows down in current stack'),
Key([mod, "shift"], "Left", lazy.layout.shuffle_left(), desc='Move windows left'),
Key([mod, "shift"], "Right", lazy.layout.shuffle_right(), desc='Move windows right'),
Key([mod], "minus", lazy.layout.shrink(), lazy.layout.decrease_nmaster(),
desc='Shrink window (MonadTall), decrease number in master pane (Tile)'),
Key([mod], "equal", lazy.layout.grow(), lazy.layout.increase_nmaster(),
desc='Expand window (MonadTall), increase number in master pane (Tile)'),
# Grow windows. If current window is on the edge of screen and direction
# will be to screen edge - window would shrink.
# Key([mod, "control"], "Up", lazy.layout.grow_up(), desc="Grow window up"),
# Key([mod, "control"], "Down", lazy.layout.grow_down(), desc="Grow window down"),
# Key([mod, "control"], "Left", lazy.layout.grow_left(), desc="Grow window to the left"),
# Key([mod, "control"], "Right", lazy.layout.grow_right(), desc="Grow window to the right"),
Key([mod], "n", lazy.layout.normalize(), desc='normalize window size ratios'),
Key([mod], "m", lazy.layout.maximize(), desc='toggle window between minimum and maximum sizes'),
Key([mod, "shift"], "f", lazy.window.toggle_floating(), desc='toggle floating'),
Key([mod], "f", lazy.window.toggle_fullscreen(), desc='toggle fullscreen'),
# ## Stack controls
# Key([mod, "shift"], "Tab", lazy.layout.rotate(), lazy.layout.flip(),
# desc='Switch which side main pane occupies (XmonadTall)'),
# Key([mod], "space", lazy.layout.next(), desc='Switch window focus to other pane(s) of stack'),
# Key([mod, "shift"], "space", lazy.layout.toggle_split(),
# desc='Toggle between split and unsplit sides of stack'),
]
groups = [Group("CHT", matches=[Match(wm_class=('microsoft teams - preview'))]),
Group("WWW",
matches=[Match(wm_class=['Firefox',
'firefox',
'firefox-bin',
'Chromium',
'Google-chrome',
'google-chrome'])]),
Group("DEV"),
Group("SYS"),
Group("REF"),
Group("DOC", matches=[Match(wm_class=['obsidian'])]),
Group("DMP")]
# Allow MODKEY+[0 through 9] to bind to groups, see https://docs.qtile.org/en/stable/manual/config/groups.html
# MOD4 + index Number : Switch to Group[index]
# MOD4 + shift + index Number : Send active window to another Group
from libqtile.dgroups import simple_key_binder
dgroups_key_binder = simple_key_binder("mod4")
groups.append(ScratchPad('scratch', [
DropDown('term', myTerm, height=0.66, width=0.66, x=0.166, y=0.166),
DropDown('qalc', myTerm+' -e qalc', height=0.66, width=0.33, x=0.33, y=0.166),
DropDown('file', myExplorer, height=0.66, width=0.66, x=0.166, y=0.166),
DropDown('sound', sound_ctrl, height=0.66, width=0.50, x=0.25, y=0.166),
]),
)
keys.extend([
Key([mod], 'q', lazy.group['scratch'].dropdown_toggle('qalc')),
Key([mod], 'w', lazy.group['scratch'].dropdown_toggle('term')),
Key([mod], 'e', lazy.group['scratch'].dropdown_toggle('file')),
Key([mod], 's', lazy.group['scratch'].dropdown_toggle('sound')),
])
layout_theme = {"border_width": 2,
"margin": 8,
"border_focus": Colors.green,
"border_normal": Colors.grey,
"ratio": 0.6180469715698392,
"new_client_position": "bottom",
}
layouts = [
layout.MonadTall(**layout_theme),
layout.MonadWide(**layout_theme),
layout.Max(**layout_theme),
# layout.MonadThreeCol(main_centered=False, **layout_theme),
# layout.RatioTile(**layout_theme),
# layout.TreeTab(
# font = "Ubuntu",
# fontsize = 10,
# # sections = ["FIRST", "SECOND", "THIRD", "FOURTH"],
# section_fontsize = 10,
# border_width = 2,
# bg_color = Colors.bg,
# active_bg = Colors.green,
# active_fg = Colors.bg,
# inactive_bg = Colors.grey,
# inactive_fg = Colors.bg,
# padding_left = 0,
# padding_x = 0,
# padding_y = 5,
# section_top = 10,
# section_bottom = 20,
# level_shift = 8,
# vspace = 3,
# panel_width = 150
# ),
# layout.Floating(**layout_theme)
]
prompt = "{0}@{1}: ".format(os.environ["USER"], socket.gethostname())
# #### DEFAULT WIDGET SETTINGS #####
widget_defaults = dict(
font="FiraCode Nerd Font Bold",
fontsize=11,
padding=0,
background=Colors.bg
)
extension_defaults = widget_defaults.copy()
def init_widgets_list():
powerline = {
"decorations": [
PowerLineDecoration(path='back_slash')
]
}
widgets_list = [
# widget.Image(filename = "~/.config/qtile/icons/python-white.png"),
widget.TextBox(
text=u'\ue73c',
foreground=Colors.fg,
fontsize=22,
padding=12,
# mouse_callbacks={'Button1': lambda: qtile.cmd_spawn(myTerm)}
),
widget.GroupBox(
font="Ubuntu Bold",
fontsize=9,
margin_y=3,
margin_x=0,
padding_y=5,
padding_x=3,
borderwidth=3,
active=Colors.fg,
inactive=Colors.grey,
rounded=False,
highlight_color=Colors.orange,
highlight_method="line",
this_current_screen_border=Colors.blue,
other_screen_border=Colors.grey,
this_screen_border=Colors.blue,
other_current_screen_border=Colors.grey,
foreground=Colors.fg,
background=Colors.bg
),
widget.Sep(
foreground=Colors.red,
padding=8
),
widget.CurrentLayoutIcon(
# custom_icon_paths=[os.path.expanduser("~/.config/qtile/icons")],
foreground=Colors.red,
background=Colors.bg,
padding=0,
scale=0.7
),
widget.Prompt(),
widget.Sep(
foreground=Colors.red,
padding=8
),
widget.WindowName(
fontsize=10,
foreground=Colors.yellow,
background=Colors.bg,
padding=0,
**powerline,
),
widget.Systray(
background=Colors.bg1,
padding=5,
**powerline,
),
# widget.Battery(
# battery=0,
# fmt=' {}',
# charge_char=u'\uf583',
# discharge_char=u'\uf57d',
# empty_char=u'\uf582',
# full_char=u'\uf578',
# unknown_char=u'\uf590',
# format='{char} {percent:2.0%} {hour:d}:{min:02d}',
# background=Colors.yellow,
# foreground=Colors.bg,
# **powerline,
# ),
widget.ThermalSensor(
foreground=Colors.bg,
background=Colors.orange,
threshold=90,
fmt='\uf8c7 {}',
**powerline,
),
widget.CheckUpdates(
update_interval=1800,
distro=update_distro_key,
markup=False,
display_format="\uf546 {updates}",
foreground=Colors.bg,
colour_have_updates=Colors.bg,
colour_no_updates=Colors.bg,
background=Colors.red,
**powerline,
),
widget.Memory(
foreground=Colors.bg,
background=Colors.purple,
mouse_callbacks={'Button1': lambda: qtile.cmd_spawn(myTerm + ' -e htop')},
fmt='{}',
format='\uf85a{MemPercent:5.1f} %',
**powerline,
),
widget.CPU(
foreground=Colors.bg,
background=Colors.blue,
fmt='{}',
format='\ufb19{load_percent:5.1f}%',
**powerline,
),
widget.Net(
interface=get_network_interface(),
format='{down} ↓↑ {up}',
prefix='M',
foreground=Colors.bg,
background=Colors.aqua,
**powerline,
),
widget.Clock(
foreground=Colors.bg,
background=Colors.green,
format="%Y-%m-%d %a %H:%M ",
padding=5
),
]
upw_kwargs = {
"background": Colors.yellow,
"foreground": Colors.bg,
"border_colour": Colors.bg,
"border_critical_colour": Colors.red,
"border_charge_colour": Colors.blue,
"fill_critical": Colors.red,
"fill_low": Colors.red,
"fill_normal": Colors.bg2,
"text_charging": '({percentage:.0f}%) {ttf}',
"text_discharging": '({percentage:.0f}%) {tte}',
"spacing": 10,
}
upw_kwargs.update(powerline)
widgets_list[8:8] = [UPowerWidget(battery_name=battery, **upw_kwargs) for battery in get_batteries()]
return widgets_list
def init_widgets_screen1():
widgets_screen1 = init_widgets_list()
del widgets_screen1[7:8] # Slicing removes (systray) on Monitors 1,3
del widgets_screen1[4:5] # Slicing removes (prompt) on Monitors 1,3
return widgets_screen1
def init_widgets_screen2():
widgets_screen2 = init_widgets_list()
return widgets_screen2 # display all widgets in widgets_list
def init_screens():
num_screens = get_num_screens()
if num_screens <= 1:
return [Screen(top=bar.Bar(widgets=init_widgets_screen2(), opacity=1.0, size=20))]
elif num_screens == 2:
return [
Screen(top=bar.Bar(widgets=init_widgets_screen1(), opacity=1.0, size=20)),
Screen(top=bar.Bar(widgets=init_widgets_screen2(), opacity=1.0, size=20)),
]
else:
return [
Screen(top=bar.Bar(widgets=init_widgets_screen1(), opacity=1.0, size=20)),
Screen(top=bar.Bar(widgets=init_widgets_screen2(), opacity=1.0, size=20)),
Screen(top=bar.Bar(widgets=init_widgets_screen1(), opacity=1.0, size=20)),
]
if __name__ in ["config", "__main__"]:
screens = init_screens()
widgets_list = init_widgets_list()
widgets_screen1 = init_widgets_screen1()
widgets_screen2 = init_widgets_screen2()
def window_to_prev_group(qtile):
if qtile.currentWindow is not None:
i = qtile.groups.index(qtile.currentGroup)
qtile.currentWindow.togroup(qtile.groups[i - 1].name)
def window_to_next_group(qtile):
if qtile.currentWindow is not None:
i = qtile.groups.index(qtile.currentGroup)
qtile.currentWindow.togroup(qtile.groups[i + 1].name)
def window_to_previous_screen(qtile):
i = qtile.screens.index(qtile.current_screen)
if i != 0:
group = qtile.screens[i - 1].group.name
qtile.current_window.togroup(group)
def window_to_next_screen(qtile):
i = qtile.screens.index(qtile.current_screen)
if i + 1 != len(qtile.screens):
group = qtile.screens[i + 1].group.name
qtile.current_window.togroup(group)
def switch_screens(qtile):
i = qtile.screens.index(qtile.current_screen)
group = qtile.screens[i - 1].group
qtile.current_screen.set_group(group)
mouse = [
Drag([mod], "Button1", lazy.window.set_position_floating(),
start=lazy.window.get_position()),
Drag([mod], "Button3", lazy.window.set_size_floating(),
start=lazy.window.get_size()),
Click([mod], "Button2", lazy.window.bring_to_front())
]
dgroups_app_rules = [] # type: List
follow_mouse_focus = True
bring_front_click = False
cursor_warp = False
floating_layout = layout.Floating(float_rules=[
# Run the utility of `xprop` to see the wm class and name of an X client.
# default_float_rules include: utility, notification, toolbar, splash, dialog,
# file_progress, confirm, download and error.
*layout.Floating.default_float_rules,
Match(title='Confirmation'), # tastyworks exit box
Match(title='Qalculate!'), # qalculate-gtk
Match(wm_class='kdenlive'), # kdenlive
Match(wm_class='pinentry-gtk-2'), # GPG key password entry
])
auto_fullscreen = True
focus_on_window_activation = "smart"
reconfigure_screens = True
# If things like steam games want to auto-minimize themselves when losing
# focus, should we respect this or not?
auto_minimize = True
@hook.subscribe.startup_once
def start_once():
home = os.path.expanduser('~')
subprocess.call([home + '/.config/qtile/up.sh'])
wmname = "LG3D"
# XXX: Gasp! We're lying here. In fact, nobody really uses or cares about this
# string besides java UI toolkits; you can see several discussions on the
# mailing lists, GitHub issues, and other WM documentation that suggest setting
# this string if your java app doesn't work correctly. We may as well just lie
# and say that we're a working one by default.
#
# We choose LG3D to maximize irony: it is a 3D non-reparenting WM written in
# java that happens to be on java's whitelist.

41
dot_profile.tmpl Normal file
View file

@ -0,0 +1,41 @@
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.
# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
if [ -f "$HOME/.bashrc" ]; then
. "$HOME/.bashrc"
fi
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
if [ -d "$HOME/.cargo/env" ]; then
. "$HOME/.cargo/env"
fi
if [ -d "/opt/pycharm/bin" ] ; then
PATH="/opt/pycharm/bin:$PATH"
fi
export EDITOR='hx'
export VISUAL='hx'
setxkbmap eu
alias xcd='cd "$(xplr --print-pwd-as-result)"'

137
dot_zshrc.tmpl Normal file
View file

@ -0,0 +1,137 @@
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes
# ZSH_THEME="robbyrussell"
ZSH_THEME="headline"
# Set list of themes to pick from when loading at random
# Setting this variable when ZSH_THEME=random will cause zsh to load
# a theme from this variable instead of looking in $ZSH/themes/
# If set to an empty array, this variable will have no effect.
# ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" )
# Uncomment the following line to use case-sensitive completion.
# CASE_SENSITIVE="true"
# Uncomment the following line to use hyphen-insensitive completion.
# Case-sensitive completion must be off. _ and - will be interchangeable.
# HYPHEN_INSENSITIVE="true"
# Uncomment one of the following lines to change the auto-update behavior
# zstyle ':omz:update' mode disabled # disable automatic updates
# zstyle ':omz:update' mode auto # update automatically without asking
# zstyle ':omz:update' mode reminder # just remind me to update when it's time
# Uncomment the following line to change how often to auto-update (in days).
# zstyle ':omz:update' frequency 13
# Uncomment the following line if pasting URLs and other text is messed up.
# DISABLE_MAGIC_FUNCTIONS="true"
# Uncomment the following line to disable colors in ls.
# DISABLE_LS_COLORS="true"
# Uncomment the following line to disable auto-setting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment the following line to enable command auto-correction.
# ENABLE_CORRECTION="true"
# Uncomment the following line to display red dots whilst waiting for completion.
# You can also set it to another string to have that shown instead of the default red dots.
# e.g. COMPLETION_WAITING_DOTS="%F{yellow}waiting...%f"
# Caution: this setting can cause issues with multiline prompts in zsh < 5.7.1 (see #5765)
# COMPLETION_WAITING_DOTS="true"
# Uncomment the following line if you want to disable marking untracked files
# under VCS as dirty. This makes repository status check for large repositories
# much, much faster.
# DISABLE_UNTRACKED_FILES_DIRTY="true"
# Uncomment the following line if you want to change the command execution time
# stamp shown in the history command output.
# You can set one of the optional three formats:
# "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd"
# or set a custom format using the strftime function format specifications,
# see 'man strftime' for details.
# HIST_STAMPS="mm/dd/yyyy"
# Would you like to use another custom folder than $ZSH/custom?
# ZSH_CUSTOM=/path/to/new-custom-folder
# Which plugins would you like to load?
# Standard plugins can be found in $ZSH/plugins/
# Custom plugins may be added to $ZSH_CUSTOM/plugins/
# Example format: plugins=(rails git textmate ruby lighthouse)
# Add wisely, as too many plugins slow down shell startup.
plugins=(git)
source $ZSH/oh-my-zsh.sh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
{{ if eq .chezmoi.hostname "NS51U" }}
alias checkupdates="aptitude search '~U'"
{{ else if eq .chezmoi.hostname "t450s" }}
alias hx="helix"
{{ end }}
if [ "$TERM" = "linux" ]; then
echo -en "\e]P01d2021" #black
echo -en "\e]P87c6f64" #darkgrey
echo -en "\e]P1cc241d" #darkred
echo -en "\e]P9fb4934" #red
echo -en "\e]P298971a" #darkgreen
echo -en "\e]PAb8bb26" #green
echo -en "\e]P3d79921" #brown
echo -en "\e]PBfabd2f" #yellow
echo -en "\e]P4458588" #darkblue
echo -en "\e]PC83a598" #blue
echo -en "\e]P5b16286" #darkmagenta
echo -en "\e]PDd3869b" #magenta
echo -en "\e]P6689d6a" #darkcyan
echo -en "\e]PE8ec97c" #cyan
echo -en "\e]P7a89984" #lightgrey
echo -en "\e]PFfbf1c7" #white
clear #for background artifacting
fi
{{ if eq .chezmoi.hostname "NS51U" }}
tere() {
local result=$(command tere "$@")
[ -n "$result" ] && cd -- "$result"
}
{{ else if eq .chezmoi.hostname "t450s" }}
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent.socket"
{{ end }}