Package: ohmyi3
Ohmyi3Ohmyi3 provides a dynamic template engine for your i3 configs providing variable
and conditional driven i3 settings.Ideal for those that use i3 on many of their systems and want to maintain a single
global repository that morphs to each computers environment based on hostname, user
and any other dynamic variable.FeaturesSingle~/.config/ohmyi3/config.pyto dynamic variables to i3 configsOne set of configs morphs based on your hostname, desktop environment or any variable you care to define.Uses python jinja2 templates to add variables and conditions to your i3 [or any] configsPlugins and hooks allow you to control all aspects of your system from a single configNot only can you template dynamic i3 configs, but you can also:Template alacritty, polybar, nitrogen, feh and anything else...its all python and jinja2, limitlessPowered byhttps://github.com/uvicore/frameworkInstallationInstall from Pypihttps://pypi.org/project/ohmyi3/withpippip install ohmyi3Initialize a fresh ohmyi3 config.  This creates a~/.config/ohmyi3and
populates it with a good set of defaults you can work with.i3ctl initModify the stock~/.config/ohmyi3/config.d/*i3 configs to suit your needs.
Add any*.conffile you want.  They are all picked up in alphabetical order.Thethemevariable picks the theme from~/.config/ohmyi3/themesfolder.
Bring your own themes.NOTICE:Review and modify stock~/.config/ohmyi3/config.pyconfiguration.  This is
just a stock example.DO NOT run it as is.You need to tune this to fit your
system.  All of the variables defined in that file will be available as jinja2
variables when templating i3 and the rest of your system.Pay special attention to theafter_generatehooks.  You will want to comment
those out and use them as needed.  To review the plugin code see the~/.config/ohmyi3/pluginsdirectory.  Plugins are very simple system
modification scripts.  Please review and write your own to suit your needs.Once you have tuned your variables, you can see the resulting dictionaryi3ctl infoIf you like all the variables, and haveused the plugins with cautionyou can now run the generator to template~/.config/ohmyi3/config.d/*i3 configs
which will output a new i3 file to~/.config/i3/config(it WILL save a backup
to that same folder before it overrides a new file)i3ctl generateExample CLI Output:: Generating new i3 config using ohmyi3 ::
   + Firing user defined before_generate hook
   * Backing up /home/mreschke/.config/i3/config to /home/mreschke/.config/i3/backup-2023-04-20_17-36-41
   - Appending /home/mreschke/.files/configs/i3/config.d/00-header.conf
   - Appending /home/mreschke/.files/configs/i3/config.d/05-system.conf
   - Appending /home/mreschke/.files/configs/i3/config.d/10-autostart.conf
   - Appending /home/mreschke/.files/configs/i3/config.d/15-borders.conf
   - Appending /home/mreschke/.files/configs/i3/config.d/20-navigation.conf
   - Appending /home/mreschke/.files/configs/i3/config.d/80-applications.conf
   - Appending /home/mreschke/.files/configs/i3/config.d/85-windows.conf
   - Appending /home/mreschke/.files/configs/i3/config.d/90-gaps.conf
   * Appending THEME pink
   * Copying /home/mreschke/.files/configs/i3/themes/i3status.conf to /home/mreschke/.config/i3status/config
   + Firing user defined after_generate hook
   > Plugin Nitrogen: nitrogen --save --set-zoom-fill /home/mreschke/Wallpaper/De/budgie.jpg > /dev/null 2>&1
   > Plugin Archey3: sed -i 's/archey3.*/archey3 -c magenta/g' ~/.zshrc
   > Plugin Archey3: sed -i 's/archey3.*/archey3 -c magenta/g' ~/.bashrc
   > Plugin Polybar: Templating /home/mreschke/.files/configs/polybar/qpanels/panel/deepin.j2.ini
   > Plugin Alacritty: Templating /home/mreschke/.files/configs/alacritty/alacritty.j2.yml

Done!
New /home/mreschke/.config/i3/config generated!
Please reload i3!Reload i3Most Basic ExampleIf your~/.config/ohmyi3/config.pylooked like this...defconfig():host=util.hostname()theme='archlinux'...And you had only a single file~/config/ohmyi3/config.d/01-test.conf# My dynamic i3 configYour hostname is{{host}}{%ifhost=='sunjaro'%}Add i3 configs specifically for{{host}}{%endif%}I love the{{theme}}themeAfter runningi3ctl generate, your final~/.config/i3/configwould look like this# My dynamic i3 config

Your hostname is sunjaro
Add i3 configs specifically for sunjaro
I love the archlinux themeSample the Power~/.config/ohmyi3/config.pyimportuvicorefromohmyi3importutilfromuvicore.typingimportDictfromuvicore.configurationimportenvfromuvicore.support.dumperimportdump,ddfromohmyi3.utilimportset,gather,path,plugin# Ohmyi3 user configuration.## This config is what drives the i3ctl generator.# All variables inside config() will be available to the jinja2 templating engine# and may be used in your config.d/* i3 configs for dynamic conditions.# Use the before_generate() and after_generate() hooks to fire off plugins/*# to control the rest of your system (set wallpaper, alacritty themes, polybar...)# From here on out, the power is in your hands.  Automation is now limitless!defconfig():"""Ohmyi3 variables for configuring and templating i3"""# Hostname and user from systemhost=util.hostname()user=util.loggedinuser()# Paths to all relevant locations# If you need to change the ohmyi3 path, use the# environment variable OHMYI3_PATH (default ~/.config/ohmyi3)ohmyi3_path=uvicore.config('ohmyi3.config_path')paths=set({'ohmyi3':path(ohmyi3_path),'ohmyi3_configd':path([ohmyi3_path,'config.d']),'ohmyi3_themes':path([ohmyi3_path,'themes']),'i3':path('~/.config/i3'),'i3status':path('~/.config/i3status'),'alacritty':path('~/.config/alacritty'),'polybar':path('~/.config/polybar'),})# Unix OS Variantos=set('manjaro',host,{'p14s':'lmde',})# Main network interfacenet_interface=set('enp11s0',host,{'p15':'enp11s0','p53':'wlp0s20f3','deajaro':'wlp2s0',})# Has battery (laptop?)has_battery=set(True,host,{'sunjaro':False,'p53':True,'p15':True,'p14s':True,})battery_device=set('BAT0')# Backlinghtbacklight_device=set('intel_backlight')# Desktop Environment (kde, xfce, i3, cinnamon, mate, gnome)# I like to run i3 inside kde and xfce etc...  If runing under these DE's# I need to tweak the configs (no screen lock, different autostarts etc...)desktop=set('i3',host,{'sunjaro':'kde','p53':'i3','p15':'i3',#'p14s': 'cinnamon',})# Main desktop tools (kde, xfce...)# Not the same as desktop, which is the running Desktop Environmentdesktop_tools=set('kde',host,{'deajaro':'xfce'})# Using i3 capable of gapsi3_gaps=set(True,host,{'p14s':False})# Restart i3 commandi3_restart=set('~/.files/scripts/i3ctl-dev generate && i3-msg restart',host,{'deajaro':'i3ctl generate && i3-msg restart','p14s':'/home/mreschke/.pyenv/shims/i3ctl generate && i3-msg restart',})# Wallpaper basewallpaper_base=set('~/Wallpaper',host,{'sunjaro':'~/Pictures/Wallpaper','p53':'~/Pictures/Wallpaper',})# Current theme (amber, archlinux, manjaro, pink)theme=set('manjaro',host,{'sunjaro':'manjaro','p53':'manjaro','p15':'amber','p14s':'manjaro',})# Extra theme details# Wallpaper is an OVERRIDE, else defaults to the themes folder/background.[jpg|png]themes=set({'amber':{'color':'#EF5B1A','archey3':'yellow',#'wallpaper': 'Abstract/cracked_orange.jpg',#'wallpaper': 'Manjaro/antelope-canyon-984055.jpg',#'wallpaper': 'Scenes/digital_sunset.jpg',#'wallpaper': 'LinuxMint/linuxmint-vera/mpiwnicki_red_dusk.jpg',#'wallpaper': 'LinuxMint/linuxmint-vanessa/navi_india.jpg',#'wallpaper': 'LinuxMint/linuxmint-una/nwatson_eclipse.jpg',#'wallpaper': 'LinuxMint/linuxmint-vera/navi_india.jpg',#'wallpaper': 'LinuxMint/linuxmint-ulyssa/tangerine_nanpu.jpg',#'wallpaper': 'Manjaro/sky-3189347.jpg',},'archlinux':{'color':'#1793D1','archey3':'blue',#'wallpaper': 'Archlinux/349880.jpg','wallpaper':'De/budgie.jpg',},'manjaro':{'color':'#106E5C','archey3':'green',#'wallpaper': 'Manjaro/illyria-default-lockscreen-nobrand.jpg',#'wallpaper': 'Manjaro/wpM_orbit2_textured.jpg''wallpaper':'De/deepin.jpg',},'pink':{'color':'#b41474','archey3':'magenta',#'wallpaper': 'Abstract/artistic_colors2.jpg',#'wallpaper': 'Landscape/backlit-chiemsee-dawn-1363876.jpg',#`'wallpaper': 'Manjaro/DigitalMilkyway.png',#'wallpaper': 'LinuxMint/linuxmint-una/eeselioglu_istanbul.jpg',#'wallpaper': 'Abstract/neon_huawei.jpg',#'wallpaper': 'De/budgie.jpg','wallpaper':'De/deepin.jpg',},},host,{#'p15': {'manjaro.wallpaper': 'Manjaro/wpM_orbit2_textured.jpg'}#'p53': {'manjaro.wallpaper': 'De/deepin.jpg!!!'}})# Polybar# Specific to the custom qpanel theme made from this https://github.com/adi1090x/polybar-themespolybar=set({'enabled':True,# blocks|colorblocks|cuts|docky|forest|grayblocks|hack|material# panels|pwidgets|qpanels|shades|shapes'theme':'qpanels',# budgie|deepin|elight|edark|gnomw|klight|kdark# liri|mint|ugnome|unity|xubuntu|zorin'subtheme':'deepin'},host,{'p14s':{'enabled':False},})# Rofirofi=set({'launcher':f'~/.config/polybar/{polybar.theme}/scripts/launcher.sh --{polybar.subtheme}','powermenu':f'~/.config/polybar/{polybar.theme}/scripts/powermenu.sh --{polybar.subtheme}',},host,{'p14s':{'launcher':'rofi -show drun'}})# Alacrittyalacritty=set({'font_size':'9.0',},host,{'p15':{'font_size':'8.0'}})# Default font for window titles (not bar.font)font=set('xft:URWGothic-Book 9')# Task traytasktray=set({'enabled':True,'position':'right',})# i3bar configs# All themes may obey these global bar configs, or they may set their ownbar=set({'enabled':False,#'cmd': 'i3bar','cmd':'i3bar --transparency','status_cmd':'i3status','position':'bottom','font':'xft:URWGothic-Book 8',# Hide or show the bar'mode':'dock',# dock|hide|invisible'hidden_state':'hide',# hide|show# Modifier makes the hidden bar show up while key is pressed'modifier':'none',#'modifier': 'Ctrl+$alt',},desktop!='i3',{'mode':'hide'},host,{'p15':{'position':'top'},'p14s':{'enabled':True},},)# Applications (not autostarts)# Preferred applications, could change depending on DE installedapps=set({# These are mostly common generic all Desktop Environments and Installed Desktop Tools'terminal':'alacritty','webbrowser':'firefox','webbrowser2':'chromium','dmenu':set(path('~/.files/scripts/dmenu-run-blue'),theme,{'manjaro':path('~/.files/scripts/dmenu-run-green')}),'htop':'htop','bashtop':'bashtop','codeeditor':'code','screenlock':'blurlock','powermanager':'xfce4-power-manager',# move to autostart'powermanagersettings':'xfce4-power-manager-settings','spotify':'spotify','networkeditor':'nm-connection-editor',},desktop_tools=='kde',{#'terminal': 'konsole','filemanager':'dolphin','calculator':'kcalc','settings':'systemsettings','taskmanager':'ksysguard','screenshot':'spectacle','colorpicker':'kcolorchooser','notepad':'kate',},desktop_tools=='xfce',{#'terminal': 'gnome-terminal','filemanager':'thunar','calculator':'galculator',# xcalc'settings':'xfce4-settings-manager','taskmanager':'xfce4-taskmanager','notepad':'mousepad',},desktop_tools=='gnome',{'filemanager':'nautilus',# ???'terminal':'gnome-terminal','calculator':'gnome-calculator',})# Autostarts#exec --no-startup-id blueman-applet#exec_always --no-startup-id sbxkb#exec --no-startup-id start_conky_maia#exec --no-startup-id start_conky_greenautostart=set({# These only fire up if we are in pure i3 mode (no other desktop environment+i3)'session':set(None,desktop=='i3'anddesktop_tools=='xfce','exec --no-startup-id xfsettingsd --replace'),'locker':set(None,desktop=='i3','exec_always --no-startup-id xss-lock -- blurlock'),#'locker':  set(None, desktop=='i3', 'exec_always --no-startup-id xss-lock -- i3lock --nofork --image ' + wallpaper_base + '/De/deepin.jpg'),'polkit':set(None,desktop=='i3','exec --no-startup-id /usr/lib/polkit-kde-authentication-agent-1'),'screen':set(None,desktop=='i3','exec --no-startup-id ~/.screenlayout/screen-laptop.sh'),'powerman':set(None,desktop=='i3','exec_always --no-startup-id '+apps.powermanager),# If using polybar in pure i3'bar':set(None,desktop=='i3'andpolybar.enabled,'exec_always --no-startup-id ~/.config/polybar/launch.sh --'+polybar.theme),# Threse always fire up, regardless of how i3 is used'wallpaper':'exec_always --no-startup-id nitrogen --restore','compositor':'exec_always --no-startup-id picom --config ~/.config/picom/picom.conf -b','keyboard':'exec_always --no-startup-id xset r rate 250 50',# Theme specific alttab'alttab':'exec_always --no-startup-id "alttab -w 1 -s 1 -bw 0 -fg\''+themes[theme].color+'\'-bg\'#0E2229\'-frame\''+themes[theme].color+'\'-t 128x150 -i 127x64"',},# If tasktray is enabled running in pure i3tasktray.enabledanddesktop=='i3',{'matray':set(None,os=='manjaro','exec --no-startup-id matray'),'clipman':set('exec --no-startup-id clipit --daemon'),'netman':set('exec --no-startup-id nm-applet'),'volume':set('exec --no-startup-id volumeicon'),},)# Volume Controlvolume=set({'up':'amixer -D pulse sset Master 5%+','down':'amixer -D pulse sset Master 5%-','mute':'amixer -D pulse set Master 1+ toggle',#'mixer': apps.terminal + ' -e alsamixer','mixer':'pavucontrol',})# Media Controlmedia=set({'play_pause':'playerctl play-pause','next':'playerctl next','previous':'playerctl previous',})# Brightness Controlbrightness=set({'up':'brightnessctl -q set 3%+','down':'brightnessctl --min-val=2 -q set 3%-',})# Dynamically Load and Instantiate Plugins# Pluging must be LAST after all variables are set_vars=gather(locals())plugins=set({'nitrogen':plugin('nitrogen.Nitrogen')(_vars),'archey3':plugin('archey3.Archey3')(_vars),'polybar':plugin('polybar.Polybar')(_vars),'alacritty':plugin('alacritty.Alacritty')(_vars),})# Return all variables to the ohmyi3 generator for templatingreturngather(locals())asyncdefbefore_generate(config):"""This hook fires before the new i3 config is generated"""# Kill some applications, as they don't re-autostart if already runningutil.shell('killall alttab')asyncdefafter_generate(config):"""This hook fires after the new i3 config is generated"""#dump('after hook')# REVIEW all these plugins.  They are very specific# For example, the polybar theme is specific to# https://github.com/adi1090x/polybar-themes style themes only and# is currently designed mostly for the "panels" variant.# Set themed wallpaper#config.plugins.nitrogen.set_wallpaper()# Set themed archey in my .zshrc and or .bashrc#config.plugins.archey3.set_archey()# Modify polybar theme files (template some variables)#config.plugins.polybar.adjust_polybar()# Template the alacritty config#config.plugins.alacritty.template_config()Example Info OutputAll variables defined in your~/.config/ohmyi3/config.pywill be available as
a niceSuperDictto the jinja2 templating engine and used to dynamically control
i3 (and anything else).Example output from the exampleconfig.pyabove on my host namedp15i3ctl info::Ohmyi3UserConfiguration::Dict({'host':'p15','user':'mreschke','ohmyi3_path':'~/.config/ohmyi3','paths':Dict({'ohmyi3':'/home/mreschke/.files/configs/i3','ohmyi3_configd':'/home/mreschke/.files/configs/i3/config.d','ohmyi3_themes':'/home/mreschke/.files/configs/i3/themes','i3':'/home/mreschke/.config/i3','i3status':'/home/mreschke/.config/i3status','alacritty':'/home/mreschke/.files/configs/alacritty','polybar':'/home/mreschke/.files/configs/polybar'}),'os':'manjaro','net_interface':'enp11s0','has_battery':True,'battery_device':'BAT0','backlight_device':'intel_backlight','desktop':'i3','desktop_tools':'kde','i3_gaps':True,'i3_restart':'~/.files/scripts/i3ctl-dev generate && i3-msg restart','wallpaper_base':'~/Wallpaper','theme':'amber','themes':Dict({'amber':Dict({'color':'#EF5B1A','archey3':'yellow'}),'archlinux':Dict({'color':'#1793D1','archey3':'blue','wallpaper':'De/budgie.jpg'}),'manjaro':Dict({'color':'#106E5C','archey3':'green','wallpaper':'De/deepin.jpg'}),'pink':Dict({'color':'#b41474','archey3':'magenta','wallpaper':'De/deepin.jpg'})}),'polybar':Dict({'enabled':True,'theme':'qpanels','subtheme':'deepin'}),'rofi':Dict({'launcher':'~/.config/polybar/qpanels/scripts/launcher.sh --deepin','powermenu':'~/.config/polybar/qpanels/scripts/powermenu.sh --deepin'}),'alacritty':Dict({'font_size':'8.0'}),'font':'xft:URWGothic-Book 9','tasktray':Dict({'enabled':True,'position':'right'}),'bar':Dict({'enabled':False,'cmd':'i3bar --transparency','status_cmd':'i3status','position':'top','font':'xft:URWGothic-Book 8','mode':'dock','hidden_state':'hide','modifier':'none'}),'apps':Dict({'terminal':'alacritty','webbrowser':'firefox','webbrowser2':'chromium','dmenu':'/home/mreschke/.files/scripts/dmenu-run-blue','htop':'htop','bashtop':'bashtop','codeeditor':'code','screenlock':'blurlock','powermanager':'xfce4-power-manager','powermanagersettings':'xfce4-power-manager-settings','spotify':'spotify','networkeditor':'nm-connection-editor','filemanager':'dolphin','calculator':'kcalc','settings':'systemsettings','taskmanager':'ksysguard','screenshot':'spectacle','colorpicker':'kcolorchooser','notepad':'kate'}),'autostart':Dict({'session':None,'locker':'exec_always --no-startup-id xss-lock -- blurlock','polkit':'exec --no-startup-id /usr/lib/polkit-kde-authentication-agent-1','screen':'exec --no-startup-id ~/.screenlayout/screen-laptop.sh','powerman':'exec_always --no-startup-id xfce4-power-manager','bar':'exec_always --no-startup-id ~/.config/polybar/launch.sh --qpanels','wallpaper':'exec_always --no-startup-id nitrogen --restore','compositor':'exec_always --no-startup-id picom --config ~/.config/picom/picom.conf -b','keyboard':'exec_always --no-startup-id xset r rate 250 50','alttab':"exec_always --no-startup-id\"alttab -w 1 -s 1 -bw 0 -fg '#EF5B1A' -bg '#0E2229' -frame '#EF5B1A' -t 128x150 ""-i 127x64\"",'matray':'exec --no-startup-id matray','clipman':'exec --no-startup-id clipit --daemon','netman':'exec --no-startup-id nm-applet','volume':'exec --no-startup-id volumeicon'}),'volume':Dict({'up':'amixer -D pulse sset Master 5%+','down':'amixer -D pulse sset Master 5%-','mute':'amixer -D pulse set Master 1+ toggle','mixer':'pavucontrol'}),'media':Dict({'play_pause':'playerctl play-pause','next':'playerctl next','previous':'playerctl previous'}),'brightness':Dict({'up':'brightnessctl -q set 3%+','down':'brightnessctl --min-val=2 -q set 3%-'}),'plugins':Dict({'nitrogen':<plugins.nitrogen.nitrogen.Nitrogenobjectat0x7f1b2ed359f0>,'archey3':<plugins.archey3.archey3.Archey3objectat0x7f1b2ed35960>,'polybar':<plugins.polybar.polybar.Polybarobjectat0x7f1b2ed35ae0>,'alacritty':<plugins.alacritty.alacritty.Alacrittyobjectat0x7f1b2ed35930>})})