I want to be able to change my colorsheme from a script. I have a file which I replace with the different color shemes (from this repo). Currently I have a "base" file with everything but the colors and I use bindsym $mod+Shift+c exec "cat ~/.config/i3/colors ~/.config/i3/base > ~/.config/i3/config && i3-msg reload" to build the "real" config from the two files. A much more elegant solution would be to source/import the "colors"-file in the config. Unfortunately I couldn't find anything related.
Is it possible to import variables in the i3 config from another file?
Since i3 v4.20, it is possible to include other configuration files from your i3 configuration.
https://i3wm.org/docs/userguide.html#include
As I can see in original docs (https://i3wm.org/docs/userguide.html#variables):
If you need a more dynamic configuration you should create a little script which generates a configuration file and run it before starting i3 (for example in your ~/.xsession file).
It's part about variables and any dynamic config for i3. So, your method is valid and any more elegant way is no in i3 by default.
Related
I've tried multiple ways in my config file to get chromium to open on $ws2 but it just keeps opening on $ws1 on startup.
First you have to find the WM_CLASS(STRING) from xprop. Open xprop and click on the target window you'll see the information about that window. Find WM_CLASS(STRING) second string(for i3wm) then goto the config file of i3 wm .config/i3/config and define the rule like this for_window [class="Chromium"] move to workspace $ws2 for_window [class="TelegramDesktop"] move to workspace $ws3
Here replace the class="String" with the string we found before with xprop.
Alternatively, follow the instructions in section 4.17 of the i3 User’s Guide and insert into your config file an assign declaration e.g. assign [class="Chromium"] $ws2. This will open the program directly on the specified workspace. For less well behaved programs like Spotify the for_window ... move to workspace ... method is required to move the program after it has opened, however.
To open a PROGRAM (chromium in your case) on a particular workspace during startup and return to your first workspace:
1: Add the following to your ~/.config/i3/config file.
exec --no-startup-id i3-msg 'workspace $ws2; exec PROGRAM; workspace $ws1'
1a: Substitute the name of the workspace you want to use for '$ws2' in the example.
1b: Substitute the name of the program to run(execute) with any options for PROGRAM. No quotes are needed for this section
1c: Substitute the name of the workspace you want to return to for '$ws1' in the example, or leave off "; workspace $ws1" to land in $ws2.
1d: Ensure you have the single quote mark where I included them in the example
2: Save the edit (I leave the editor open in case I have to change the file back after restart in place)
3: To test:
3a: Have i3 reread the config file (mod4+shift+c on my system)
3b: Restart i3 in place (mod4+shift+r on my system)
Note: I use $ws1 $ws2 etc in my config because once those are configured it made it easier for me to change titles and awesome icons in just one place vs many places. Method shamelessly stolen from i3 and others as is all of my linux knowledge. :-)
In a graphical DE, like KDE, what command can be used to add a new environment variable that can be used by any other process?
Note:
1) I'm aware of export A=B, but it only works for subsequent processes started in the same shell that executed the export, processes started else where, like a graphical application such as Chrome, won't be aware of the export.
2) I'm also aware that you can put it into ~/.bash_profile or alike, but that would need a restart/relogin for the setting to take effect.
Is there something like export but have effect for all applications and doesn't require a significant restart?
Your assumption that you need to restart after placing a variable definition (whether through an export statement or otherwise) in ~/.bash_profile, is flawed. You only need to source the file again after making modifications:
source ~/.bash_profile
or the more portable version:
. ~/.bash_profile
Either statement will (re)load any definitions in that file into your current shell. Sourcing is not the same as executing the script: it will modify the environment in the calling shell itself, not a subshell running the script.
A file like ~/.bash_profile may have many other definitions and settings in it that will mess with the shell. It is better to create a small (temporary) snippet with just the variables you want, and source that instead, as #JeremiahMegel suggests.
If you want to change the environment for a single process you run from the command line, you can set the variables on the same command line:
VAR=value /usr/bin/gedit
This will run gedit with the environment variable VAR set to value, but only for that one child process.
Unfortunately, your desktop applications are a bit more static than that. Most of the graphical applications you see in the menus are probably going to be represented by .desktop files in a folder like /usr/share/applications. These files are run in an environment that has almost none of the variables you are expecting. They rely on absolute paths, and most of the configuration is done by pointing the .desktop file to a script that performs its own setup. You can modify some of these files on an individual basis if you absolutely have to, but I would not recommend doing that. If you do insist on messing around with the graphical apps on your desktop, I would recommend making a copy of the desktop files you plan to modify in to ~/.local/share/applications, or whatever the equivalent is on your system. Those files will override anything found in /usr/share/applications and will only affect you.
When I edit any .coffee file in my mvim and try to save that file with any line longer than 80 symbols, I get such error.
file_name.coffee |18 error| Line exceeds maximum allowed length Length is 91, max is 80.
This is extremely annoying, especially taking into consideration that we have convention of max 100 symbols per line in our company and even code of other team members causes problems for me locally.
The only place where I can change this limit is in nodejs module in file .../node_modules/coffeelint/lib/coffeelint.js, which has such line:
max_line_length: {
value: 80,
-level: ERROR,
+level: IGNORE,
message: 'Line exceeds maximum allowed length'
},
But, of course, editing sources of nodejs libraries is not a good option.
In my mvim I use these dotfiles - https://github.com/skwp/dotfiles
In my project directory I have .coffeelint.json, but it does not work, however, it seems to contain needed and valid code for that (it works perfectly on TravisCI and on machines of other team members).
Questions:
Is there any place where I can turn off coffeelint call when saving file?
Is there any place where I can configure my coffelint max allowed line length?
Update:
Putting properly named (.coffeelint.json) config file into home directory helps, but is not proper solution in my case.
It seems it is more a coffeelint question than a Vim question.
From http://www.coffeelint.org/#options :
It seems you have to generate a configuration file, tweaking the following option.
max_line_length This rule imposes a maximum line length on your code.
Python's style guide does a good job explaining why you might want to
limit the length of your lines, though this is a matter of taste.
Lines can be no longer than eighty characters by default.
default level: error
It also seems you have to call coffeelint with your configuration file:
From : http://www.coffeelint.org/#usage
coffeelint -f coffeelint.json application.coffee
You probably have to find in your dotfile where the coffeelint invocation is done, and add the configuration file with the -f option there.
You don't have to pass the config file explicitly. Here are the user docs for CoffeeLint. You should either create a ~/coffeelint.json file or create a coffeelint.json in the root of your project.
In all project parts (5 different repos now) we currently have .coffeelint.json file, that is not the proper name for coffeelint, if you want it to pick config file automatically. Current .coffeelint.json is used on TravisCI when checking code and is invoked with -f option, as it turned out. So I my case I have two ways to fix weird behaviour (that is intended behaviour, actually):
Copy one of the configs from 5 related repos to ~/coffeelint.json, so that coffeelint will use it automatically when vim will check file on save (but this will not do if some repos will have different configs, however, this solution does not require any changes to repos).
Create copy of each config file in each repository (so I'll have both .coffeelint.json and coffeelint.json in each repo) and add the newly added one to .gitignore, so that team members will not see it in their editors. This option is also inappropriate and looks ugly, cause I have to add 5 changes and 5 commits.
It seems that guys from the team decided to name coffeelint config file not properly in order to hide it visually in code editors. Solution cost me nerves, so, probably, I'll reconfigure everything properly and will rename configs to default names.
It would be nice if coffeelint supported multiple config files with levels of priority, but this is not possible now.
Initially I used a makefile to deploy my application in linux.
I had various sed commands to replace variables like the PHP upload file size, post size, log file location etc.
Now I am shifting to ansible. I know I can copy the files, but how can I make changes to the conf files? Like if i just want to change the upload_filesize = 50M parameter. I don't want to make copies of the whole conf file and then replace with my file.
Sometimes it’s only a one-line change. Is there any better way to edit the config files in ansible?
If it's an INI file, then your specific requirements can be probably met by ini_file module (http://docs.ansible.com/ini_file_module.html).
If your change is limited just few lines (or eve one), then you can probably look at lineinfile module (http://docs.ansible.com/lineinfile_module.html).
Should you however need to change large number of settings, then it may be more beneficial to use template (http://docs.ansible.com/template_module.html) or assemble (http://docs.ansible.com/assemble_module.html). The main disadvantage of this approach is that you may need to review your template or fragments when updating your dependency.
Depending on the operating system, you can add files here /etc/php/apache2/conf.d/10-someinifilewithsetting.ini
I just want emacs to load another file as the configuration file, and ignore the default file ("~/.emacs").
Note that I don't want to change the original "~/.emacs" file.
I've tried to change "$HOME" env variable, but it doesn't work.
(Platform is Linux.)
emacs --no-init-file --load=some-other-config.el
Or with short options:
emacs -q -l some-other-config.el
From the Emacs manual, section 48.4:
Emacs looks for your init file using the filenames ‘~/.emacs’, ‘~/.emacs.el’, or ‘~/.emacs.d/init.el’ you can choose to use any one of these three names […].
If you really want to use another file, you should consider patching Emacs and making a custom build. It looks like lisp/startup.el:1009 is a good place to start.
As far as I can see, the only option is to use -u to indicate another user's init file.
As #Benjamin quoted, there are three filenames you can choose. As normally, we choose ~/.emacs.d/init.el to be loaded. That's because, we can simply add more configuration files in this directory and add them all under version control(Git). Be sure ~/.emacs and ~/.emacs.el removed before u choose to use the ~/.emacs.d/init.el.