diff --git a/stow_home/alacritty/.config/alacritty/alacritty.yml b/stow_home/alacritty/.config/alacritty/alacritty.yml new file mode 100644 index 0000000..eaceef7 --- /dev/null +++ b/stow_home/alacritty/.config/alacritty/alacritty.yml @@ -0,0 +1,480 @@ +# Configuration for Alacritty, the GPU enhanced terminal emulator. + +# Any items in the `env` entry below will be added as +# environment variables. Some entries may override variables +# set by alacritty itself. +env: + # TERM variable + # + # This value is used to set the `$TERM` environment variable for + # each instance of Alacritty. If it is not present, alacritty will + # check the local terminfo database and use `alacritty` if it is + # available, otherwise `xterm-256color` is used. + TERM: alacritty + + +window: + # Window dimensions (changes require restart) + # + # Specified in number of columns/lines, not pixels. + # If both are `0`, this setting is ignored. + #dimensions: + # columns: 0 + # lines: 0 + + # Window position (changes require restart) + # + # Specified in number of pixels. + # If the position is not set, the window manager will handle the placement. + #position: + # x: 0 + # y: 0 + + # Window padding (changes require restart) + # + # Blank space added around the window in pixels. This padding is scaled + # by DPI and the specified value is always added at both opposing sides. + padding: + x: 7 + y: 2 + + # Spread additional padding evenly around the terminal content. + #dynamic_padding: false + + # Window decorations + # + # Values for `decorations`: + # - full: Borders and title bar + # - none: Neither borders nor title bar + # + # Values for `decorations` (macOS only): + # - transparent: Title bar, transparent background and title bar buttons + # - buttonless: Title bar, transparent background, but no title bar buttons + #decorations: full + + # Startup Mode (changes require restart) + # + # Values for `startup_mode`: + # - Windowed + # - Maximized + # - Fullscreen + # + # Values for `startup_mode` (macOS only): + # - SimpleFullscreen + #startup_mode: Windowed + + # Window title + title: Alacritty + + # Window class (Linux/BSD only): + class: + # Application instance name + instance: Alacritty + # General application class + general: Alacritty + + # GTK theme variant (Linux/BSD only) + # + # Override the variant of the GTK theme. Commonly supported values are `dark` and `light`. + # Set this to `None` to use the default theme variant. + #gtk_theme_variant: None + +scrolling: + # Maximum number of lines in the scrollback buffer. + # Specifying '0' will disable scrolling. + history: 5000 + + # Number of lines the viewport will move for every line scrolled when + # scrollback is enabled (history > 0). + #multiplier: 3 + + # Scroll to the bottom when new text is written to the terminal. + #auto_scroll: false + +# Spaces per Tab (changes require restart) +# +# This setting defines the width of a tab in cells. +# +# Some applications, like Emacs, rely on knowing about the width of a tab. +# To prevent unexpected behavior in these applications, it's also required to +# change the `it` value in terminfo when altering this setting. +#tabspaces: 8 +# Font configuration +font: + normal: + family: BlexMono Nerd Font + bold: + family: BlexMono Nerd Font + italic: + family: BlexMono Nerd Font + bold_italic: + family: BlexMono Nerd Font + size: 8.0 + + offset: + x: 0 + y: 0 + + # Glyph offset determines the locations of the glyphs within their cells with + # the default being at the bottom. Increasing `x` moves the glyph to the right, + # increasing `y` moves the glyph upwards. + #glyph_offset: + # x: 0 + # y: 0 + +# If `true`, bold text is drawn using the bright color variants. +draw_bold_text_with_bright_colors: true +# ... + +# Nord color scheme +colors: + # Default colors + primary: + background: '0x282a36' + foreground: '0xf8f8f2' + + # Bright and dim foreground colors + # + # The dimmed foreground color is calculated automatically if it is not present. + # If the bright foreground color is not set, or `draw_bold_text_with_bright_colors` + # is `false`, the normal foreground color will be used. + + # Cursor colors + # Colors which should be used to draw the terminal cursor. If these are unset, + # the cursor color will be the inverse of the cell color. + cursor: + text: '0x44475a' + cursor: '0xf8f8f2' + +# Selection colors +# +# Colors which should be used to draw the selection area. If selection +# background is unset, selection color will be the inverse of the cell colors. +# If only text is unset the cell text color will remain the same. +# selection: +# text: '0xf8f8f2' +#background: '0x44475a' + +colors: + primary: + background: '#2e3440' + foreground: '#d8dee9' + dim_foreground: '#a5abb6' + cursor: + text: '#2e3440' + cursor: '#d8dee9' + vi_mode_cursor: + text: '#2e3440' + cursor: '#d8dee9' + selection: + text: CellForeground + background: '#4c566a' + search: + matches: + foreground: CellBackground + background: '#88c0d0' + bar: + background: '#434c5e' + foreground: '#d8dee9' + normal: + black: '#3b4252' + red: '#bf616a' + green: '#a3be8c' + yellow: '#ebcb8b' + blue: '#81a1c1' + magenta: '#b48ead' + cyan: '#88c0d0' + white: '#e5e9f0' + bright: + black: '#4c566a' + red: '#bf616a' + green: '#a3be8c' + yellow: '#ebcb8b' + blue: '#81a1c1' + magenta: '#b48ead' + cyan: '#8fbcbb' + white: '#eceff4' + dim: + black: '#373e4d' + red: '#94545d' + green: '#809575' + yellow: '#b29e75' + blue: '#68809a' + magenta: '#8c738c' + cyan: '#6d96a5' + white: '#aeb3bb' + # Indexed Colors + # + # The indexed colors include all colors from 16 to 256. + # When these are not set, they're filled with sensible defaults. + # + # Example: + # `- { index: 16, color: '0xff00ff' }` + # + indexed_colors: [] + +# Background opacity +# +# Window opacity as a floating point number from `0.0` to `1.0`. +# The value `0.0` is completely transparent and `1.0` is opaque. +#background_opacity: 1.0 +background_opacity: .9 + + +#selection: + #semantic_escape_chars: ",│`|:\"' ()[]{}<>\t" + + # When set to `true`, selected text will be copied to the primary clipboard. + #save_to_clipboard: false + +# Allow terminal applications to change Alacritty's window title. +#dynamic_title: true + +#cursor: + # Cursor style + # + # Values for `style`: + # - ▇ Block + # - _ Underline + # - | Beam + #style: Beam + + # If this is `true`, the cursor will be rendered as a hollow box when the + # window is not focused. + #unfocused_hollow: true + +# Live config reload (changes require restart) +#live_config_reload: true + +# Shell +# +# You can set `shell.program` to the path of your favorite shell, e.g. `/bin/fish`. +# Entries in `shell.args` are passed unmodified as arguments to the shell. +# +# Default: +# - (macOS) /bin/bash --login +# - (Linux/BSD) user login shell +# - (Windows) powershell +#shell: +# program: /bin/bash +# args: +# - --login + +# Startup directory +# +# Directory the shell is started in. If this is unset, or `None`, the working +# directory of the parent process will be used. +#working_directory: /home/joelchrono12 + +# WinPTY backend (Windows only) +# +# Alacritty defaults to using the newer ConPTY backend if it is available, +# since it resolves a lot of bugs and is quite a bit faster. If it is not +# available, the the WinPTY backend will be used instead. +# +# Setting this option to `true` makes Alacritty use the legacy WinPTY backend, +# even if the ConPTY backend is available. +#winpty_backend: false + +# Send ESC (\x1b) before characters when alt is pressed. +#alt_send_esc: true + +#debug: + # Display the time it takes to redraw each frame. + #render_timer: false + + # Keep the log file after quitting Alacritty. + #persistent_logging: false + + # Log level + # + # Values for `log_level`: + # - None + # - Error + # - Warn + # - Info + # - Debug + # - Trace + #log_level: Warn + + # Print all received window events. + #print_events: false + + # Record all characters and escape sequences as test data. + #ref_test: false + +#mouse: + # Click settings + # + # The `double_click` and `triple_click` settings control the time + # alacritty should wait for accepting multiple clicks as one double + # or triple click. + #double_click: { threshold: 300 } + #triple_click: { threshold: 300 } + + # If this is `true`, the cursor is temporarily hidden when typing. + #hide_when_typing: false + + #url: + # URL launcher + # + # This program is executed when clicking on a text which is recognized as a URL. + # The URL is always added to the command as the last parameter. + # + # When set to `None`, URL launching will be disabled completely. + # + # Default: + # - (macOS) open + # - (Linux/BSD) xdg-open + # - (Windows) explorer +# launcher: + # program: xdg-open + # args: [] + + # URL modifiers + # + # These are the modifiers that need to be held down for opening URLs when clicking + # on them. The available modifiers are documented in the key binding section. + #modifiers: None + +# Mouse bindings +# +# Mouse bindings are specified as a list of objects, much like the key +# bindings further below. +# +# Each mouse binding will specify a: +# +# - `mouse`: +# +# - Middle +# - Left +# - Right +# - Numeric identifier such as `5` +# +# - `action` (see key bindings) +# +# And optionally: +# +# - `mods` (see key bindings) +#mouse_bindings: +# - { mouse: Middle, action: PasteSelection } + +# Key bindings +# +# Key bindings are specified as a list of objects. For example, this is the +# default paste binding: +# +# `- { key: V, mods: Control|Shift, action: Paste }` +# +# Each key binding will specify a: +# +# - `key`: Identifier of the key pressed +# +# - A-Z +# - F1-F24 +# - Key0-Key9 +# +# A full list with available key codes can be found here: +# https://docs.rs/glutin/*/glutin/event/enum.VirtualKeyCode.html#variants +# +# Instead of using the name of the keys, the `key` field also supports using +# the scancode of the desired key. Scancodes have to be specified as a +# decimal number. This command will allow you to display the hex scancodes +# for certain keys: +# +# `showkey --scancodes`. +# +# Then exactly one of: +# +# - `chars`: Send a byte sequence to the running application +# +# The `chars` field writes the specified string to the terminal. This makes +# it possible to pass escape sequences. To find escape codes for bindings +# like `PageUp` (`"\x1b[5~"`), you can run the command `showkey -a` outside +# of tmux. Note that applications use terminfo to map escape sequences back +# to keys. It is therefore required to update the terminfo when changing an +# escape sequence. +# +# - `action`: Execute a predefined action +# +# - Copy +# - Paste +# - PasteSelection +# - IncreaseFontSize +# - DecreaseFontSize +# - ResetFontSize +# - ScrollPageUp +# - ScrollPageDown +# - ScrollLineUp +# - ScrollLineDown +# - ScrollToTop +# - ScrollToBottom +# - ClearHistory +# - Hide +# - Minimize +# - Quit +# - ToggleFullscreen +# - SpawnNewInstance +# - ClearLogNotice +# - ReceiveChar +# - None +# +# (macOS only): +# - ToggleSimpleFullscreen: Enters fullscreen without occupying another space +# +# - `command`: Fork and execute a specified command plus arguments +# +# The `command` field must be a map containing a `program` string and an +# `args` array of command line parameter strings. For example: +# `{ program: "alacritty", args: ["-e", "vttest"] }` +# +# And optionally: +# +# - `mods`: Key modifiers to filter binding actions +# +# - Command +# - Control +# - Option +# - Super +# - Shift +# - Alt +# +# Multiple `mods` can be combined using `|` like this: +# `mods: Control|Shift`. +# Whitespace and capitalization are relevant and must match the example. +# +# - `mode`: Indicate a binding for only specific terminal reported modes +# +# This is mainly used to send applications the correct escape sequences +# when in different modes. +# +# - AppCursor +# - AppKeypad +# - Alt +# +# A `~` operator can be used before a mode to apply the binding whenever +# the mode is *not* active, e.g. `~Alt`. +# +# Bindings are always filled by default, but will be replaced when a new +# binding with the same triggers is defined. To unset a default binding, it can +# be mapped to the `ReceiveChar` action. Alternatively, you can use `None` for +# a no-op if you do not wish to receive input characters for that binding. +key_bindings: + # (Windows, Linux, and BSD only) + - { key: V, mods: Control|Shift, action: Paste } + - { key: C, mods: Control|Shift, action: Copy } + - { key: Insert, mods: Shift, action: PasteSelection } + - { key: Key0, mods: Control, action: ResetFontSize } + - { key: Equals, mods: Control, action: IncreaseFontSize } + - { key: Plus, mods: Control, action: IncreaseFontSize } + - { key: Minus, mods: Control, action: DecreaseFontSize } + - { key: Minus, mods: Control, action: DecreaseFontSize } + + - { key: Paste, action: Paste } + - { key: Copy, action: Copy } + - { key: L, mods: Control, action: ClearLogNotice } + - { key: L, mods: Control, chars: "\x0c" } + - { key: PageUp, mods: Shift, action: ScrollPageUp, mode: ~Alt } + - { key: PageDown, mods: Shift, action: ScrollPageDown, mode: ~Alt } + - { key: Home, mods: Shift, action: ScrollToTop, mode: ~Alt } + - { key: End, mods: Shift, action: ScrollToBottom, mode: ~Alt } diff --git a/stow_home/awesome/.config/awesome/lain/.gitmodules b/stow_home/awesome/.config/awesome/lain/.gitmodules new file mode 100644 index 0000000..d95bcb5 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lain.wiki"] + path = wiki + url = https://github.com/lcpz/lain.wiki.git diff --git a/stow_home/awesome/.config/awesome/lain/ISSUE_TEMPLATE.md b/stow_home/awesome/.config/awesome/lain/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..e9dcc0b --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/ISSUE_TEMPLATE.md @@ -0,0 +1,33 @@ +# Please, read me! + +So that I can help you quickly and without having to redirect you here. + +# If you have an issue + +**Please read the [wiki](https://github.com/lcpz/lain/wiki) and search the [Issues section](https://github.com/lcpz/lain/issues) first.** + +If you can't find a solution there, then go ahead and provide: + +* output of `awesome -v` and `lua -v` +* expected behavior and actual behavior +* steps to reproduce the problem +* X error log + +# How to provide X error log + +There are two ways: + +* (Physically) Restart X like this: + ```shell + startx -- -keeptty -nolisten tcp > $HOME/.xorg.log 2>&1 + ``` + the error log will be output into `$HOME/.xorg.log`. + +* (Virtually) Use [Xephyr](https://wikipedia.org/wiki/Xephyr): + ```shell + # set screen size as you like + Xephyr :1 -screen 1280x800 2> stdout.txt & DISPLAY=:1 awesome + ``` + the error log will be output in the file `stdout.txt`. + +Before reporting, read the log and see if you can solve it yourself. diff --git a/stow_home/awesome/.config/awesome/lain/LICENSE b/stow_home/awesome/.config/awesome/lain/LICENSE new file mode 100644 index 0000000..23cb790 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/stow_home/awesome/.config/awesome/lain/README.rst b/stow_home/awesome/.config/awesome/lain/README.rst new file mode 100644 index 0000000..2b77f9a --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/README.rst @@ -0,0 +1,38 @@ +Lain +==== + +------------------------------------------------- +Layouts, widgets and utilities for Awesome WM 4.x +------------------------------------------------- + +:Author: Luca CPZ +:Version: git +:License: GNU-GPL2_ +:Source: https://github.com/lcpz/lain + +Description +----------- + +Successor of awesome-vain_, this module provides alternative layouts, asynchronous widgets and utility functions for Awesome_. + +Contributions +------------- + +Constructive criticism and suggestions are welcome. + +If you want to create a pull request, make sure that: + +- Your code fits with the general style of the module. In particular, you should use the same indentation pattern that the code uses, and also avoid adding space at the ends of lines. + +- Your code its easy to understand, maintainable, and modularized. You should also avoid code duplication wherever possible by adding functions to or using lain.helpers_. If something is unclear, or you can not write it in such a way that it will be clear, explain it with a comment. + +- You test your changes before submitting to make sure that you code works and does not break other parts of the module. + +- You update ``wiki`` submodule with a thorough section, if necessary. + +Contributed widgets have to be put in ``widget/contrib``. + +.. _GNU-GPL2: http://www.gnu.org/licenses/gpl-2.0.html +.. _awesome-vain: https://github.com/vain/awesome-vain +.. _Awesome: https://github.com/awesomeWM/awesome +.. _lain.helpers: https://github.com/lcpz/lain/blob/master/helpers.lua diff --git a/stow_home/awesome/.config/awesome/lain/helpers.lua b/stow_home/awesome/.config/awesome/lain/helpers.lua new file mode 100644 index 0000000..d6f6b3c --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/helpers.lua @@ -0,0 +1,204 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + +--]] + +local spawn = require("awful.spawn") +local timer = require("gears.timer") +local debug = require("debug") +local io = { lines = io.lines, + open = io.open } +local pairs = pairs +local rawget = rawget +local table = { sort = table.sort, unpack = table.unpack } +local unpack = unpack or table.unpack -- lua 5.1 retro-compatibility + +-- Lain helper functions for internal use +-- lain.helpers +local helpers = {} + +helpers.lain_dir = debug.getinfo(1, 'S').source:match[[^@(.*/).*$]] +helpers.icons_dir = helpers.lain_dir .. 'icons/' +helpers.scripts_dir = helpers.lain_dir .. 'scripts/' + +-- {{{ Modules loader + +function helpers.wrequire(table, key) + local module = rawget(table, key) + return module or require(table._NAME .. '.' .. key) +end + +-- }}} + +-- {{{ File operations + +-- check if the file exists and is readable +function helpers.file_exists(path) + local file = io.open(path, "rb") + if file then file:close() end + return file ~= nil +end + +-- get a table with all lines from a file +function helpers.lines_from(path) + local lines = {} + for line in io.lines(path) do + lines[#lines + 1] = line + end + return lines +end + +-- get a table with all lines from a file matching regexp +function helpers.lines_match(regexp, path) + local lines = {} + for line in io.lines(path) do + if string.match(line, regexp) then + lines[#lines + 1] = line + end + end + return lines +end + +-- get first line of a file +function helpers.first_line(path) + local file, first = io.open(path, "rb"), nil + if file then + first = file:read("*l") + file:close() + end + return first +end + +-- get first non empty line from a file +function helpers.first_nonempty_line(path) + for line in io.lines(path) do + if #line then return line end + end + return nil +end + +-- }}} + +-- {{{ Timer maker + +helpers.timer_table = {} + +function helpers.newtimer(name, timeout, fun, nostart, stoppable) + if not name or #name == 0 then return end + name = (stoppable and name) or timeout + if not helpers.timer_table[name] then + helpers.timer_table[name] = timer({ timeout = timeout }) + helpers.timer_table[name]:start() + end + helpers.timer_table[name]:connect_signal("timeout", fun) + if not nostart then + helpers.timer_table[name]:emit_signal("timeout") + end + return stoppable and helpers.timer_table[name] +end + +-- }}} + +-- {{{ Pipe operations + +-- run a command and execute a function on its output (asynchronous pipe) +-- @param cmd the input command +-- @param callback function to execute on cmd output +-- @return cmd PID +function helpers.async(cmd, callback) + return spawn.easy_async(cmd, + function (stdout, stderr, reason, exit_code) + callback(stdout, exit_code) + end) +end + +-- like above, but call spawn.easy_async with a shell +function helpers.async_with_shell(cmd, callback) + return spawn.easy_async_with_shell(cmd, + function (stdout, stderr, reason, exit_code) + callback(stdout, exit_code) + end) +end + +-- run a command and execute a function on its output line by line +function helpers.line_callback(cmd, callback) + return spawn.with_line_callback(cmd, { + stdout = function (line) + callback(line) + end, + }) +end + +-- }}} + +-- {{{ A map utility + +helpers.map_table = {} + +function helpers.set_map(element, value) + helpers.map_table[element] = value +end + +function helpers.get_map(element) + return helpers.map_table[element] +end + +-- }}} + +-- {{{ Misc + +-- check if an element exist on a table +function helpers.element_in_table(element, tbl) + for _, i in pairs(tbl) do + if i == element then + return true + end + end + return false +end + +-- iterate over table of records sorted by keys +function helpers.spairs(t) + -- collect the keys + local keys = {} + for k in pairs(t) do keys[#keys+1] = k end + + table.sort(keys) + + -- return the iterator function + local i = 0 + return function() + i = i + 1 + if keys[i] then + return keys[i], t[keys[i]] + end + end +end + +-- create the partition of singletons of a given set +-- example: the trivial partition set of {a, b, c}, is {{a}, {b}, {c}} +function helpers.trivial_partition_set(set) + local ss = {} + for _,e in pairs(set) do + ss[#ss+1] = {e} + end + return ss +end + +-- create the powerset of a given set +function helpers.powerset(s) + if not s then return {} end + local t = {{}} + for i = 1, #s do + for j = 1, #t do + t[#t+1] = {s[i],unpack(t[j])} + end + end + return t +end + +-- }}} + +return helpers diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/1.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/1.png new file mode 100644 index 0000000..d2fb62e Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/1.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/10.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/10.png new file mode 100644 index 0000000..507b079 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/10.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/11.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/11.png new file mode 100644 index 0000000..336141b Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/11.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/12.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/12.png new file mode 100644 index 0000000..c589729 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/12.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/13.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/13.png new file mode 100644 index 0000000..377518b Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/13.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/14.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/14.png new file mode 100644 index 0000000..6f4a9fe Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/14.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/15.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/15.png new file mode 100644 index 0000000..1a271c1 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/15.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/16.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/16.png new file mode 100644 index 0000000..5e65835 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/16.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/17.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/17.png new file mode 100644 index 0000000..f3fa0a9 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/17.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/18.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/18.png new file mode 100644 index 0000000..7acb37a Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/18.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/19.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/19.png new file mode 100644 index 0000000..a557957 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/19.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/2.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/2.png new file mode 100644 index 0000000..17b33e0 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/2.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/20.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/20.png new file mode 100644 index 0000000..558d111 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/20.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/21.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/21.png new file mode 100644 index 0000000..0bbedc8 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/21.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/22.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/22.png new file mode 100644 index 0000000..762d262 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/22.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/23.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/23.png new file mode 100644 index 0000000..a39dcee Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/23.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/24.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/24.png new file mode 100644 index 0000000..c00dbca Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/24.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/25.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/25.png new file mode 100644 index 0000000..dc9243c Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/25.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/26.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/26.png new file mode 100644 index 0000000..50bb182 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/26.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/27.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/27.png new file mode 100644 index 0000000..0fbf9fc Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/27.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/28.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/28.png new file mode 100644 index 0000000..def6ab2 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/28.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/29.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/29.png new file mode 100644 index 0000000..531923c Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/29.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/3.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/3.png new file mode 100644 index 0000000..98b552d Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/3.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/30.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/30.png new file mode 100644 index 0000000..ca58151 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/30.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/31.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/31.png new file mode 100644 index 0000000..6e8da21 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/31.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/4.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/4.png new file mode 100644 index 0000000..4335979 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/4.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/5.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/5.png new file mode 100644 index 0000000..576ec11 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/5.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/6.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/6.png new file mode 100644 index 0000000..56fa8ab Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/6.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/7.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/7.png new file mode 100644 index 0000000..7c90b3a Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/7.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/8.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/8.png new file mode 100644 index 0000000..9d1f28e Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/8.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/black/9.png b/stow_home/awesome/.config/awesome/lain/icons/cal/black/9.png new file mode 100644 index 0000000..00d0933 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/black/9.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/1.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/1.png new file mode 100644 index 0000000..a0faa20 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/1.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/10.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/10.png new file mode 100644 index 0000000..7d9343b Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/10.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/11.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/11.png new file mode 100644 index 0000000..7af5e99 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/11.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/12.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/12.png new file mode 100644 index 0000000..b164f85 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/12.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/13.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/13.png new file mode 100644 index 0000000..fef74f3 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/13.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/14.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/14.png new file mode 100644 index 0000000..d747a6b Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/14.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/15.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/15.png new file mode 100644 index 0000000..64418a6 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/15.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/16.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/16.png new file mode 100644 index 0000000..8b86700 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/16.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/17.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/17.png new file mode 100644 index 0000000..033b5ff Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/17.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/18.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/18.png new file mode 100644 index 0000000..0cf1c24 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/18.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/19.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/19.png new file mode 100644 index 0000000..bfd3530 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/19.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/2.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/2.png new file mode 100644 index 0000000..e7f3fa4 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/2.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/20.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/20.png new file mode 100644 index 0000000..9a5a1fb Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/20.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/21.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/21.png new file mode 100644 index 0000000..266ab9f Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/21.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/22.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/22.png new file mode 100644 index 0000000..f486289 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/22.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/23.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/23.png new file mode 100644 index 0000000..244dceb Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/23.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/24.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/24.png new file mode 100644 index 0000000..0ce1c75 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/24.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/25.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/25.png new file mode 100644 index 0000000..48d279c Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/25.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/26.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/26.png new file mode 100644 index 0000000..7535855 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/26.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/27.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/27.png new file mode 100644 index 0000000..2aa9074 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/27.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/28.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/28.png new file mode 100644 index 0000000..0201976 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/28.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/29.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/29.png new file mode 100644 index 0000000..9305b9b Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/29.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/3.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/3.png new file mode 100644 index 0000000..f1eb5de Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/3.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/30.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/30.png new file mode 100644 index 0000000..1ba61aa Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/30.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/31.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/31.png new file mode 100644 index 0000000..e9a873b Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/31.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/4.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/4.png new file mode 100644 index 0000000..ee1ed6a Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/4.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/5.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/5.png new file mode 100644 index 0000000..466aa71 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/5.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/6.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/6.png new file mode 100644 index 0000000..0a7bf4d Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/6.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/7.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/7.png new file mode 100644 index 0000000..e971951 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/7.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/8.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/8.png new file mode 100644 index 0000000..cb03d0b Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/8.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/cal/white/9.png b/stow_home/awesome/.config/awesome/lain/icons/cal/white/9.png new file mode 100644 index 0000000..fca554a Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/cal/white/9.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascade.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascade.png new file mode 100644 index 0000000..292a057 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascade.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascadetile.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascadetile.png new file mode 100644 index 0000000..ba30f43 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascadetile.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascadetilew.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascadetilew.png new file mode 100644 index 0000000..d15eb70 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascadetilew.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascadew.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascadew.png new file mode 100644 index 0000000..da64bd6 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/cascadew.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerfair.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerfair.png new file mode 100644 index 0000000..188c243 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerfair.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerfairw.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerfairw.png new file mode 100644 index 0000000..ed4bcf5 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerfairw.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerwork.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerwork.png new file mode 100644 index 0000000..51e06bc Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerwork.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerworkh.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerworkh.png new file mode 100644 index 0000000..c59092f Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerworkh.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerworkhw.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerworkhw.png new file mode 100644 index 0000000..7820f8c Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerworkhw.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerworkw.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerworkw.png new file mode 100644 index 0000000..85e6996 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/centerworkw.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/termfair.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/termfair.png new file mode 100644 index 0000000..06226c1 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/termfair.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/default/termfairw.png b/stow_home/awesome/.config/awesome/lain/icons/layout/default/termfairw.png new file mode 100644 index 0000000..0a8b576 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/default/termfairw.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/cascade.png b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/cascade.png new file mode 100644 index 0000000..fbe4fac Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/cascade.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/cascadetile.png b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/cascadetile.png new file mode 100644 index 0000000..2e03a80 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/cascadetile.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/centerfair.png b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/centerfair.png new file mode 100644 index 0000000..75dc993 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/centerfair.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/centerwork.png b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/centerwork.png new file mode 100644 index 0000000..af7a863 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/centerwork.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/centerworkh.png b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/centerworkh.png new file mode 100644 index 0000000..88019b3 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/centerworkh.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/termfair.png b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/termfair.png new file mode 100644 index 0000000..f7640b5 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/layout/zenburn/termfair.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/mail.png b/stow_home/awesome/.config/awesome/lain/icons/mail.png new file mode 100644 index 0000000..9c0c7a3 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/mail.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/no_net.png b/stow_home/awesome/.config/awesome/lain/icons/no_net.png new file mode 100644 index 0000000..3613372 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/no_net.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/01d.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/01d.png new file mode 100644 index 0000000..569965e Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/01d.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/01n.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/01n.png new file mode 100644 index 0000000..ce5b135 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/01n.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/02d.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/02d.png new file mode 100644 index 0000000..2ba9799 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/02d.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/02n.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/02n.png new file mode 100644 index 0000000..12e4283 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/02n.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/03d.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/03d.png new file mode 100644 index 0000000..1cf0e9d Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/03d.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/03n.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/03n.png new file mode 100644 index 0000000..89a42b8 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/03n.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/04d.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/04d.png new file mode 100644 index 0000000..e7fb67f Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/04d.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/04n.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/04n.png new file mode 120000 index 0000000..b9a83df --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/04n.png @@ -0,0 +1 @@ +04d.png \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/09d.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/09d.png new file mode 100644 index 0000000..cfa066a Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/09d.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/09n.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/09n.png new file mode 120000 index 0000000..cca1f5d --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/09n.png @@ -0,0 +1 @@ +09d.png \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/10d.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/10d.png new file mode 100644 index 0000000..712d0c8 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/10d.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/10n.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/10n.png new file mode 120000 index 0000000..6e01227 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/10n.png @@ -0,0 +1 @@ +10d.png \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/11d.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/11d.png new file mode 100644 index 0000000..3b62f7c Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/11d.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/11n.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/11n.png new file mode 120000 index 0000000..b227917 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/11n.png @@ -0,0 +1 @@ +11d.png \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/13d.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/13d.png new file mode 100644 index 0000000..e265b01 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/13d.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/13n.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/13n.png new file mode 120000 index 0000000..94e5a52 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/13n.png @@ -0,0 +1 @@ +13d.png \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/50d.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/50d.png new file mode 100644 index 0000000..905ace3 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/50d.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/50n.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/50n.png new file mode 120000 index 0000000..e3ba961 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/50n.png @@ -0,0 +1 @@ +50d.png \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/README.md b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/README.md new file mode 100644 index 0000000..f908fbd --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/README.md @@ -0,0 +1,3 @@ +[Plain Weather Icons](http://merlinthered.deviantart.com/art/plain-weather-icons-157162192), created by [MerlinTheRed](http://merlinthered.deviantart.com/). + + diff --git a/stow_home/awesome/.config/awesome/lain/icons/openweathermap/na.png b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/na.png new file mode 100644 index 0000000..1cc5132 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/openweathermap/na.png differ diff --git a/stow_home/awesome/.config/awesome/lain/icons/taskwarrior.png b/stow_home/awesome/.config/awesome/lain/icons/taskwarrior.png new file mode 100644 index 0000000..c64fe86 Binary files /dev/null and b/stow_home/awesome/.config/awesome/lain/icons/taskwarrior.png differ diff --git a/stow_home/awesome/.config/awesome/lain/init.lua b/stow_home/awesome/.config/awesome/lain/init.lua new file mode 100644 index 0000000..b59d5dd --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/init.lua @@ -0,0 +1,15 @@ +--[[ + + Lain + Layouts, widgets and utilities for Awesome WM + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + +--]] + +return { + layout = require("lain.layout"), + util = require("lain.util"), + widget = require("lain.widget") +} diff --git a/stow_home/awesome/.config/awesome/lain/lain-scm-1.rockspec b/stow_home/awesome/.config/awesome/lain/lain-scm-1.rockspec new file mode 100644 index 0000000..fb1eaaf --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/lain-scm-1.rockspec @@ -0,0 +1,27 @@ +package = "lain" +version = "scm-1" +source = { + url = "https://github.com/lcpz/lain", + tag = "scm-1`" +} +description = { + summary = "Layout, widgets and utilities for Awesome WM", + detailed = [[ + Successor of awesome-vain, this module provides alternative layouts, asynchronous widgets and utility functions for Awesome WM. + + Dependencies: curl (for IMAP, MPD and weather widgets); Glib >= 2.54 (for filesystems widget). + ]], + homepage = "https://github.com/lcpz/lain", + license = "GPL-2.0" +} +dependencies = { + "lua >= 5.1", + "awesome >= 4.0", + "Glib >= 2.54", + "curl" +} +supported_platforms = { "linux" } +build = { + type = "builtin", + modules = { lain = "init.lua" } +} diff --git a/stow_home/awesome/.config/awesome/lain/layout/cascade.lua b/stow_home/awesome/.config/awesome/lain/layout/cascade.lua new file mode 100644 index 0000000..cbc3877 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/layout/cascade.lua @@ -0,0 +1,172 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2014, projektile + * (c) 2013, Luca CPZ + * (c) 2010-2012, Peter Hofmann + +--]] + +local floor = math.floor +local screen = screen + +local cascade = { + name = "cascade", + nmaster = 0, + offset_x = 32, + offset_y = 8, + tile = { + name = "cascadetile", + nmaster = 0, + ncol = 0, + mwfact = 0, + offset_x = 5, + offset_y = 32, + extra_padding = 0 + } +} + +local function do_cascade(p, tiling) + local t = p.tag or screen[p.screen].selected_tag + local wa = p.workarea + local cls = p.clients + + if #cls == 0 then return end + + if not tiling then + -- Cascade windows. + + local num_c + if cascade.nmaster > 0 then + num_c = cascade.nmaster + else + num_c = t.master_count + end + + -- Opening a new window will usually force all existing windows to + -- get resized. This wastes a lot of CPU time. So let's set a lower + -- bound to "how_many": This wastes a little screen space but you'll + -- get a much better user experience. + local how_many = (#cls >= num_c and #cls) or num_c + + local current_offset_x = cascade.offset_x * (how_many - 1) + local current_offset_y = cascade.offset_y * (how_many - 1) + + -- Iterate. + for i = 1,#cls,1 do + local c = cls[i] + local g = {} + + g.x = wa.x + (how_many - i) * cascade.offset_x + g.y = wa.y + (i - 1) * cascade.offset_y + g.width = wa.width - current_offset_x + g.height = wa.height - current_offset_y + + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + + p.geometries[c] = g + end + else + -- Layout with one fixed column meant for a master window. Its + -- width is calculated according to mwfact. Other clients are + -- cascaded or "tabbed" in a slave column on the right. + + -- (1) (2) (3) (4) + -- +----------+---+ +----------+---+ +----------+---+ +----------+---+ + -- | | | | | 3 | | | 4 | | +---+| + -- | | | -> | | | -> | +---++ -> | +---+|+ + -- | 1 | 2 | | 1 +---++ | 1 | 3 || | 1 +---+|+| + -- | | | | | 2 || | +---++| | +---+|+ | + -- | | | | | || | | 2 | | | | 2 |+ | + -- +----------+---+ +---------+---++ +--------+---+-+ +------+---+---+ + + local mwfact + if cascade.tile.mwfact > 0 then + mwfact = cascade.tile.mwfact + else + mwfact = t.master_width_factor + end + + -- Make slave windows overlap main window? Do this if ncol is 1. + local overlap_main + if cascade.tile.ncol > 0 then + overlap_main = cascade.tile.ncol + else + overlap_main = t.column_count + end + + -- Minimum space for slave windows? See cascade.tile.lua. + local num_c + if cascade.tile.nmaster > 0 then + num_c = cascade.tile.nmaster + else + num_c = t.master_count + end + + local how_many = (#cls - 1 >= num_c and (#cls - 1)) or num_c + + local current_offset_x = cascade.tile.offset_x * (how_many - 1) + local current_offset_y = cascade.tile.offset_y * (how_many - 1) + + if #cls <= 0 then return end + + -- Main column, fixed width and height. + local c = cls[1] + local g = {} + -- Rounding is necessary to prevent the rendered size of slavewid + -- from being 1 pixel off when the result is not an integer. + local mainwid = floor(wa.width * mwfact) + local slavewid = wa.width - mainwid + + if overlap_main == 1 then + g.width = wa.width + + -- The size of the main window may be reduced a little bit. + -- This allows you to see if there are any windows below the + -- main window. + -- This only makes sense, though, if the main window is + -- overlapping everything else. + g.width = g.width - cascade.tile.extra_padding + else + g.width = mainwid + end + + g.height = wa.height + g.x = wa.x + g.y = wa.y + + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + + p.geometries[c] = g + + -- Remaining clients stacked in slave column, new ones on top. + if #cls <= 1 then return end + for i = 2,#cls do + c = cls[i] + g = {} + + g.width = slavewid - current_offset_x + g.height = wa.height - current_offset_y + + g.x = wa.x + mainwid + (how_many - (i - 1)) * cascade.tile.offset_x + g.y = wa.y + (i - 2) * cascade.tile.offset_y + + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + + p.geometries[c] = g + end + end +end + +function cascade.tile.arrange(p) + return do_cascade(p, true) +end + +function cascade.arrange(p) + return do_cascade(p, false) +end + +return cascade diff --git a/stow_home/awesome/.config/awesome/lain/layout/centerwork.lua b/stow_home/awesome/.config/awesome/lain/layout/centerwork.lua new file mode 100644 index 0000000..2b38a69 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/layout/centerwork.lua @@ -0,0 +1,194 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2018, Eugene Pakhomov + * (c) 2016, Henrik Antonsson + * (c) 2015, Joerg Jaspert + * (c) 2014, projektile + * (c) 2013, Luca CPZ + * (c) 2010-2012, Peter Hofmann + +--]] + +local floor, max, mouse, mousegrabber, screen = math.floor, math.max, mouse, mousegrabber, screen + +local centerwork = { + name = "centerwork", + horizontal = { name = "centerworkh" } +} + +local function arrange(p, layout) + local t = p.tag or screen[p.screen].selected_tag + local wa = p.workarea + local cls = p.clients + + if #cls == 0 then return end + + local c, g = cls[1], {} + + -- Main column, fixed width and height + local mwfact = t.master_width_factor + local mainhei = floor(wa.height * mwfact) + local mainwid = floor(wa.width * mwfact) + local slavewid = wa.width - mainwid + local slaveLwid = floor(slavewid / 2) + local slaveRwid = slavewid - slaveLwid + local slavehei = wa.height - mainhei + local slaveThei = floor(slavehei / 2) + local slaveBhei = slavehei - slaveThei + local nbrFirstSlaves = floor(#cls / 2) + local nbrSecondSlaves = floor((#cls - 1) / 2) + + local slaveFirstDim, slaveSecondDim = 0, 0 + + if layout.name == "centerwork" then -- vertical + if nbrFirstSlaves > 0 then slaveFirstDim = floor(wa.height / nbrFirstSlaves) end + if nbrSecondSlaves > 0 then slaveSecondDim = floor(wa.height / nbrSecondSlaves) end + + g.height = wa.height + g.width = mainwid + + g.x = wa.x + slaveLwid + g.y = wa.y + else -- horizontal + if nbrFirstSlaves > 0 then slaveFirstDim = floor(wa.width / nbrFirstSlaves) end + if nbrSecondSlaves > 0 then slaveSecondDim = floor(wa.width / nbrSecondSlaves) end + + g.height = mainhei + g.width = wa.width + + g.x = wa.x + g.y = wa.y + slaveThei + end + + g.width = max(g.width, 1) + g.height = max(g.height, 1) + + p.geometries[c] = g + + -- Auxiliary clients + if #cls <= 1 then return end + for i = 2, #cls do + local c, g = cls[i], {} + local idxChecker, dimToAssign + + local rowIndex = floor(i/2) + + if layout.name == "centerwork" then + if i % 2 == 0 then -- left slave + g.x = wa.x + g.y = wa.y + (rowIndex - 1) * slaveFirstDim + g.width = slaveLwid + + idxChecker, dimToAssign = nbrFirstSlaves, slaveFirstDim + else -- right slave + g.x = wa.x + slaveLwid + mainwid + g.y = wa.y + (rowIndex - 1) * slaveSecondDim + g.width = slaveRwid + + idxChecker, dimToAssign = nbrSecondSlaves, slaveSecondDim + end + + -- if last slave in row, use remaining space for it + if rowIndex == idxChecker then + g.height = wa.y + wa.height - g.y + else + g.height = dimToAssign + end + else + if i % 2 == 0 then -- top slave + g.x = wa.x + (rowIndex - 1) * slaveFirstDim + g.y = wa.y + g.height = slaveThei + + idxChecker, dimToAssign = nbrFirstSlaves, slaveFirstDim + else -- bottom slave + g.x = wa.x + (rowIndex - 1) * slaveSecondDim + g.y = wa.y + slaveThei + mainhei + g.height = slaveBhei + + idxChecker, dimToAssign = nbrSecondSlaves, slaveSecondDim + end + + -- if last slave in row, use remaining space for it + if rowIndex == idxChecker then + g.width = wa.x + wa.width - g.x + else + g.width = dimToAssign + end + end + + g.width = max(g.width, 1) + g.height = max(g.height, 1) + + p.geometries[c] = g + end +end + +local function mouse_resize_handler(c, corner, x, y, orientation) + local wa = c.screen.workarea + local mwfact = c.screen.selected_tag.master_width_factor + local g = c:geometry() + local offset = 0 + local cursor = "cross" + + local corner_coords + + if orientation == 'vertical' then + if g.height + 15 >= wa.height then + offset = g.height * .5 + cursor = "sb_h_double_arrow" + elseif not (g.y + g.height + 15 > wa.y + wa.height) then + offset = g.height + end + corner_coords = { x = wa.x + wa.width * (1 - mwfact) / 2, y = g.y + offset } + else + if g.width + 15 >= wa.width then + offset = g.width * .5 + cursor = "sb_v_double_arrow" + elseif not (g.x + g.width + 15 > wa.x + wa.width) then + offset = g.width + end + corner_coords = { y = wa.y + wa.height * (1 - mwfact) / 2, x = g.x + offset } + end + + mouse.coords(corner_coords) + + local prev_coords = {} + + mousegrabber.run(function(_mouse) + if not c.valid then return false end + for _, v in ipairs(_mouse.buttons) do + if v then + prev_coords = { x = _mouse.x, y = _mouse.y } + local new_mwfact + if orientation == 'vertical' then + new_mwfact = 1 - (_mouse.x - wa.x) / wa.width * 2 + else + new_mwfact = 1 - (_mouse.y - wa.y) / wa.height * 2 + end + c.screen.selected_tag.master_width_factor = math.min(math.max(new_mwfact, 0.01), 0.99) + return true + end + end + return prev_coords.x == _mouse.x and prev_coords.y == _mouse.y + end, cursor) +end + +function centerwork.arrange(p) + return arrange(p, centerwork) +end + +function centerwork.horizontal.arrange(p) + return arrange(p, centerwork.horizontal) +end + +function centerwork.mouse_resize_handler(c, corner, x, y) + return mouse_resize_handler(c, corner, x, y, 'vertical') +end + +function centerwork.horizontal.mouse_resize_handler(c, corner, x, y) + return mouse_resize_handler(c, corner, x, y, 'horizontal') +end + +return centerwork diff --git a/stow_home/awesome/.config/awesome/lain/layout/init.lua b/stow_home/awesome/.config/awesome/lain/layout/init.lua new file mode 100644 index 0000000..6478b06 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/layout/init.lua @@ -0,0 +1,19 @@ +--[[ + + Lain + Layouts, widgets and utilities for Awesome WM + + Layouts section + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2010-2012, Peter Hofmann + +--]] + +local wrequire = require("lain.helpers").wrequire +local setmetatable = setmetatable + +local layout = { _NAME = "lain.layout" } + +return setmetatable(layout, { __index = wrequire }) diff --git a/stow_home/awesome/.config/awesome/lain/layout/termfair.lua b/stow_home/awesome/.config/awesome/lain/layout/termfair.lua new file mode 100644 index 0000000..e33894e --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/layout/termfair.lua @@ -0,0 +1,237 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2014, projektile + * (c) 2013, Luca CPZ + * (c) 2010, Nicolas Estibals + * (c) 2010-2012, Peter Hofmann + +--]] + +local math = math +local screen = screen +local tonumber = tonumber + +local termfair = { name = "termfair" } +termfair.center = { name = "centerfair" } + +local function do_fair(p, orientation) + local t = p.tag or screen[p.screen].selected_tag + local wa = p.workarea + local cls = p.clients + + if #cls == 0 then return end + + if orientation == "west" then + -- Layout with fixed number of vertical columns (read from nmaster). + -- New windows align from left to right. When a row is full, a now + -- one above it is created. Like this: + + -- (1) (2) (3) + -- +---+---+---+ +---+---+---+ +---+---+---+ + -- | | | | | | | | | | | | + -- | 1 | | | -> | 2 | 1 | | -> | 3 | 2 | 1 | -> + -- | | | | | | | | | | | | + -- +---+---+---+ +---+---+---+ +---+---+---+ + + -- (4) (5) (6) + -- +---+---+---+ +---+---+---+ +---+---+---+ + -- | 4 | | | | 5 | 4 | | | 6 | 5 | 4 | + -- +---+---+---+ -> +---+---+---+ -> +---+---+---+ + -- | 3 | 2 | 1 | | 3 | 2 | 1 | | 3 | 2 | 1 | + -- +---+---+---+ +---+---+---+ +---+---+---+ + + -- How many vertical columns? Read from nmaster on the tag. + local num_x = tonumber(termfair.nmaster) or t.master_count + local ncol = tonumber(termfair.ncol) or t.column_count + + if num_x <= 2 then num_x = 2 end + if ncol <= 1 then ncol = 1 end + local width = math.floor(wa.width/num_x) + + local num_y = math.max(math.ceil(#cls / num_x), ncol) + local height = math.floor(wa.height/num_y) + local cur_num_x = num_x + local at_x = 0 + local at_y = 0 + + local remaining_clients = #cls + + -- We start the first row. Left-align by limiting the number of + -- available slots. + if remaining_clients < num_x then + cur_num_x = remaining_clients + end + + -- Iterate in reversed order. + for i = #cls,1,-1 do + -- Get x and y position. + local c = cls[i] + local this_x = cur_num_x - at_x - 1 + local this_y = num_y - at_y - 1 + + -- Calculate geometry. + local g = {} + if this_x == (num_x - 1) then + g.width = wa.width - (num_x - 1)*width + else + g.width = width + end + + if this_y == (num_y - 1) then + g.height = wa.height - (num_y - 1)*height + else + g.height = height + end + + g.x = wa.x + this_x*width + g.y = wa.y + this_y*height + + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + + p.geometries[c] = g + + remaining_clients = remaining_clients - 1 + + -- Next grid position. + at_x = at_x + 1 + if at_x == num_x then + -- Row full, create a new one above it. + at_x = 0 + at_y = at_y + 1 + + -- We start a new row. Left-align. + if remaining_clients < num_x then + cur_num_x = remaining_clients + end + end + end + elseif orientation == "center" then + -- Layout with fixed number of vertical columns (read from nmaster). + -- Cols are centerded until there is nmaster columns, then windows + -- are stacked in the slave columns, with at most ncol clients per + -- column if possible. + + -- with nmaster=3 and ncol=1 you'll have + -- (1) (2) (3) + -- +---+---+---+ +-+---+---+-+ +---+---+---+ + -- | | | | | | | | | | | | | + -- | | 1 | | -> | | 1 | 2 | | -> | 1 | 2 | 3 | -> + -- | | | | | | | | | | | | | + -- +---+---+---+ +-+---+---+-+ +---+---+---+ + + -- (4) (5) + -- +---+---+---+ +---+---+---+ + -- | | | 3 | | | 2 | 4 | + -- + 1 + 2 +---+ -> + 1 +---+---+ + -- | | | 4 | | | 3 | 5 | + -- +---+---+---+ +---+---+---+ + + -- How many vertical columns? Read from nmaster on the tag. + local num_x = tonumber(termfair.center.nmaster) or t.master_count + local ncol = tonumber(termfair.center.ncol) or t.column_count + + if num_x <= 2 then num_x = 2 end + if ncol <= 1 then ncol = 1 end + + local width = math.floor(wa.width / num_x) + + if #cls < num_x then + -- Less clients than the number of columns, let's center it! + local offset_x = wa.x + (wa.width - #cls*width) / 2 + for i = 1, #cls do + local g = { y = wa.y } + g.width = width + g.height = wa.height + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + g.x = offset_x + (i - 1) * width + p.geometries[cls[i]] = g + end + else + -- More clients than the number of columns, let's arrange it! + -- Master client deserves a special treatement + local g = {} + g.width = wa.width - (num_x - 1)*width + g.height = wa.height + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + g.x = wa.x + g.y = wa.y + p.geometries[cls[1]] = g + + -- Treat the other clients + + -- Compute distribution of clients among columns + local num_y = {} + local remaining_clients = #cls-1 + local ncol_min = math.ceil(remaining_clients/(num_x-1)) + + if ncol >= ncol_min then + for i = (num_x-1), 1, -1 do + if (remaining_clients-i+1) < ncol then + num_y[i] = remaining_clients-i + 1 + else + num_y[i] = ncol + end + remaining_clients = remaining_clients - num_y[i] + end + else + local rem = remaining_clients % (num_x-1) + if rem == 0 then + for i = 1, num_x-1 do + num_y[i] = ncol_min + end + else + for i = 1, num_x-1 do + num_y[i] = ncol_min - 1 + end + for i = 0, rem-1 do + num_y[num_x-1-i] = num_y[num_x-1-i] + 1 + end + end + end + + -- Compute geometry of the other clients + local nclient = 2 -- we start with the 2nd client + local wx = g.x + g.width + for i = 1, (num_x-1) do + local height = math.floor(wa.height / num_y[i]) + local wy = wa.y + for j = 0, (num_y[i]-2) do + local g = {} + g.x = wx + g.y = wy + g.height = height + g.width = width + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + p.geometries[cls[nclient]] = g + nclient = nclient + 1 + wy = wy + height + end + local g = {} + g.x = wx + g.y = wy + g.height = wa.height - (num_y[i] - 1)*height + g.width = width + if g.width < 1 then g.width = 1 end + if g.height < 1 then g.height = 1 end + p.geometries[cls[nclient]] = g + nclient = nclient + 1 + wx = wx + width + end + end + end +end + +function termfair.center.arrange(p) + return do_fair(p, "center") +end + +function termfair.arrange(p) + return do_fair(p, "west") +end + +return termfair diff --git a/stow_home/awesome/.config/awesome/lain/util/dkjson.lua b/stow_home/awesome/.config/awesome/lain/util/dkjson.lua new file mode 100644 index 0000000..89aa2e1 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/util/dkjson.lua @@ -0,0 +1,713 @@ +-- Module options: +local always_try_using_lpeg = true +local register_global_module_table = false +local global_module_name = 'json' + +--[==[ + +David Kolf's JSON module for Lua 5.1/5.2 + +Version 2.5 + + +For the documentation see the corresponding readme.txt or visit +. + +You can contact the author by sending an e-mail to 'david' at the +domain 'dkolf.de'. + + +Copyright (C) 2010-2013 David Heiko Kolf + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS +BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--]==] + +-- global dependencies: +local pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset = + pairs, type, tostring, tonumber, getmetatable, setmetatable, rawset +local error, require, pcall, select = error, require, pcall, select +local floor, huge = math.floor, math.huge +local strrep, gsub, strsub, strbyte, strchar, strfind, strlen, strformat = + string.rep, string.gsub, string.sub, string.byte, string.char, + string.find, string.len, string.format +local strmatch = string.match +local concat = table.concat + +local json = { version = "dkjson 2.5" } + +if register_global_module_table then + _G[global_module_name] = json +end + +local _ENV = nil -- blocking globals in Lua 5.2 + +pcall (function() + -- Enable access to blocked metatables. + -- Don't worry, this module doesn't change anything in them. + local debmeta = require "debug".getmetatable + if debmeta then getmetatable = debmeta end +end) + +json.null = setmetatable ({}, { + __tojson = function () return "null" end +}) + +local function isarray (tbl) + local max, n, arraylen = 0, 0, 0 + for k,v in pairs (tbl) do + if k == 'n' and type(v) == 'number' then + arraylen = v + if v > max then + max = v + end + else + if type(k) ~= 'number' or k < 1 or floor(k) ~= k then + return false + end + if k > max then + max = k + end + n = n + 1 + end + end + if max > 10 and max > arraylen and max > n * 2 then + return false -- don't create an array with too many holes + end + return true, max +end + +local escapecodes = { + ["\""] = "\\\"", ["\\"] = "\\\\", ["\b"] = "\\b", ["\f"] = "\\f", + ["\n"] = "\\n", ["\r"] = "\\r", ["\t"] = "\\t" +} + +local function escapeutf8 (uchar) + local value = escapecodes[uchar] + if value then + return value + end + local a, b, c, d = strbyte (uchar, 1, 4) + a, b, c, d = a or 0, b or 0, c or 0, d or 0 + if a <= 0x7f then + value = a + elseif 0xc0 <= a and a <= 0xdf and b >= 0x80 then + value = (a - 0xc0) * 0x40 + b - 0x80 + elseif 0xe0 <= a and a <= 0xef and b >= 0x80 and c >= 0x80 then + value = ((a - 0xe0) * 0x40 + b - 0x80) * 0x40 + c - 0x80 + elseif 0xf0 <= a and a <= 0xf7 and b >= 0x80 and c >= 0x80 and d >= 0x80 then + value = (((a - 0xf0) * 0x40 + b - 0x80) * 0x40 + c - 0x80) * 0x40 + d - 0x80 + else + return "" + end + if value <= 0xffff then + return strformat ("\\u%.4x", value) + elseif value <= 0x10ffff then + -- encode as UTF-16 surrogate pair + value = value - 0x10000 + local highsur, lowsur = 0xD800 + floor (value/0x400), 0xDC00 + (value % 0x400) + return strformat ("\\u%.4x\\u%.4x", highsur, lowsur) + else + return "" + end +end + +local function fsub (str, pattern, repl) + -- gsub always builds a new string in a buffer, even when no match + -- exists. First using find should be more efficient when most strings + -- don't contain the pattern. + if strfind (str, pattern) then + return gsub (str, pattern, repl) + else + return str + end +end + +local function quotestring (value) + -- based on the regexp "escapable" in https://github.com/douglascrockford/JSON-js + value = fsub (value, "[%z\1-\31\"\\\127]", escapeutf8) + if strfind (value, "[\194\216\220\225\226\239]") then + value = fsub (value, "\194[\128-\159\173]", escapeutf8) + value = fsub (value, "\216[\128-\132]", escapeutf8) + value = fsub (value, "\220\143", escapeutf8) + value = fsub (value, "\225\158[\180\181]", escapeutf8) + value = fsub (value, "\226\128[\140-\143\168-\175]", escapeutf8) + value = fsub (value, "\226\129[\160-\175]", escapeutf8) + value = fsub (value, "\239\187\191", escapeutf8) + value = fsub (value, "\239\191[\176-\191]", escapeutf8) + end + return "\"" .. value .. "\"" +end +json.quotestring = quotestring + +local function replace(str, o, n) + local i, j = strfind (str, o, 1, true) + if i then + return strsub(str, 1, i-1) .. n .. strsub(str, j+1, -1) + else + return str + end +end + +-- locale independent num2str and str2num functions +local decpoint, numfilter + +local function updatedecpoint () + decpoint = strmatch(tostring(0.5), "([^05+])") + -- build a filter that can be used to remove group separators + numfilter = "[^0-9%-%+eE" .. gsub(decpoint, "[%^%$%(%)%%%.%[%]%*%+%-%?]", "%%%0") .. "]+" +end + +updatedecpoint() + +local function num2str (num) + return replace(fsub(tostring(num), numfilter, ""), decpoint, ".") +end + +local function str2num (str) + local num = tonumber(replace(str, ".", decpoint)) + if not num then + updatedecpoint() + num = tonumber(replace(str, ".", decpoint)) + end + return num +end + +local function addnewline2 (level, buffer, buflen) + buffer[buflen+1] = "\n" + buffer[buflen+2] = strrep (" ", level) + buflen = buflen + 2 + return buflen +end + +function json.addnewline (state) + if state.indent then + state.bufferlen = addnewline2 (state.level or 0, + state.buffer, state.bufferlen or #(state.buffer)) + end +end + +local encode2 -- forward declaration + +local function addpair (key, value, prev, indent, level, buffer, buflen, tables, globalorder, state) + local kt = type (key) + if kt ~= 'string' and kt ~= 'number' then + return nil, "type '" .. kt .. "' is not supported as a key by JSON." + end + if prev then + buflen = buflen + 1 + buffer[buflen] = "," + end + if indent then + buflen = addnewline2 (level, buffer, buflen) + end + buffer[buflen+1] = quotestring (key) + buffer[buflen+2] = ":" + return encode2 (value, indent, level, buffer, buflen + 2, tables, globalorder, state) +end + +local function appendcustom(res, buffer, state) + local buflen = state.bufferlen + if type (res) == 'string' then + buflen = buflen + 1 + buffer[buflen] = res + end + return buflen +end + +local function exception(reason, value, state, buffer, buflen, defaultmessage) + defaultmessage = defaultmessage or reason + local handler = state.exception + if not handler then + return nil, defaultmessage + else + state.bufferlen = buflen + local ret, msg = handler (reason, value, state, defaultmessage) + if not ret then return nil, msg or defaultmessage end + return appendcustom(ret, buffer, state) + end +end + +function json.encodeexception(reason, value, state, defaultmessage) + return quotestring("<" .. defaultmessage .. ">") +end + +encode2 = function (value, indent, level, buffer, buflen, tables, globalorder, state) + local valtype = type (value) + local valmeta = getmetatable (value) + valmeta = type (valmeta) == 'table' and valmeta -- only tables + local valtojson = valmeta and valmeta.__tojson + if valtojson then + if tables[value] then + return exception('reference cycle', value, state, buffer, buflen) + end + tables[value] = true + state.bufferlen = buflen + local ret, msg = valtojson (value, state) + if not ret then return exception('custom encoder failed', value, state, buffer, buflen, msg) end + tables[value] = nil + buflen = appendcustom(ret, buffer, state) + elseif value == nil then + buflen = buflen + 1 + buffer[buflen] = "null" + elseif valtype == 'number' then + local s + if value ~= value or value >= huge or -value >= huge then + -- This is the behaviour of the original JSON implementation. + s = "null" + else + s = num2str (value) + end + buflen = buflen + 1 + buffer[buflen] = s + elseif valtype == 'boolean' then + buflen = buflen + 1 + buffer[buflen] = value and "true" or "false" + elseif valtype == 'string' then + buflen = buflen + 1 + buffer[buflen] = quotestring (value) + elseif valtype == 'table' then + if tables[value] then + return exception('reference cycle', value, state, buffer, buflen) + end + tables[value] = true + level = level + 1 + local isa, n = isarray (value) + if n == 0 and valmeta and valmeta.__jsontype == 'object' then + isa = false + end + local msg + if isa then -- JSON array + buflen = buflen + 1 + buffer[buflen] = "[" + for i = 1, n do + buflen, msg = encode2 (value[i], indent, level, buffer, buflen, tables, globalorder, state) + if not buflen then return nil, msg end + if i < n then + buflen = buflen + 1 + buffer[buflen] = "," + end + end + buflen = buflen + 1 + buffer[buflen] = "]" + else -- JSON object + local prev = false + buflen = buflen + 1 + buffer[buflen] = "{" + local order = valmeta and valmeta.__jsonorder or globalorder + if order then + local used = {} + n = #order + for i = 1, n do + local k = order[i] + local v = value[k] + if v then + used[k] = true + buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state) + prev = true -- add a seperator before the next element + end + end + for k,v in pairs (value) do + if not used[k] then + buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state) + if not buflen then return nil, msg end + prev = true -- add a seperator before the next element + end + end + else -- unordered + for k,v in pairs (value) do + buflen, msg = addpair (k, v, prev, indent, level, buffer, buflen, tables, globalorder, state) + if not buflen then return nil, msg end + prev = true -- add a seperator before the next element + end + end + if indent then + buflen = addnewline2 (level - 1, buffer, buflen) + end + buflen = buflen + 1 + buffer[buflen] = "}" + end + tables[value] = nil + else + return exception ('unsupported type', value, state, buffer, buflen, + "type '" .. valtype .. "' is not supported by JSON.") + end + return buflen +end + +function json.encode (value, state) + state = state or {} + local oldbuffer = state.buffer + local buffer = oldbuffer or {} + state.buffer = buffer + updatedecpoint() + local ret, msg = encode2 (value, state.indent, state.level or 0, + buffer, state.bufferlen or 0, state.tables or {}, state.keyorder, state) + if not ret then + error (msg, 2) + elseif oldbuffer == buffer then + state.bufferlen = ret + return true + else + state.bufferlen = nil + state.buffer = nil + return concat (buffer) + end +end + +local function loc (str, where) + local line, pos, linepos = 1, 1, 0 + while true do + pos = strfind (str, "\n", pos, true) + if pos and pos < where then + line = line + 1 + linepos = pos + pos = pos + 1 + else + break + end + end + return "line " .. line .. ", column " .. (where - linepos) +end + +local function unterminated (str, what, where) + return nil, strlen (str) + 1, "unterminated " .. what .. " at " .. loc (str, where) +end + +local function scanwhite (str, pos) + while true do + pos = strfind (str, "%S", pos) + if not pos then return nil end + local sub2 = strsub (str, pos, pos + 1) + if sub2 == "\239\187" and strsub (str, pos + 2, pos + 2) == "\191" then + -- UTF-8 Byte Order Mark + pos = pos + 3 + elseif sub2 == "//" then + pos = strfind (str, "[\n\r]", pos + 2) + if not pos then return nil end + elseif sub2 == "/*" then + pos = strfind (str, "*/", pos + 2) + if not pos then return nil end + pos = pos + 2 + else + return pos + end + end +end + +local escapechars = { + ["\""] = "\"", ["\\"] = "\\", ["/"] = "/", ["b"] = "\b", ["f"] = "\f", + ["n"] = "\n", ["r"] = "\r", ["t"] = "\t" +} + +local function unichar (value) + if value < 0 then + return nil + elseif value <= 0x007f then + return strchar (value) + elseif value <= 0x07ff then + return strchar (0xc0 + floor(value/0x40), + 0x80 + (floor(value) % 0x40)) + elseif value <= 0xffff then + return strchar (0xe0 + floor(value/0x1000), + 0x80 + (floor(value/0x40) % 0x40), + 0x80 + (floor(value) % 0x40)) + elseif value <= 0x10ffff then + return strchar (0xf0 + floor(value/0x40000), + 0x80 + (floor(value/0x1000) % 0x40), + 0x80 + (floor(value/0x40) % 0x40), + 0x80 + (floor(value) % 0x40)) + else + return nil + end +end + +local function scanstring (str, pos) + local lastpos = pos + 1 + local buffer, n = {}, 0 + while true do + local nextpos = strfind (str, "[\"\\]", lastpos) + if not nextpos then + return unterminated (str, "string", pos) + end + if nextpos > lastpos then + n = n + 1 + buffer[n] = strsub (str, lastpos, nextpos - 1) + end + if strsub (str, nextpos, nextpos) == "\"" then + lastpos = nextpos + 1 + break + else + local escchar = strsub (str, nextpos + 1, nextpos + 1) + local value + if escchar == "u" then + value = tonumber (strsub (str, nextpos + 2, nextpos + 5), 16) + if value then + local value2 + if 0xD800 <= value and value <= 0xDBff then + -- we have the high surrogate of UTF-16. Check if there is a + -- low surrogate escaped nearby to combine them. + if strsub (str, nextpos + 6, nextpos + 7) == "\\u" then + value2 = tonumber (strsub (str, nextpos + 8, nextpos + 11), 16) + if value2 and 0xDC00 <= value2 and value2 <= 0xDFFF then + value = (value - 0xD800) * 0x400 + (value2 - 0xDC00) + 0x10000 + else + value2 = nil -- in case it was out of range for a low surrogate + end + end + end + value = value and unichar (value) + if value then + if value2 then + lastpos = nextpos + 12 + else + lastpos = nextpos + 6 + end + end + end + end + if not value then + value = escapechars[escchar] or escchar + lastpos = nextpos + 2 + end + n = n + 1 + buffer[n] = value + end + end + if n == 1 then + return buffer[1], lastpos + elseif n > 1 then + return concat (buffer), lastpos + else + return "", lastpos + end +end + +local scanvalue -- forward declaration + +local function scantable (what, closechar, str, startpos, nullval, objectmeta, arraymeta) + local len = strlen (str) + local tbl, n = {}, 0 + local pos = startpos + 1 + if what == 'object' then + setmetatable (tbl, objectmeta) + else + setmetatable (tbl, arraymeta) + end + while true do + pos = scanwhite (str, pos) + if not pos then return unterminated (str, what, startpos) end + local char = strsub (str, pos, pos) + if char == closechar then + return tbl, pos + 1 + end + local val1, err + val1, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta) + if err then return nil, pos, err end + pos = scanwhite (str, pos) + if not pos then return unterminated (str, what, startpos) end + char = strsub (str, pos, pos) + if char == ":" then + if val1 == nil then + return nil, pos, "cannot use nil as table index (at " .. loc (str, pos) .. ")" + end + pos = scanwhite (str, pos + 1) + if not pos then return unterminated (str, what, startpos) end + local val2 + val2, pos, err = scanvalue (str, pos, nullval, objectmeta, arraymeta) + if err then return nil, pos, err end + tbl[val1] = val2 + pos = scanwhite (str, pos) + if not pos then return unterminated (str, what, startpos) end + char = strsub (str, pos, pos) + else + n = n + 1 + tbl[n] = val1 + end + if char == "," then + pos = pos + 1 + end + end +end + +scanvalue = function (str, pos, nullval, objectmeta, arraymeta) + pos = pos or 1 + pos = scanwhite (str, pos) + if not pos then + return nil, strlen (str) + 1, "no valid JSON value (reached the end)" + end + local char = strsub (str, pos, pos) + if char == "{" then + return scantable ('object', "}", str, pos, nullval, objectmeta, arraymeta) + elseif char == "[" then + return scantable ('array', "]", str, pos, nullval, objectmeta, arraymeta) + elseif char == "\"" then + return scanstring (str, pos) + else + local pstart, pend = strfind (str, "^%-?[%d%.]+[eE]?[%+%-]?%d*", pos) + if pstart then + local number = str2num (strsub (str, pstart, pend)) + if number then + return number, pend + 1 + end + end + pstart, pend = strfind (str, "^%a%w*", pos) + if pstart then + local name = strsub (str, pstart, pend) + if name == "true" then + return true, pend + 1 + elseif name == "false" then + return false, pend + 1 + elseif name == "null" then + return nullval, pend + 1 + end + end + return nil, pos, "no valid JSON value at " .. loc (str, pos) + end +end + +local function optionalmetatables(...) + if select("#", ...) > 0 then + return ... + else + return {__jsontype = 'object'}, {__jsontype = 'array'} + end +end + +function json.decode (str, pos, nullval, ...) + local objectmeta, arraymeta = optionalmetatables(...) + return scanvalue (str, pos, nullval, objectmeta, arraymeta) +end + +function json.use_lpeg () + local g = require ("lpeg") + + if g.version() == "0.11" then + error "due to a bug in LPeg 0.11, it cannot be used for JSON matching" + end + + local pegmatch = g.match + local P, S, R = g.P, g.S, g.R + + local function ErrorCall (str, pos, msg, state) + if not state.msg then + state.msg = msg .. " at " .. loc (str, pos) + state.pos = pos + end + return false + end + + local function Err (msg) + return g.Cmt (g.Cc (msg) * g.Carg (2), ErrorCall) + end + + local SingleLineComment = P"//" * (1 - S"\n\r")^0 + local MultiLineComment = P"/*" * (1 - P"*/")^0 * P"*/" + local Space = (S" \n\r\t" + P"\239\187\191" + SingleLineComment + MultiLineComment)^0 + + local PlainChar = 1 - S"\"\\\n\r" + local EscapeSequence = (P"\\" * g.C (S"\"\\/bfnrt" + Err "unsupported escape sequence")) / escapechars + local HexDigit = R("09", "af", "AF") + local function UTF16Surrogate (match, pos, high, low) + high, low = tonumber (high, 16), tonumber (low, 16) + if 0xD800 <= high and high <= 0xDBff and 0xDC00 <= low and low <= 0xDFFF then + return true, unichar ((high - 0xD800) * 0x400 + (low - 0xDC00) + 0x10000) + else + return false + end + end + local function UTF16BMP (hex) + return unichar (tonumber (hex, 16)) + end + local U16Sequence = (P"\\u" * g.C (HexDigit * HexDigit * HexDigit * HexDigit)) + local UnicodeEscape = g.Cmt (U16Sequence * U16Sequence, UTF16Surrogate) + U16Sequence/UTF16BMP + local Char = UnicodeEscape + EscapeSequence + PlainChar + local String = P"\"" * g.Cs (Char ^ 0) * (P"\"" + Err "unterminated string") + local Integer = P"-"^(-1) * (P"0" + (R"19" * R"09"^0)) + local Fractal = P"." * R"09"^0 + local Exponent = (S"eE") * (S"+-")^(-1) * R"09"^1 + local Number = (Integer * Fractal^(-1) * Exponent^(-1))/str2num + local Constant = P"true" * g.Cc (true) + P"false" * g.Cc (false) + P"null" * g.Carg (1) + local SimpleValue = Number + String + Constant + local ArrayContent, ObjectContent + + -- The functions parsearray and parseobject parse only a single value/pair + -- at a time and store them directly to avoid hitting the LPeg limits. + local function parsearray (str, pos, nullval, state) + local obj, cont + local npos + local t, nt = {}, 0 + repeat + obj, cont, npos = pegmatch (ArrayContent, str, pos, nullval, state) + if not npos then break end + pos = npos + nt = nt + 1 + t[nt] = obj + until cont == 'last' + return pos, setmetatable (t, state.arraymeta) + end + + local function parseobject (str, pos, nullval, state) + local obj, key, cont + local npos + local t = {} + repeat + key, obj, cont, npos = pegmatch (ObjectContent, str, pos, nullval, state) + if not npos then break end + pos = npos + t[key] = obj + until cont == 'last' + return pos, setmetatable (t, state.objectmeta) + end + + local Array = P"[" * g.Cmt (g.Carg(1) * g.Carg(2), parsearray) * Space * (P"]" + Err "']' expected") + local Object = P"{" * g.Cmt (g.Carg(1) * g.Carg(2), parseobject) * Space * (P"}" + Err "'}' expected") + local Value = Space * (Array + Object + SimpleValue) + local ExpectedValue = Value + Space * Err "value expected" + ArrayContent = Value * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp() + local Pair = g.Cg (Space * String * Space * (P":" + Err "colon expected") * ExpectedValue) + ObjectContent = Pair * Space * (P"," * g.Cc'cont' + g.Cc'last') * g.Cp() + local DecodeValue = ExpectedValue * g.Cp () + + function json.decode (str, pos, nullval, ...) + local state = {} + state.objectmeta, state.arraymeta = optionalmetatables(...) + local obj, retpos = pegmatch (DecodeValue, str, pos, nullval, state) + if state.msg then + return nil, state.pos, state.msg + else + return obj, retpos + end + end + + -- use this function only once: + json.use_lpeg = function () return json end + + json.using_lpeg = true + + return json -- so you can get the module using json = require "dkjson".use_lpeg() +end + +if always_try_using_lpeg then + pcall (json.use_lpeg) +end + +return json diff --git a/stow_home/awesome/.config/awesome/lain/util/init.lua b/stow_home/awesome/.config/awesome/lain/util/init.lua new file mode 100644 index 0000000..55bfa26 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/util/init.lua @@ -0,0 +1,168 @@ +--[[ + + Lain + Layouts, widgets and utilities for Awesome WM + + Utilities section + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2010-2012, Peter Hofmann + +--]] + +local awful = require("awful") +local sqrt = math.sqrt +local pairs = pairs +local client = client +local tonumber = tonumber +local wrequire = require("lain.helpers").wrequire +local setmetatable = setmetatable + +-- Lain utilities submodule +-- lain.util +local util = { _NAME = "lain.util" } + +-- Like awful.menu.clients, but only show clients of currently selected tags +function util.menu_clients_current_tags(menu, args) + -- List of currently selected tags. + local cls_tags = awful.screen.focused().selected_tags + + if cls_tags == nil then return nil end + + -- Final list of menu items. + local cls_t = {} + + -- For each selected tag get all clients of that tag and add them to + -- the menu. A click on a menu item will raise that client. + for i = 1,#cls_tags do + local t = cls_tags[i] + local cls = t:clients() + + for k, c in pairs(cls) do + cls_t[#cls_t + 1] = { awful.util.escape(c.name) or "", + function () + c.minimized = false + client.focus = c + c:raise() + end, + c.icon } + end + end + + -- No clients? Then quit. + if #cls_t <= 0 then return nil end + + -- menu may contain some predefined values, otherwise start with a + -- fresh menu. + if not menu then menu = {} end + + -- Set the list of items and show the menu. + menu.items = cls_t + local m = awful.menu(menu) + m:show(args) + + return m +end + +-- Magnify a client: set it to "float" and resize it. +function util.magnify_client(c, width_f, height_f) + if c and not c.floating then + util.magnified_client = c + util.mc(c, width_f, height_f) + else + util.magnified_client = nil + c.floating = false + end +end + +-- https://github.com/lcpz/lain/issues/195 +function util.mc(c, width_f, height_f) + c = c or util.magnified_client + if not c then return end + + c.floating = true + local s = awful.screen.focused() + local mg = s.workarea + local g = {} + local mwfact = width_f or s.selected_tag.master_width_factor or 0.5 + g.width = sqrt(mwfact) * mg.width + g.height = sqrt(height_f or mwfact) * mg.height + g.x = mg.x + (mg.width - g.width) / 2 + g.y = mg.y + (mg.height - g.height) / 2 + + if c then c:geometry(g) end -- if c is still a valid object +end + +-- Non-empty tag browsing +-- direction in {-1, 1} <-> {previous, next} non-empty tag +function util.tag_view_nonempty(direction, sc) + local s = sc or awful.screen.focused() + + for i = 1, #s.tags do + awful.tag.viewidx(direction, s) + if #s.clients > 0 then + return + end + end +end + +-- {{{ Dynamic tagging + +-- Add a new tag +function util.add_tag(layout) + awful.prompt.run { + prompt = "New tag name: ", + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = function(name) + if not name or #name == 0 then return end + awful.tag.add(name, { screen = awful.screen.focused(), layout = layout or awful.layout.suit.tile }):view_only() + end + } +end + +-- Rename current tag +function util.rename_tag() + awful.prompt.run { + prompt = "Rename tag: ", + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = function(new_name) + if not new_name or #new_name == 0 then return end + local t = awful.screen.focused().selected_tag + if t then + t.name = new_name + end + end + } +end + +-- Move current tag +-- pos in {-1, 1} <-> {previous, next} tag position +function util.move_tag(pos) + local tag = awful.screen.focused().selected_tag + if tonumber(pos) <= -1 then + awful.tag.move(tag.index - 1, tag) + else + awful.tag.move(tag.index + 1, tag) + end +end + +-- Delete current tag +-- Any rule set on the tag shall be broken +function util.delete_tag() + local t = awful.screen.focused().selected_tag + if not t then return end + t:delete() +end + +-- }}} + +-- On the fly useless gaps change +function util.useless_gaps_resize(thatmuch, s, t) + local scr = s or awful.screen.focused() + local tag = t or scr.selected_tag + tag.gap = tag.gap + tonumber(thatmuch) + awful.layout.arrange(scr) +end + +return setmetatable(util, { __index = wrequire }) diff --git a/stow_home/awesome/.config/awesome/lain/util/markup.lua b/stow_home/awesome/.config/awesome/lain/util/markup.lua new file mode 100644 index 0000000..63f9486 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/util/markup.lua @@ -0,0 +1,66 @@ +--[[ + + Licensed under MIT License + * (c) 2013, Luca CPZ + * (c) 2009, Uli Schlachter + * (c) 2009, Majic + +--]] + +local format = string.format +local setmetatable = setmetatable + +-- Lain markup util submodule +-- lain.util.markup +local markup = { fg = {}, bg = {} } + +-- Convenience tags +function markup.bold(text) return format("%s", text) end +function markup.italic(text) return format("%s", text) end +function markup.strike(text) return format("%s", text) end +function markup.underline(text) return format("%s", text) end +function markup.monospace(text) return format("%s", text) end +function markup.big(text) return format("%s", text) end +function markup.small(text) return format("%s", text) end + +-- Set the font +function markup.font(font, text) + return format("%s", font, text) +end + +-- Set the foreground +function markup.fg.color(color, text) + return format("%s", color, text) +end + +-- Set the background +function markup.bg.color(color, text) + return format("%s", color, text) +end + +-- Set foreground and background +function markup.color(fg, bg, text) + return format("%s", fg, bg, text) +end + +-- Set font and foreground +function markup.fontfg(font, fg, text) + return format("%s", font, fg, text) +end + +-- Set font and background +function markup.fontbg(font, bg, text) + return format("%s", font, bg, text) +end + +-- Set font, foreground and background +function markup.fontcolor(font, fg, bg, text) + return format("%s", font, fg, bg, text) +end + +-- link markup.{fg,bg}(...) calls to markup.{fg,bg}.color(...) +setmetatable(markup.fg, { __call = function(_, ...) return markup.fg.color(...) end }) +setmetatable(markup.bg, { __call = function(_, ...) return markup.bg.color(...) end }) + +-- link markup(...) calls to markup.fg.color(...) +return setmetatable(markup, { __call = function(_, ...) return markup.fg.color(...) end }) diff --git a/stow_home/awesome/.config/awesome/lain/util/menu_iterator.lua b/stow_home/awesome/.config/awesome/lain/util/menu_iterator.lua new file mode 100644 index 0000000..9959b25 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/util/menu_iterator.lua @@ -0,0 +1,145 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2017, Simon Désaulniers + * (c) 2017, Uli Schlachter + * (c) 2017, Jeferson Siqueira + +--]] + +-- Menu iterator with Naughty notifications +-- lain.util.menu_iterator + +local naughty = require("naughty") +local helpers = require("lain.helpers") +local util = require("lain.util") +local atable = require("awful.util").table +local assert = assert +local pairs = pairs +local tconcat = table.concat +local unpack = unpack or table.unpack -- lua 5.1 retro-compatibility + +local state = { cid = nil } + +local function naughty_destroy_callback(reason) + local closed = naughty.notificationClosedReason + if reason == closed.expired or reason == closed.dismissedByUser then + local actions = state.index and state.menu[state.index - 1][2] + if actions then + for _,action in pairs(actions) do + -- don't try to call nil callbacks + if action then action() end + end + state.index = nil + end + end +end + +-- Iterates over a menu. +-- After the timeout, callbacks associated to the last visited choice are +-- executed. Inputs: +-- * menu: a list of {label, {callbacks}} pairs +-- * timeout: time to wait before confirming the menu selection +-- * icon: icon to display in the notification of the chosen label +local function iterate(menu, timeout, icon) + local timeout = timeout or 4 -- default timeout for each menu entry + local icon = icon or nil -- icon to display on the menu + + -- Build the list of choices + if not state.index then + state.menu = menu + state.index = 1 + end + + -- Select one and display the appropriate notification + local label + local next = state.menu[state.index] + state.index = state.index + 1 + + if not next then + label = "Cancel" + state.index = nil + else + label, _ = unpack(next) + end + + state.cid = naughty.notify({ + text = label, + icon = icon, + timeout = timeout, + screen = mouse.screen, + replaces_id = state.cid, + destroy = naughty_destroy_callback + }).id +end + +-- Generates a menu compatible with the first argument of `iterate` function and +-- suitable for the following cases: +-- * all possible choices individually (partition of singletons); +-- * all possible subsets of the set of choices (powerset). +-- +-- Inputs: +-- * args: an array containing the following members: +-- * choices: Array of choices (string) on which the menu will be +-- generated. +-- * name: Displayed name of the menu (in the form "name: choices"). +-- * selected_cb: Callback to execute for each selected choice. Takes +-- the choice as a string argument. Can be `nil` (no action +-- to execute). +-- * rejected_cb: Callback to execute for each rejected choice (possible +-- choices which are not selected). Takes the choice as a +-- string argument. Can be `nil` (no action to execute). +-- * extra_choices: An array of extra { choice_str, callback_fun } pairs to be +-- added to the menu. Each callback_fun can be `nil`. +-- * combination: The combination of choices to generate. Possible values: +-- "powerset" and "single" (default). +-- Output: +-- * m: menu to be iterated over. +local function menu(args) + local choices = assert(args.choices or args[1]) + local name = assert(args.name or args[2]) + local selected_cb = args.selected_cb + local rejected_cb = args.rejected_cb + local extra_choices = args.extra_choices or {} + + local ch_combinations = args.combination == "powerset" and helpers.powerset(choices) or helpers.trivial_partition_set(choices) + + for _,c in pairs(extra_choices) do + ch_combinations = atable.join(ch_combinations, {{c[1]}}) + end + + local m = {} -- the menu + + for _,c in pairs(ch_combinations) do + if #c > 0 then + local cbs = {} + + -- selected choices + for _,ch in pairs(c) do + if atable.hasitem(choices, ch) then + cbs[#cbs + 1] = selected_cb and function() selected_cb(ch) end or nil + end + end + + -- rejected choices + for _,ch in pairs(choices) do + if not atable.hasitem(c, ch) and atable.hasitem(choices, ch) then + cbs[#cbs + 1] = rejected_cb and function() rejected_cb(ch) end or nil + end + end + + -- add user extra choices (like the choice "None" for example) + for _,x in pairs(extra_choices) do + if x[1] == c[1] then + cbs[#cbs + 1] = x[2] + end + end + + m[#m + 1] = { name .. ": " .. tconcat(c, " + "), cbs } + end + end + + return m +end + +return { iterate = iterate, menu = menu } diff --git a/stow_home/awesome/.config/awesome/lain/util/quake.lua b/stow_home/awesome/.config/awesome/lain/util/quake.lua new file mode 100644 index 0000000..01891b0 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/util/quake.lua @@ -0,0 +1,168 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2016, Luca CPZ + * (c) 2015, unknown + +--]] + +local awful = require("awful") +local capi = { client = client } +local math = math +local string = string +local pairs = pairs +local screen = screen +local setmetatable = setmetatable + +-- Quake-like Dropdown application spawn +local quake = {} + +-- If you have a rule like "awful.client.setslave" for your terminals, +-- ensure you use an exception for QuakeDD. Otherwise, you may +-- run into problems with focus. + +function quake:display() + if self.followtag then self.screen = awful.screen.focused() end + + -- First, we locate the client + local client = nil + local i = 0 + for c in awful.client.iterate(function (c) + -- c.name may be changed! + return c.instance == self.name + end) + do + i = i + 1 + if i == 1 then + client = c + else + -- Additional matching clients, let's remove the sticky bit + -- which may persist between awesome restarts. We don't close + -- them as they may be valuable. They will just turn into + -- normal clients. + c.sticky = false + c.ontop = false + c.above = false + end + end + + if not client and not self.visible then return end + + if not client then + -- The client does not exist, we spawn it + cmd = string.format("%s %s %s", self.app, + string.format(self.argname, self.name), self.extra) + awful.spawn(cmd, { tag = self.screen.selected_tag }) + return + end + + -- Set geometry + client.floating = true + client.border_width = self.border + client.size_hints_honor = false + client:geometry(self.geometry[self.screen.index] or self:compute_size()) + + -- Set not sticky and on top + client.sticky = false + client.ontop = true + client.above = true + client.skip_taskbar = true + + -- Additional user settings + if self.settings then self.settings(client) end + + -- Toggle display + if self.visible then + client.hidden = false + client:raise() + self.last_tag = self.screen.selected_tag + client:tags({self.screen.selected_tag}) + capi.client.focus = client + else + client.hidden = true + local ctags = client:tags() + for i, t in pairs(ctags) do + ctags[i] = nil + end + client:tags(ctags) + end + + return client +end + +function quake:compute_size() + -- skip if we already have a geometry for this screen + if not self.geometry[self.screen.index] then + local geom + if not self.overlap then + geom = screen[self.screen.index].workarea + else + geom = screen[self.screen.index].geometry + end + local width, height = self.width, self.height + if width <= 1 then width = math.floor(geom.width * width) - 2 * self.border end + if height <= 1 then height = math.floor(geom.height * height) end + local x, y + if self.horiz == "left" then x = geom.x + elseif self.horiz == "right" then x = geom.width + geom.x - width + else x = geom.x + (geom.width - width)/2 end + if self.vert == "top" then y = geom.y + elseif self.vert == "bottom" then y = geom.height + geom.y - height + else y = geom.y + (geom.height - height)/2 end + self.geometry[self.screen.index] = { x = x, y = y, width = width, height = height } + end + return self.geometry[self.screen.index] +end + +function quake:new(config) + local conf = config or {} + + conf.app = conf.app or "xterm" -- application to spawn + conf.name = conf.name or "QuakeDD" -- window name + conf.argname = conf.argname or "-name %s" -- how to specify window name + conf.extra = conf.extra or "" -- extra arguments + conf.border = conf.border or 1 -- client border width + conf.visible = conf.visible or false -- initially not visible + conf.followtag = conf.followtag or false -- spawn on currently focused screen + conf.overlap = conf.overlap or false -- overlap wibox + conf.screen = conf.screen or awful.screen.focused() + conf.settings = conf.settings + + -- If width or height <= 1 this is a proportion of the workspace + conf.height = conf.height or 0.25 -- height + conf.width = conf.width or 1 -- width + conf.vert = conf.vert or "top" -- top, bottom or center + conf.horiz = conf.horiz or "left" -- left, right or center + conf.geometry = {} -- internal use + + local dropdown = setmetatable(conf, { __index = quake }) + + capi.client.connect_signal("manage", function(c) + if c.instance == dropdown.name and c.screen == dropdown.screen then + dropdown:display() + end + end) + capi.client.connect_signal("unmanage", function(c) + if c.instance == dropdown.name and c.screen == dropdown.screen then + dropdown.visible = false + end + end) + + return dropdown +end + +function quake:toggle() + if self.followtag then self.screen = awful.screen.focused() end + local current_tag = self.screen.selected_tag + if current_tag and self.last_tag ~= current_tag and self.visible then + local c=self:display() + if c then + c:move_to_tag(current_tag) + end + else + self.visible = not self.visible + self:display() + end +end + +return setmetatable(quake, { __call = function(_, ...) return quake:new(...) end }) diff --git a/stow_home/awesome/.config/awesome/lain/util/separators.lua b/stow_home/awesome/.config/awesome/lain/util/separators.lua new file mode 100644 index 0000000..465132d --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/util/separators.lua @@ -0,0 +1,117 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2015, Luca CPZ + * (c) 2015, plotnikovanton + +--]] + +local wibox = require("wibox") +local gears = require("gears") + +-- Lain Cairo separators util submodule +-- lain.util.separators +local separators = { height = 0, width = 9 } + +-- [[ Arrow + +-- Right +function separators.arrow_right(col1, col2) + local widget = wibox.widget.base.make_widget() + widget.col1 = col1 + widget.col2 = col2 + + widget.fit = function(m, w, h) + return separators.width, separators.height + end + + widget.update = function(col1, col2) + widget.col1 = col1 + widget.col2 = col2 + widget:emit_signal("widget::redraw_needed") + end + + widget.draw = function(mycross, wibox, cr, width, height) + if widget.col2 ~= "alpha" then + cr:set_source_rgb(gears.color.parse_color(widget.col2)) + cr:new_path() + cr:move_to(0, 0) + cr:line_to(width, height/2) + cr:line_to(width, 0) + cr:close_path() + cr:fill() + + cr:new_path() + cr:move_to(0, height) + cr:line_to(width, height/2) + cr:line_to(width, height) + cr:close_path() + cr:fill() + end + + if widget.col1 ~= "alpha" then + cr:set_source_rgb(gears.color.parse_color(widget.col1)) + cr:new_path() + cr:move_to(0, 0) + cr:line_to(width, height/2) + cr:line_to(0, height) + cr:close_path() + cr:fill() + end + end + + return widget +end + +-- Left +function separators.arrow_left(col1, col2) + local widget = wibox.widget.base.make_widget() + widget.col1 = col1 + widget.col2 = col2 + + widget.fit = function(m, w, h) + return separators.width, separators.height + end + + widget.update = function(col1, col2) + widget.col1 = col1 + widget.col2 = col2 + widget:emit_signal("widget::redraw_needed") + end + + widget.draw = function(mycross, wibox, cr, width, height) + if widget.col1 ~= "alpha" then + cr:set_source_rgb(gears.color.parse_color(widget.col1)) + cr:new_path() + cr:move_to(width, 0) + cr:line_to(0, height/2) + cr:line_to(0, 0) + cr:close_path() + cr:fill() + + cr:new_path() + cr:move_to(width, height) + cr:line_to(0, height/2) + cr:line_to(0, height) + cr:close_path() + cr:fill() + end + + if widget.col2 ~= "alpha" then + cr:new_path() + cr:move_to(width, 0) + cr:line_to(0, height/2) + cr:line_to(width, height) + cr:close_path() + + cr:set_source_rgb(gears.color.parse_color(widget.col2)) + cr:fill() + end + end + + return widget +end + +-- ]] + +return separators diff --git a/stow_home/awesome/.config/awesome/lain/widget/alsa.lua b/stow_home/awesome/.config/awesome/lain/widget/alsa.lua new file mode 100644 index 0000000..3b6c6d6 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/alsa.lua @@ -0,0 +1,53 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2010, Adrian C. + +--]] + +local helpers = require("lain.helpers") +local shell = require("awful.util").shell +local wibox = require("wibox") +local string = string + +-- ALSA volume +-- lain.widget.alsa + +local function factory(args) + local alsa = { widget = wibox.widget.textbox() } + local args = args or {} + local timeout = args.timeout or 5 + local settings = args.settings or function() end + + alsa.cmd = args.cmd or "amixer" + alsa.channel = args.channel or "Master" + alsa.togglechannel = args.togglechannel + + local format_cmd = string.format("%s get %s", alsa.cmd, alsa.channel) + + if alsa.togglechannel then + format_cmd = { shell, "-c", string.format("%s get %s; %s get %s", + alsa.cmd, alsa.channel, alsa.cmd, alsa.togglechannel) } + end + + alsa.last = {} + + function alsa.update() + helpers.async(format_cmd, function(mixer) + local l,s = string.match(mixer, "([%d]+)%%.*%[([%l]*)") + if alsa.last.level ~= l or alsa.last.status ~= s then + volume_now = { level = l, status = s } + widget = alsa.widget + settings() + alsa.last = volume_now + end + end) + end + + helpers.newtimer(string.format("alsa-%s-%s", alsa.cmd, alsa.channel), timeout, alsa.update) + + return alsa +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/alsabar.lua b/stow_home/awesome/.config/awesome/lain/widget/alsabar.lua new file mode 100644 index 0000000..b2f7b44 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/alsabar.lua @@ -0,0 +1,166 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2013, Rman + +--]] + +local helpers = require("lain.helpers") +local awful = require("awful") +local naughty = require("naughty") +local wibox = require("wibox") +local math = math +local string = string +local type = type +local tonumber = tonumber + +-- ALSA volume bar +-- lain.widget.alsabar + +local function factory(args) + local alsabar = { + colors = { + background = "#000000", + mute = "#EB8F8F", + unmute = "#A4CE8A" + }, + + _current_level = 0, + _playback = "off" + } + + local args = args or {} + local timeout = args.timeout or 5 + local settings = args.settings or function() end + local width = args.width or 63 + local height = args.height or 1 + local margins = args.margins or 1 + local paddings = args.paddings or 1 + local ticks = args.ticks or false + local ticks_size = args.ticks_size or 7 + local tick = args.tick or "|" + local tick_pre = args.tick_pre or "[" + local tick_post = args.tick_post or "]" + local tick_none = args.tick_none or " " + + alsabar.cmd = args.cmd or "amixer" + alsabar.channel = args.channel or "Master" + alsabar.togglechannel = args.togglechannel + alsabar.colors = args.colors or alsabar.colors + alsabar.followtag = args.followtag or false + alsabar.notification_preset = args.notification_preset + + if not alsabar.notification_preset then + alsabar.notification_preset = { font = "Monospace 10" } + end + + local format_cmd = string.format("%s get %s", alsabar.cmd, alsabar.channel) + + if alsabar.togglechannel then + format_cmd = { awful.util.shell, "-c", string.format("%s get %s; %s get %s", + alsabar.cmd, alsabar.channel, alsabar.cmd, alsabar.togglechannel) } + end + + alsabar.bar = wibox.widget { + color = alsabar.colors.unmute, + background_color = alsabar.colors.background, + forced_height = height, + forced_width = width, + margins = margins, + paddings = margins, + ticks = ticks, + ticks_size = ticks_size, + widget = wibox.widget.progressbar + } + + alsabar.tooltip = awful.tooltip({ objects = { alsabar.bar } }) + + function alsabar.update(callback) + helpers.async(format_cmd, function(mixer) + local vol, playback = string.match(mixer, "([%d]+)%%.*%[([%l]*)") + + if not vol or not playback then return end + + if vol ~= alsabar._current_level or playback ~= alsabar._playback then + alsabar._current_level = tonumber(vol) + alsabar.bar:set_value(alsabar._current_level / 100) + if alsabar._current_level == 0 or playback == "off" then + alsabar._playback = playback + alsabar.tooltip:set_text("[Muted]") + alsabar.bar.color = alsabar.colors.mute + else + alsabar._playback = "on" + alsabar.tooltip:set_text(string.format("%s: %s", alsabar.channel, vol)) + alsabar.bar.color = alsabar.colors.unmute + end + + volume_now = { + level = alsabar._current_level, + status = alsabar._playback + } + + settings() + + if type(callback) == "function" then callback() end + end + end) + end + + function alsabar.notify() + alsabar.update(function() + local preset = alsabar.notification_preset + + preset.title = string.format("%s - %s%%", alsabar.channel, alsabar._current_level) + + if alsabar._playback == "off" then + preset.title = preset.title .. " Muted" + end + + -- tot is the maximum number of ticks to display in the notification + local tot = alsabar.notification_preset.max_ticks + + if not tot then + local wib = awful.screen.focused().mywibox + -- if we can grab mywibox, tot is defined as its height if + -- horizontal, or width otherwise + if wib then + if wib.position == "left" or wib.position == "right" then + tot = wib.width + else + tot = wib.height + end + -- fallback: default horizontal wibox height + else + tot = 20 + end + end + + int = math.modf((alsabar._current_level / 100) * tot) + preset.text = string.format( + "%s%s%s%s", + tick_pre, + string.rep(tick, int), + string.rep(tick_none, tot - int), + tick_post + ) + + if alsabar.followtag then preset.screen = awful.screen.focused() end + + if not alsabar.notification then + alsabar.notification = naughty.notify { + preset = preset, + destroy = function() alsabar.notification = nil end + } + else + naughty.replace_text(alsabar.notification, preset.title, preset.text) + end + end) + end + + helpers.newtimer(string.format("alsabar-%s-%s", alsabar.cmd, alsabar.channel), timeout, alsabar.update) + + return alsabar +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/bat.lua b/stow_home/awesome/.config/awesome/lain/widget/bat.lua new file mode 100644 index 0000000..3cb801c --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/bat.lua @@ -0,0 +1,217 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2010-2012, Peter Hofmann + +--]] + +local helpers = require("lain.helpers") +local fs = require("gears.filesystem") +local naughty = require("naughty") +local wibox = require("wibox") +local math = math +local string = string +local ipairs = ipairs +local tonumber = tonumber + +-- Battery infos +-- lain.widget.bat + +local function factory(args) + local pspath = args.pspath or "/sys/class/power_supply/" + + if not fs.is_dir(pspath) then + naughty.notify { text = "lain.widget.bat: invalid power supply path", timeout = 0 } + return + end + + local bat = { widget = wibox.widget.textbox() } + local args = args or {} + local timeout = args.timeout or 30 + local notify = args.notify or "on" + local full_notify = args.full_notify or notify + local n_perc = args.n_perc or { 5, 15 } + local batteries = args.batteries or (args.battery and {args.battery}) or {} + local ac = args.ac or "AC0" + local settings = args.settings or function() end + + function bat.get_batteries() + helpers.line_callback("ls -1 " .. pspath, function(line) + local bstr = string.match(line, "BAT%w+") + if bstr then + batteries[#batteries + 1] = bstr + else + ac = string.match(line, "A%w+") or "AC0" + end + end) + end + + if #batteries == 0 then bat.get_batteries() end + + bat_notification_critical_preset = { + title = "Battery exhausted", + text = "Shutdown imminent", + timeout = 15, + fg = "#000000", + bg = "#FFFFFF" + } + + bat_notification_low_preset = { + title = "Battery low", + text = "Plug the cable!", + timeout = 15, + fg = "#202020", + bg = "#CDCDCD" + } + + bat_notification_charged_preset = { + title = "Battery full", + text = "You can unplug the cable", + timeout = 15, + fg = "#202020", + bg = "#CDCDCD" + } + + bat_now = { + status = "N/A", + ac_status = "N/A", + perc = "N/A", + time = "N/A", + watt = "N/A" + } + + bat_now.n_status = {} + bat_now.n_perc = {} + for i = 1, #batteries do + bat_now.n_status[i] = "N/A" + bat_now.n_perc[i] = 0 + end + + -- used to notify full charge only once before discharging + local fullnotification = false + + function bat.update() + local sum_rate_current = 0 + local sum_rate_voltage = 0 + local sum_rate_power = 0 + local sum_rate_energy = 0 + local sum_energy_now = 0 + local sum_energy_full = 0 + + for i, battery in ipairs(batteries) do + local bstr = pspath .. battery + local present = helpers.first_line(bstr .. "/present") + + if tonumber(present) == 1 then + -- current_now(I)[uA], voltage_now(U)[uV], power_now(P)[uW] + local rate_current = tonumber(helpers.first_line(bstr .. "/current_now")) + local rate_voltage = tonumber(helpers.first_line(bstr .. "/voltage_now")) + local rate_power = tonumber(helpers.first_line(bstr .. "/power_now")) + + -- energy_now(P)[uWh], charge_now(I)[uAh] + local energy_now = tonumber(helpers.first_line(bstr .. "/energy_now") or + helpers.first_line(bstr .. "/charge_now")) + + -- energy_full(P)[uWh], charge_full(I)[uAh] + local energy_full = tonumber(helpers.first_line(bstr .. "/energy_full") or + helpers.first_line(bstr .. "/charge_full")) + + local energy_percentage = tonumber(helpers.first_line(bstr .. "/capacity")) or + math.floor((energy_now / energy_full) * 100) + + bat_now.n_status[i] = helpers.first_line(bstr .. "/status") or "N/A" + bat_now.n_perc[i] = energy_percentage or bat_now.n_perc[i] + + sum_rate_current = sum_rate_current + (rate_current or 0) + sum_rate_voltage = sum_rate_voltage + (rate_voltage or 0) + sum_rate_power = sum_rate_power + (rate_power or 0) + sum_rate_energy = sum_rate_energy + (rate_power or (((rate_voltage or 0) * (rate_current or 0)) / 1e6)) + sum_energy_now = sum_energy_now + (energy_now or 0) + sum_energy_full = sum_energy_full + (energy_full or 0) + end + end + + -- When one of the battery is charging, others' status are either + -- "Full", "Unknown" or "Charging". When the laptop is not plugged in, + -- one or more of the batteries may be full, but only one battery + -- discharging suffices to set global status to "Discharging". + bat_now.status = bat_now.n_status[1] + for _,status in ipairs(bat_now.n_status) do + if status == "Discharging" or status == "Charging" then + bat_now.status = status + end + end + bat_now.ac_status = tonumber(helpers.first_line(string.format("%s%s/online", pspath, ac))) or "N/A" + + if bat_now.status ~= "N/A" then + if bat_now.status ~= "Full" and sum_rate_power == 0 and bat_now.ac_status == 1 then + bat_now.perc = math.floor(math.min(100, (sum_energy_now / sum_energy_full) * 100)) + bat_now.time = "00:00" + bat_now.watt = 0 + + -- update {perc,time,watt} iff battery not full and rate > 0 + elseif bat_now.status ~= "Full" then + local rate_time = 0 + -- Calculate time and watt if rates are greater then 0 + if (sum_rate_power > 0 or sum_rate_current > 0) then + local div = (sum_rate_power > 0 and sum_rate_power) or sum_rate_current + + if bat_now.status == "Charging" then + rate_time = (sum_energy_full - sum_energy_now) / div + else -- Discharging + rate_time = sum_energy_now / div + end + + if 0 < rate_time and rate_time < 0.01 then -- check for magnitude discrepancies (#199) + rate_time_magnitude = math.abs(math.floor(math.log10(rate_time))) + rate_time = rate_time * 10^(rate_time_magnitude - 2) + end + end + + local hours = math.floor(rate_time) + local minutes = math.floor((rate_time - hours) * 60) + bat_now.perc = math.floor(math.min(100, (sum_energy_now / sum_energy_full) * 100)) + bat_now.time = string.format("%02d:%02d", hours, minutes) + bat_now.watt = tonumber(string.format("%.2f", sum_rate_energy / 1e6)) + elseif bat_now.status == "Full" then + bat_now.perc = 100 + bat_now.time = "00:00" + bat_now.watt = 0 + end + end + + widget = bat.widget + settings() + + -- notifications for critical, low, and full levels + if notify == "on" then + if bat_now.status == "Discharging" then + if tonumber(bat_now.perc) <= n_perc[1] then + bat.id = naughty.notify({ + preset = bat_notification_critical_preset, + replaces_id = bat.id + }).id + elseif tonumber(bat_now.perc) <= n_perc[2] then + bat.id = naughty.notify({ + preset = bat_notification_low_preset, + replaces_id = bat.id + }).id + end + fullnotification = false + elseif bat_now.status == "Full" and full_notify == "on" and not fullnotification then + bat.id = naughty.notify({ + preset = bat_notification_charged_preset, + replaces_id = bat.id + }).id + fullnotification = true + end + end + end + + helpers.newtimer("batteries", timeout, bat.update) + + return bat +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/cal.lua b/stow_home/awesome/.config/awesome/lain/widget/cal.lua new file mode 100644 index 0000000..928a7bd --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/cal.lua @@ -0,0 +1,175 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2018, Luca CPZ + +--]] + +local helpers = require("lain.helpers") +local markup = require("lain.util.markup") +local awful = require("awful") +local naughty = require("naughty") +local floor = math.floor +local os = os +local pairs = pairs +local string = string +local tconcat = table.concat +local type = type +local tonumber = tonumber +local tostring = tostring + +-- Calendar notification +-- lain.widget.cal + +local function factory(args) + args = args or {} + local cal = { + attach_to = args.attach_to or {}, + week_start = args.week_start or 2, + three = args.three or false, + followtag = args.followtag or false, + week_number = args.week_number or "none", + week_number_format = args.week_number_format or args.week_number == "left" and "%3d | " or "| %-3d", + icons = args.icons or helpers.icons_dir .. "cal/white/", + notification_preset = args.notification_preset or { + font = "Monospace 10", fg = "#FFFFFF", bg = "#000000" + } + } + + function cal.get_week_number(m, st_day, x) + return string.format(cal.week_number_format, os.date("%V", m) + (x ~= 0 and floor((x + st_day) / 7) - 1 or 0)) + end + + function cal.sum_week_days(x, y) + return (x + y) % 7 + end + + function cal.build(month, year) + local current_month, current_year = tonumber(os.date("%m")), tonumber(os.date("%Y")) + local is_current_month = (not month or not year) or (month == current_month and year == current_year) + local today = is_current_month and tonumber(os.date("%d")) -- otherwise nil and not highlighted + local t = os.time { year = year or current_year, month = month and month+1 or current_month+1, day = 0 } + local d = os.date("*t", t) + local mth_days, st_day, this_month = d.day, (d.wday-d.day-cal.week_start+1)%7, os.date("%B %Y", t) + local notifytable = { [1] = string.format("%s%s\n", string.rep(" ", floor((28 - this_month:len())/2)), markup.bold(this_month)) } + for x = 0,6 do notifytable[#notifytable+1] = os.date("%a", os.time { year=2006, month=1, day=x+cal.week_start }):sub(1, 3) .. " " end + notifytable[#notifytable] = string.format("%s\n%s", notifytable[#notifytable]:sub(1, -2), string.rep(" ", st_day*4)) + local strx + for x = 1,mth_days do + strx = x + if x == today then + if x < 10 then x = " " .. x end + strx = markup.bold(markup.color(cal.notification_preset.bg, cal.notification_preset.fg, x) .. " ") + end + strx = string.format("%s%s", string.rep(" ", 3 - tostring(x):len()), strx) + notifytable[#notifytable+1] = string.format("%-4s%s", strx, (x+st_day)%7==0 and x ~= mth_days and "\n" or "") + end + if string.len(cal.icons or "") > 0 and today then cal.icon = cal.icons .. today .. ".png" end + cal.month, cal.year = d.month, d.year + + if cal.week_number ~= "none" then + local m = os.time { year = year or current_year, month = month and month or current_month, day = 0 } + local head_prepend = string.rep(" ", tostring(string.format(cal.week_number_format, 0)):len()) + + if cal.week_number == "left" then + notifytable[1] = head_prepend .. notifytable[1] -- month-year row + notifytable[2] = head_prepend .. notifytable[2] -- weekdays row + notifytable[8] = notifytable[8]:gsub("\n", "\n" .. cal.get_week_number(m, st_day, 0)) -- first week of the month + + for x = 10,#notifytable do + if cal.sum_week_days(st_day, x) == 2 then + notifytable[x] = cal.get_week_number(m, st_day, x) .. notifytable[x] + end + end + elseif cal.week_number == "right" then + notifytable[8] = notifytable[8]:gsub("\n", head_prepend .. "\n") -- weekdays row + for x = 9,#notifytable do + if cal.sum_week_days(st_day, x) == 1 then + notifytable[x] = notifytable[x]:gsub("\n", cal.get_week_number(m, st_day, x - 7) .. "\n") + end + end + -- last week of the month + local end_days = cal.sum_week_days(st_day, mth_days) + if end_days ~= 0 then end_days = 7 - end_days end + notifytable[#notifytable] = notifytable[#notifytable] .. string.rep(" ", 4 * end_days) .. cal.get_week_number(m, st_day, mth_days + end_days) + end + end + + return notifytable + end + + function cal.getdate(month, year, offset) + if not month or not year then + month = tonumber(os.date("%m")) + year = tonumber(os.date("%Y")) + end + + month = month + offset + + while month > 12 do + month = month - 12 + year = year + 1 + end + + while month < 1 do + month = month + 12 + year = year - 1 + end + + return month, year + end + + function cal.hide() + if not cal.notification then return end + naughty.destroy(cal.notification) + cal.notification = nil + end + + function cal.show(seconds, month, year, scr) + cal.notification_preset.text = tconcat(cal.build(month, year)) + + if cal.three then + local current_month, current_year = cal.month, cal.year + local prev_month, prev_year = cal.getdate(cal.month, cal.year, -1) + local next_month, next_year = cal.getdate(cal.month, cal.year, 1) + cal.notification_preset.text = string.format("%s\n\n%s\n\n%s", + tconcat(cal.build(prev_month, prev_year)), cal.notification_preset.text, + tconcat(cal.build(next_month, next_year))) + cal.month, cal.year = current_month, current_year + end + + cal.hide() + cal.notification = naughty.notify { + preset = cal.notification_preset, + screen = cal.followtag and awful.screen.focused() or scr or 1, + icon = cal.icon, + timeout = type(seconds) == "number" and seconds or cal.notification_preset.timeout or 5 + } + end + + function cal.hover_on() cal.show(0) end + function cal.move(offset) + local offset = offset or 0 + cal.month, cal.year = cal.getdate(cal.month, cal.year, offset) + cal.show(0, cal.month, cal.year) + end + function cal.prev() cal.move(-1) end + function cal.next() cal.move( 1) end + + function cal.attach(widget) + widget:connect_signal("mouse::enter", cal.hover_on) + widget:connect_signal("mouse::leave", cal.hide) + widget:buttons(awful.util.table.join( + awful.button({}, 1, cal.prev), + awful.button({}, 3, cal.next), + awful.button({}, 2, cal.hover_on), + awful.button({}, 5, cal.prev), + awful.button({}, 4, cal.next))) + end + + for _, widget in pairs(cal.attach_to) do cal.attach(widget) end + + return cal +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/contrib/init.lua b/stow_home/awesome/.config/awesome/lain/widget/contrib/init.lua new file mode 100644 index 0000000..9e863a5 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/contrib/init.lua @@ -0,0 +1,18 @@ +--[[ + + Lain + Layouts, widgets and utilities for Awesome WM + + Users contributed widgets section + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + +--]] + +local wrequire = require("lain.helpers").wrequire +local setmetatable = setmetatable + +local widget = { _NAME = "lain.widget.contrib" } + +return setmetatable(widget, { __index = wrequire }) diff --git a/stow_home/awesome/.config/awesome/lain/widget/contrib/moc.lua b/stow_home/awesome/.config/awesome/lain/widget/contrib/moc.lua new file mode 100644 index 0000000..f429c77 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/contrib/moc.lua @@ -0,0 +1,96 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2014, anticlockwise + +--]] + +local helpers = require("lain.helpers") +local shell = require("awful.util").shell +local focused = require("awful.screen").focused +local escape_f = require("awful.util").escape +local naughty = require("naughty") +local wibox = require("wibox") +local os = os +local string = string + +-- MOC audio player +-- lain.widget.contrib.moc + +local function factory(args) + local moc = { widget = wibox.widget.textbox() } + local args = args or {} + local timeout = args.timeout or 2 + local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" + local cover_pattern = args.cover_pattern or "*\\.(jpg|jpeg|png|gif)$" + local cover_size = args.cover_size or 100 + local default_art = args.default_art or "" + local followtag = args.followtag or false + local settings = args.settings or function() end + + moc_notification_preset = { title = "Now playing", timeout = 6 } + + helpers.set_map("current moc track", nil) + + function moc.update() + helpers.async("mocp -i", function(f) + moc_now = { + state = "N/A", + file = "N/A", + artist = "N/A", + title = "N/A", + album = "N/A", + elapsed = "N/A", + total = "N/A" + } + + for line in string.gmatch(f, "[^\n]+") do + for k, v in string.gmatch(line, "([%w]+):[%s](.*)$") do + if k == "State" then moc_now.state = v + elseif k == "File" then moc_now.file = v + elseif k == "Artist" then moc_now.artist = escape_f(v) + elseif k == "SongTitle" then moc_now.title = escape_f(v) + elseif k == "Album" then moc_now.album = escape_f(v) + elseif k == "CurrentTime" then moc_now.elapsed = escape_f(v) + elseif k == "TotalTime" then moc_now.total = escape_f(v) + end + end + end + + moc_notification_preset.text = string.format("%s (%s) - %s\n%s", moc_now.artist, + moc_now.album, moc_now.total, moc_now.title) + widget = moc.widget + settings() + + if moc_now.state == "PLAY" then + if moc_now.title ~= helpers.get_map("current moc track") then + helpers.set_map("current moc track", moc_now.title) + + if followtag then moc_notification_preset.screen = focused() end + + local common = { + preset = moc_notification_preset, + icon = default_art, + icon_size = cover_size, + replaces_id = moc.id, + } + + local path = string.format("%s/%s", music_dir, string.match(moc_now.file, ".*/")) + local cover = string.format("find '%s' -maxdepth 1 -type f | egrep -i -m1 '%s'", path, cover_pattern) + helpers.async({ shell, "-c", cover }, function(current_icon) + common.icon = current_icon:gsub("\n", "") + moc.id = naughty.notify(common).id + end) + end + elseif moc_now.state ~= "PAUSE" then + helpers.set_map("current moc track", nil) + end + end) + end + + moc.timer = helpers.newtimer("moc", timeout, moc.update, true, true) + + return moc +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/contrib/redshift.lua b/stow_home/awesome/.config/awesome/lain/widget/contrib/redshift.lua new file mode 100644 index 0000000..d0e5eed --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/contrib/redshift.lua @@ -0,0 +1,54 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2017, Luca CPZ + * (c) 2014, blueluke + +--]] + +local async = require("lain.helpers").async +local awful = require("awful") +local execute = os.execute +local type = type + +-- Redshift +-- lain.widget.contrib.redshift +local redshift = { active = false, pid = nil } + +function redshift:start() + execute("pkill redshift") + awful.spawn.with_shell("redshift -x") -- clear adjustments + redshift.pid = awful.spawn.with_shell("redshift") + redshift.active = true + if type(redshift.update_fun) == "function" then + redshift.update_fun(redshift.active) + end +end + +function redshift:toggle() + async({ awful.util.shell, "-c", string.format("ps -p %d -o pid=", redshift.pid) }, function(f) + if f and #f > 0 then -- redshift is running + -- Sending -USR1 toggles redshift (See project website) + execute("pkill -USR1 redshift") + redshift.active = not redshift.active + else -- not started or killed, (re)start it + redshift:start() + end + redshift.update_fun(redshift.active) + end) +end + +-- Attach to a widget +-- Provides a button which toggles redshift on/off on click +-- @param widget: Widget to attach to. +-- @param fun: Function to be run each time redshift is toggled (optional). +-- Use it to update widget text or icons on status change. +function redshift:attach(widget, fun) + redshift.update_fun = fun or function() end + if not redshift.pid then redshift:start() end + if widget then + widget:buttons(awful.util.table.join(awful.button({}, 1, function () redshift:toggle() end))) + end +end + +return redshift diff --git a/stow_home/awesome/.config/awesome/lain/widget/contrib/task.lua b/stow_home/awesome/.config/awesome/lain/widget/contrib/task.lua new file mode 100644 index 0000000..536e006 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/contrib/task.lua @@ -0,0 +1,92 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Jan Xie + +--]] + +local helpers = require("lain.helpers") +local markup = require("lain.util").markup +local awful = require("awful") +local naughty = require("naughty") +local mouse = mouse +local string = string + +-- Taskwarrior notification +-- lain.widget.contrib.task +local task = {} + +function task.hide() + if not task.notification then return end + naughty.destroy(task.notification) + task.notification = nil +end + +function task.show(scr) + task.notification_preset.screen = task.followtag and awful.screen.focused() or scr or 1 + + helpers.async({ awful.util.shell, "-c", task.show_cmd }, function(f) + local widget_focused = true + + if mouse.current_widgets then + widget_focused = false + for _,v in ipairs(mouse.current_widgets) do + if task.widget == v then + widget_focused = true + break + end + end + end + + if widget_focused then + task.hide() + task.notification = naughty.notify { + preset = task.notification_preset, + title = "task next", + text = markup.font(task.notification_preset.font, + awful.util.escape(f:gsub("\n*$", ""))) + } + end + end) +end + +function task.prompt() + awful.prompt.run { + prompt = task.prompt_text, + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = function(t) + helpers.async(t, function(f) + naughty.notify { + preset = task.notification_preset, + title = t, + text = markup.font(task.notification_preset.font, + awful.util.escape(f:gsub("\n*$", ""))) + } + end) + end, + history_path = awful.util.getdir("cache") .. "/history_task" + } +end + +function task.attach(widget, args) + local args = args or {} + task.show_cmd = args.show_cmd or "task next" + task.prompt_text = args.prompt_text or "Enter task command: " + task.followtag = args.followtag or false + task.notification_preset = args.notification_preset + task.widget = widget + + if not task.notification_preset then + task.notification_preset = { + font = "Monospace 10", + icon = helpers.icons_dir .. "/taskwarrior.png" + } + end + + if widget then + widget:connect_signal("mouse::enter", function () task.show() end) + widget:connect_signal("mouse::leave", function () task.hide() end) + end +end + +return task diff --git a/stow_home/awesome/.config/awesome/lain/widget/contrib/tp_smapi.lua b/stow_home/awesome/.config/awesome/lain/widget/contrib/tp_smapi.lua new file mode 100644 index 0000000..b8acbe2 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/contrib/tp_smapi.lua @@ -0,0 +1,147 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2018, Luca CPZ + * (c) 2013, Conor Heine + +--]] + +local helpers = require("lain.helpers") +local focused = require("awful.screen").focused +local gears = require("gears") +local naughty = require("naughty") +local wibox = require("wibox") +local string = string +local type = type + +-- ThinkPad battery infos and widget creator +-- http://www.thinkwiki.org/wiki/Tp_smapi +-- lain.widget.contrib.tp_smapi + +local function factory(apipath) + local tp_smapi = { + path = apipath or "/sys/devices/platform/smapi" + } + + function tp_smapi.get(batid, feature) + return helpers.first_line(string.format("%s/%s/%s", tp_smapi.path, batid or "BAT0", feature or "")) + end + + function tp_smapi.installed(batid) + return tp_smapi.get(batid, "installed") == "1" + end + + function tp_smapi.status(batid) + return tp_smapi.get(batid, "state") + end + + function tp_smapi.percentage(batid) + return tp_smapi.get(batid, "remaining_percent") + end + + -- either running or charging time + function tp_smapi.time(batid) + local status = tp_smapi.status(batid) + local mins_left = tp_smapi.get(batid, string.match(string.lower(status), "discharging") and "remaining_running_time" or "remaining_charging_time") + if not string.find(mins_left, "^%d+") then return "N/A" end + return string.format("%02d:%02d", math.floor(mins_left / 60), mins_left % 60) -- HH:mm + end + + function tp_smapi.hide() + if not tp_smapi.notification then return end + naughty.destroy(tp_smapi.notification) + tp_smapi.notification = nil + end + + function tp_smapi.show(batid, seconds, scr) + if not tp_smapi.installed(batid) then return end + + local mfgr = tp_smapi.get(batid, "manufacturer") or "no_mfgr" + local model = tp_smapi.get(batid, "model") or "no_model" + local chem = tp_smapi.get(batid, "chemistry") or "no_chem" + local status = tp_smapi.get(batid, "state") + local time = tp_smapi.time(batid) + local msg = "" + + if status and status ~= "idle" then + msg = string.format("[%s] %s %s", status, time ~= "N/A" and time or "unknown remaining time", + string.lower(status):gsub(" ", ""):gsub("\n", "") == "charging" and " until charged" or " remaining") + else + msg = "On AC power" + end + + tp_smapi.hide() + tp_smapi.notification = naughty.notify { + title = string.format("%s: %s %s (%s)", batid, mfgr, model, chem), + text = msg, + timeout = type(seconds) == "number" and seconds or 0, + screen = scr or focused() + } + end + + function tp_smapi.create_widget(args) + local args = args or {} + local pspath = args.pspath or "/sys/class/power_supply/" + local batteries = args.batteries or (args.battery and {args.battery}) or {} + local timeout = args.timeout or 30 + local settings = args.settings or function() end + + if #batteries == 0 then + helpers.line_callback("ls -1 " .. pspath, function(line) + local bstr = string.match(line, "BAT%w+") + if bstr then batteries[#batteries + 1] = bstr end + end) + end + + local all_batteries_installed = true + + for i, battery in ipairs(batteries) do + if not tp_smapi.installed(battery) then + naughty.notify { + preset = naughty.config.critical, + title = "tp_smapi: error while creating widget", + text = string.format("battery %s is not installed", battery) + } + all_batteries_installed = false + break + end + end + + if not all_batteries_installed then return end + + tpbat = { + batteries = batteries, + widget = args.widget or wibox.widget.textbox() + } + + function tpbat.update() + tpbat_now = { + n_status = {}, + n_perc = {}, + n_time = {}, + status = "N/A" + } + + for i = 1, #batteries do + tpbat_now.n_status[i] = tp_smapi.status(batteries[i]) or "N/A" + tpbat_now.n_perc[i] = tp_smapi.percentage(batteries[i]) + tpbat_now.n_time[i] = tp_smapi.time(batteries[i]) or "N/A" + + if not tpbat_now.n_status[i]:lower():match("full") then + tpbat_now.status = tpbat_now.n_status[i] + end + end + + widget = tpbat.widget -- backwards compatibility + settings() + end + + helpers.newtimer("thinkpad-batteries", timeout, tpbat.update) + + return tpbat + end + + return tp_smapi +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/cpu.lua b/stow_home/awesome/.config/awesome/lain/widget/cpu.lua new file mode 100644 index 0000000..f4cce73 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/cpu.lua @@ -0,0 +1,75 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2010-2012, Peter Hofmann + +--]] + +local helpers = require("lain.helpers") +local wibox = require("wibox") +local math = math +local string = string +local tostring = tostring + +-- CPU usage +-- lain.widget.cpu + +local function factory(args) + local cpu = { core = {}, widget = wibox.widget.textbox() } + local args = args or {} + local timeout = args.timeout or 2 + local settings = args.settings or function() end + + function cpu.update() + -- Read the amount of time the CPUs have spent performing + -- different kinds of work. Read the first line of /proc/stat + -- which is the sum of all CPUs. + for index,time in pairs(helpers.lines_match("cpu","/proc/stat")) do + local coreid = index - 1 + local core = cpu.core[coreid] or + { last_active = 0 , last_total = 0, usage = 0 } + local at = 1 + local idle = 0 + local total = 0 + + for field in string.gmatch(time, "[%s]+([^%s]+)") do + -- 4 = idle, 5 = ioWait. Essentially, the CPUs have done + -- nothing during these times. + if at == 4 or at == 5 then + idle = idle + field + end + total = total + field + at = at + 1 + end + + local active = total - idle + + if core.last_active ~= active or core.last_total ~= total then + -- Read current data and calculate relative values. + local dactive = active - core.last_active + local dtotal = total - core.last_total + local usage = math.ceil((dactive / dtotal) * 100) + + core.last_active = active + core.last_total = total + core.usage = usage + + -- Save current data for the next run. + cpu.core[coreid] = core + end + end + + cpu_now = cpu.core + cpu_now.usage = cpu_now[0].usage + widget = cpu.widget + + settings() + end + + helpers.newtimer("cpu", timeout, cpu.update) + + return cpu +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/fs.lua b/stow_home/awesome/.config/awesome/lain/widget/fs.lua new file mode 100644 index 0000000..58fbf93 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/fs.lua @@ -0,0 +1,151 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2018, Uli Schlacter + * (c) 2018, Otto Modinos + * (c) 2013, Luca CPZ + +--]] + +local helpers = require("lain.helpers") +local Gio = require("lgi").Gio +local focused = require("awful.screen").focused +local wibox = require("wibox") +local naughty = require("naughty") +local math = math +local string = string +local tconcat = table.concat +local type = type +local tonumber = tonumber +local query_size = Gio.FILE_ATTRIBUTE_FILESYSTEM_SIZE +local query_free = Gio.FILE_ATTRIBUTE_FILESYSTEM_FREE +local query_used = Gio.FILE_ATTRIBUTE_FILESYSTEM_USED +local query = query_size .. "," .. query_free .. "," .. query_used + +-- File systems info +-- lain.widget.fs + +local function factory(args) + local fs = { + widget = wibox.widget.textbox(), + units = { + [1] = "Kb", [2] = "Mb", [3] = "Gb", + [4] = "Tb", [5] = "Pb", [6] = "Eb", + [7] = "Zb", [8] = "Yb" + } + } + + function fs.hide() + if not fs.notification then return end + naughty.destroy(fs.notification) + fs.notification = nil + end + + function fs.show(seconds, scr) + fs.hide(); fs.update() + fs.notification_preset.screen = fs.followtag and focused() or scr or 1 + fs.notification = naughty.notify { + preset = fs.notification_preset, + timeout = type(seconds) == "number" and seconds or 5 + } + end + + local args = args or {} + local timeout = args.timeout or 600 + local partition = args.partition + local threshold = args.threshold or 99 + local showpopup = args.showpopup or "on" + local settings = args.settings or function() end + + fs.followtag = args.followtag or false + fs.notification_preset = args.notification_preset + + if not fs.notification_preset then + fs.notification_preset = { + font = "Monospace 10", + fg = "#FFFFFF", + bg = "#000000" + } + end + + function fs.update() + local notifytable = { [1] = string.format("%-10s %4s\t%6s\t%6s\t\n", "path", "used", "free", "size") } + local pathlen = 10 + local maxpathidx = 1 + fs_now = {} + + for _, mount in ipairs(Gio.unix_mounts_get()) do + local path = Gio.unix_mount_get_mount_path(mount) + local root = Gio.File.new_for_path(path) + local info = root:query_filesystem_info(query) + + if info then + local size = info:get_attribute_uint64(query_size) + local used = info:get_attribute_uint64(query_used) + local free = info:get_attribute_uint64(query_free) + + if size > 0 then + local units = math.floor(math.log(size)/math.log(1024)) + + fs_now[path] = { + units = fs.units[units], + percentage = math.floor(100 * used / size), -- used percentage + size = size / math.pow(1024, math.floor(units)), + used = used / math.pow(1024, math.floor(units)), + free = free / math.pow(1024, math.floor(units)) + } + + if fs_now[path].percentage > 0 then -- don't notify unused file systems + notifytable[#notifytable+1] = string.format("\n%-10s %3s%%\t%6.2f\t%6.2f\t%s", path, + math.floor(fs_now[path].percentage), fs_now[path].free, fs_now[path].size, + fs_now[path].units) + + if #path > pathlen then + pathlen = #path + maxpathidx = #notifytable + end + end + end + end + end + + widget = fs.widget + settings() + + if partition and fs_now[partition] and fs_now[partition].percentage >= threshold then + if not helpers.get_map(partition) then + naughty.notify { + preset = naughty.config.presets.critical, + title = "Warning", + text = string.format("%s is above %d%% (%d%%)", partition, threshold, fs_now[partition].percentage) + } + helpers.set_map(partition, true) + else + helpers.set_map(partition, false) + end + end + + if pathlen > 10 then -- if are there paths longer than 10 chars, reformat first column accordingly + local pathspaces + for i = 1, #notifytable do + pathspaces = notifytable[i]:match("[ ]+") + if i ~= maxpathidx and pathspaces then + notifytable[i] = notifytable[i]:gsub(pathspaces, pathspaces .. string.rep(" ", pathlen - 10)) + end + end + end + + fs.notification_preset.text = tconcat(notifytable) + end + + if showpopup == "on" then + fs.widget:connect_signal('mouse::enter', function () fs.show(0) end) + fs.widget:connect_signal('mouse::leave', function () fs.hide() end) + end + + helpers.newtimer(partition or "fs", timeout, fs.update) + + return fs +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/imap.lua b/stow_home/awesome/.config/awesome/lain/widget/imap.lua new file mode 100644 index 0000000..b3d9dc7 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/imap.lua @@ -0,0 +1,93 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + +--]] + +local helpers = require("lain.helpers") +local naughty = require("naughty") +local wibox = require("wibox") +local awful = require("awful") +local string = string +local type = type +local tonumber = tonumber + +-- Mail IMAP check +-- lain.widget.imap + +local function factory(args) + local imap = { widget = wibox.widget.textbox() } + local args = args or {} + local server = args.server + local mail = args.mail + local password = args.password + local port = args.port or 993 + local timeout = args.timeout or 60 + local pwdtimeout = args.pwdtimeout or 10 + local is_plain = args.is_plain or false + local followtag = args.followtag or false + local notify = args.notify or "on" + local settings = args.settings or function() end + + local head_command = "curl --connect-timeout 3 -fsm 3" + local request = "-X 'STATUS INBOX (MESSAGES RECENT UNSEEN)'" + + if not server or not mail or not password then return end + + mail_notification_preset = { + icon = helpers.icons_dir .. "mail.png", + position = "top_left" + } + + helpers.set_map(mail, 0) + + if not is_plain then + if type(password) == "string" or type(password) == "table" then + helpers.async(password, function(f) password = f:gsub("\n", "") end) + elseif type(password) == "function" then + imap.pwdtimer = helpers.newtimer(mail .. "-password", pwdtimeout, function() + local retrieved_password, try_again = password() + if not try_again then + imap.pwdtimer:stop() -- stop trying to retrieve + password = retrieved_password or "" -- failsafe + end + end, true, true) + end + end + + function imap.update() + -- do not update if the password has not been retrieved yet + if type(password) ~= "string" then return end + + local curl = string.format("%s --url imaps://%s:%s/INBOX -u %s:'%s' %s -k", + head_command, server, port, mail, password, request) + + helpers.async(curl, function(f) + imap_now = { ["MESSAGES"] = 0, ["RECENT"] = 0, ["UNSEEN"] = 0 } + + for s,d in f:gmatch("(%w+)%s+(%d+)") do imap_now[s] = tonumber(d) end + mailcount = imap_now["UNSEEN"] -- backwards compatibility + widget = imap.widget + + settings() + + if notify == "on" and mailcount and mailcount >= 1 and mailcount > helpers.get_map(mail) then + if followtag then mail_notification_preset.screen = awful.screen.focused() end + naughty.notify { + preset = mail_notification_preset, + text = string.format("%s has %d new message%s", mail, mailcount, mailcount == 1 and "" or "s") + } + end + + helpers.set_map(mail, imap_now["UNSEEN"]) + end) + + end + + imap.timer = helpers.newtimer(mail, timeout, imap.update, true, true) + + return imap +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/init.lua b/stow_home/awesome/.config/awesome/lain/widget/init.lua new file mode 100644 index 0000000..57b86bb --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/init.lua @@ -0,0 +1,19 @@ +--[[ + + Lain + Layouts, widgets and utilities for Awesome WM + + Widgets section + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2010-2012, Peter Hofmann + +--]] + +local wrequire = require("lain.helpers").wrequire +local setmetatable = setmetatable + +local widget = { _NAME = "lain.widget" } + +return setmetatable(widget, { __index = wrequire }) diff --git a/stow_home/awesome/.config/awesome/lain/widget/mem.lua b/stow_home/awesome/.config/awesome/lain/widget/mem.lua new file mode 100644 index 0000000..3dcae2b --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/mem.lua @@ -0,0 +1,50 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2010-2012, Peter Hofmann + +--]] + +local helpers = require("lain.helpers") +local wibox = require("wibox") +local gmatch, lines, floor = string.gmatch, io.lines, math.floor + +-- Memory usage (ignoring caches) +-- lain.widget.mem + +local function factory(args) + local mem = { widget = wibox.widget.textbox() } + local args = args or {} + local timeout = args.timeout or 2 + local settings = args.settings or function() end + + function mem.update() + mem_now = {} + for line in lines("/proc/meminfo") do + for k, v in gmatch(line, "([%a]+):[%s]+([%d]+).+") do + if k == "MemTotal" then mem_now.total = floor(v / 1024 + 0.5) + elseif k == "MemFree" then mem_now.free = floor(v / 1024 + 0.5) + elseif k == "Buffers" then mem_now.buf = floor(v / 1024 + 0.5) + elseif k == "Cached" then mem_now.cache = floor(v / 1024 + 0.5) + elseif k == "SwapTotal" then mem_now.swap = floor(v / 1024 + 0.5) + elseif k == "SwapFree" then mem_now.swapf = floor(v / 1024 + 0.5) + elseif k == "SReclaimable" then mem_now.srec = floor(v / 1024 + 0.5) + end + end + end + + mem_now.used = mem_now.total - mem_now.free - mem_now.buf - mem_now.cache - mem_now.srec + mem_now.swapused = mem_now.swap - mem_now.swapf + mem_now.perc = math.floor(mem_now.used / mem_now.total * 100) + + widget = mem.widget + settings() + end + + helpers.newtimer("mem", timeout, mem.update) + + return mem +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/mpd.lua b/stow_home/awesome/.config/awesome/lain/widget/mpd.lua new file mode 100644 index 0000000..01f28e6 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/mpd.lua @@ -0,0 +1,132 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2010, Adrian C. + +--]] + +local helpers = require("lain.helpers") +local shell = require("awful.util").shell +local escape_f = require("awful.util").escape +local focused = require("awful.screen").focused +local naughty = require("naughty") +local wibox = require("wibox") +local os = os +local string = string + +-- MPD infos +-- lain.widget.mpd + +local function factory(args) + local mpd = { widget = wibox.widget.textbox() } + local args = args or {} + local timeout = args.timeout or 2 + local password = (args.password and #args.password > 0 and string.format("password %s\\n", args.password)) or "" + local host = args.host or os.getenv("MPD_HOST") or "127.0.0.1" + local port = args.port or os.getenv("MPD_PORT") or "6600" + local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" + local cover_pattern = args.cover_pattern or "*\\.(jpg|jpeg|png|gif)$" + local cover_size = args.cover_size or 100 + local default_art = args.default_art + local notify = args.notify or "on" + local followtag = args.followtag or false + local settings = args.settings or function() end + + local mpdh = string.format("telnet://%s:%s", host, port) + local echo = string.format("printf \"%sstatus\\ncurrentsong\\nclose\\n\"", password) + local cmd = string.format("%s | curl --connect-timeout 1 -fsm 3 %s", echo, mpdh) + + mpd_notification_preset = { title = "Now playing", timeout = 6 } + + helpers.set_map("current mpd track", nil) + + function mpd.update() + helpers.async({ shell, "-c", cmd }, function(f) + mpd_now = { + random_mode = false, + single_mode = false, + repeat_mode = false, + consume_mode = false, + pls_pos = "N/A", + pls_len = "N/A", + state = "N/A", + file = "N/A", + name = "N/A", + artist = "N/A", + title = "N/A", + album = "N/A", + genre = "N/A", + track = "N/A", + date = "N/A", + time = "N/A", + elapsed = "N/A" + } + + for line in string.gmatch(f, "[^\n]+") do + for k, v in string.gmatch(line, "([%w]+):[%s](.*)$") do + if k == "state" then mpd_now.state = v + elseif k == "file" then mpd_now.file = v + elseif k == "Name" then mpd_now.name = escape_f(v) + elseif k == "Artist" then mpd_now.artist = escape_f(v) + elseif k == "Title" then mpd_now.title = escape_f(v) + elseif k == "Album" then mpd_now.album = escape_f(v) + elseif k == "Genre" then mpd_now.genre = escape_f(v) + elseif k == "Track" then mpd_now.track = escape_f(v) + elseif k == "Date" then mpd_now.date = escape_f(v) + elseif k == "Time" then mpd_now.time = v + elseif k == "elapsed" then mpd_now.elapsed = string.match(v, "%d+") + elseif k == "song" then mpd_now.pls_pos = v + elseif k == "playlistlength" then mpd_now.pls_len = v + elseif k == "repeat" then mpd_now.repeat_mode = v ~= "0" + elseif k == "single" then mpd_now.single_mode = v ~= "0" + elseif k == "random" then mpd_now.random_mode = v ~= "0" + elseif k == "consume" then mpd_now.consume_mode = v ~= "0" + end + end + end + + mpd_notification_preset.text = string.format("%s (%s) - %s\n%s", mpd_now.artist, + mpd_now.album, mpd_now.date, mpd_now.title) + widget = mpd.widget + settings() + + if mpd_now.state == "play" then + if notify == "on" and mpd_now.title ~= helpers.get_map("current mpd track") then + helpers.set_map("current mpd track", mpd_now.title) + + if followtag then mpd_notification_preset.screen = focused() end + + local common = { + preset = mpd_notification_preset, + icon = default_art, + icon_size = cover_size, + replaces_id = mpd.id + } + + if not string.match(mpd_now.file, "http.*://") then -- local file instead of http stream + local path = string.format("%s/%s", music_dir, string.match(mpd_now.file, ".*/")) + local cover = string.format("find '%s' -maxdepth 1 -type f | egrep -i -m1 '%s'", + path:gsub("'", "'\\''"), cover_pattern) + helpers.async({ shell, "-c", cover }, function(current_icon) + common.icon = current_icon:gsub("\n", "") + if #common.icon == 0 then common.icon = nil end + mpd.id = naughty.notify(common).id + end) + else + mpd.id = naughty.notify(common).id + end + + end + elseif mpd_now.state ~= "pause" then + helpers.set_map("current mpd track", nil) + end + end) + end + + mpd.timer = helpers.newtimer("mpd", timeout, mpd.update, true, true) + + return mpd +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/net.lua b/stow_home/awesome/.config/awesome/lain/widget/net.lua new file mode 100644 index 0000000..805b577 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/net.lua @@ -0,0 +1,113 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2010-2012, Peter Hofmann + +--]] + +local helpers = require("lain.helpers") +local naughty = require("naughty") +local wibox = require("wibox") +local string = string + +-- Network infos +-- lain.widget.net + +local function factory(args) + local net = { widget = wibox.widget.textbox(), devices = {} } + local args = args or {} + local timeout = args.timeout or 2 + local units = args.units or 1024 -- KB + local notify = args.notify or "on" + local wifi_state = args.wifi_state or "off" + local eth_state = args.eth_state or "off" + local screen = args.screen or 1 + local settings = args.settings or function() end + + -- Compatibility with old API where iface was a string corresponding to 1 interface + net.iface = (args.iface and (type(args.iface) == "string" and {args.iface}) or + (type(args.iface) == "table" and args.iface)) or {} + + function net.get_device() + helpers.line_callback("ip link", function(line) + net.iface[#net.iface + 1] = not string.match(line, "LOOPBACK") and string.match(line, "(%w+): <") or nil + end) + end + + if #net.iface == 0 then net.get_device() end + + function net.update() + -- These are the totals over all specified interfaces + net_now = { + devices = {}, + -- Bytes since last iteration + sent = 0, + received = 0 + } + + for _, dev in ipairs(net.iface) do + local dev_now = {} + local dev_before = net.devices[dev] or { last_t = 0, last_r = 0 } + local now_t = tonumber(helpers.first_line(string.format("/sys/class/net/%s/statistics/tx_bytes", dev)) or 0) + local now_r = tonumber(helpers.first_line(string.format("/sys/class/net/%s/statistics/rx_bytes", dev)) or 0) + + dev_now.carrier = helpers.first_line(string.format("/sys/class/net/%s/carrier", dev)) or "0" + dev_now.state = helpers.first_line(string.format("/sys/class/net/%s/operstate", dev)) or "down" + + dev_now.sent = (now_t - dev_before.last_t) / timeout / units + dev_now.received = (now_r - dev_before.last_r) / timeout / units + + net_now.sent = net_now.sent + dev_now.sent + net_now.received = net_now.received + dev_now.received + + dev_now.sent = string.format("%.1f", dev_now.sent) + dev_now.received = string.format("%.1f", dev_now.received) + + dev_now.last_t = now_t + dev_now.last_r = now_r + + if wifi_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) == "DEVTYPE=wlan" and string.match(dev_now.carrier, "1") then + dev_now.wifi = true + dev_now.signal = tonumber(string.match(helpers.lines_from("/proc/net/wireless")[3], "(%-%d+%.)")) or nil + end + + if eth_state == "on" and helpers.first_line(string.format("/sys/class/net/%s/uevent", dev)) ~= "DEVTYPE=wlan" and string.match(dev_now.carrier, "1") then + dev_now.ethernet = true + end + + net.devices[dev] = dev_now + + -- Notify only once when connection is lost + if string.match(dev_now.carrier, "0") and notify == "on" and helpers.get_map(dev) then + naughty.notify { + title = dev, + text = "No carrier", + icon = helpers.icons_dir .. "no_net.png", + screen = screen + } + helpers.set_map(dev, false) + elseif string.match(dev_now.carrier, "1") then + helpers.set_map(dev, true) + end + + net_now.carrier = dev_now.carrier + net_now.state = dev_now.state + net_now.devices[dev] = dev_now + -- net_now.sent and net_now.received will be + -- the totals across all specified devices + end + + net_now.sent = string.format("%.1f", net_now.sent) + net_now.received = string.format("%.1f", net_now.received) + + widget = net.widget + settings() + end + + helpers.newtimer("network", timeout, net.update) + + return net +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/pulse.lua b/stow_home/awesome/.config/awesome/lain/widget/pulse.lua new file mode 100644 index 0000000..f63fe55 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/pulse.lua @@ -0,0 +1,57 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2016, Luca CPZ + +--]] + +local helpers = require("lain.helpers") +local shell = require("awful.util").shell +local wibox = require("wibox") +local string = string +local type = type + +-- PulseAudio volume +-- lain.widget.pulse + +local function factory(args) + local pulse = { widget = wibox.widget.textbox(), device = "N/A" } + local args = args or {} + local timeout = args.timeout or 5 + local settings = args.settings or function() end + + pulse.devicetype = args.devicetype or "sink" + pulse.cmd = args.cmd or "pacmd list-" .. pulse.devicetype .. "s | sed -n -e '/*/,$!d' -e '/index/p' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'" + + function pulse.update() + helpers.async({ shell, "-c", type(pulse.cmd) == "string" and pulse.cmd or pulse.cmd() }, + function(s) + volume_now = { + index = string.match(s, "index: (%S+)") or "N/A", + device = string.match(s, "device.string = \"(%S+)\"") or "N/A", + muted = string.match(s, "muted: (%S+)") or "N/A" + } + + pulse.device = volume_now.index + + local ch = 1 + volume_now.channel = {} + for v in string.gmatch(s, ":.-(%d+)%%") do + volume_now.channel[ch] = v + ch = ch + 1 + end + + volume_now.left = volume_now.channel[1] or "N/A" + volume_now.right = volume_now.channel[2] or "N/A" + + widget = pulse.widget + settings() + end) + end + + helpers.newtimer("pulse", timeout, pulse.update) + + return pulse +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/pulsebar.lua b/stow_home/awesome/.config/awesome/lain/widget/pulsebar.lua new file mode 100644 index 0000000..51290f8 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/pulsebar.lua @@ -0,0 +1,171 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2013, Rman + +--]] + +local helpers = require("lain.helpers") +local awful = require("awful") +local naughty = require("naughty") +local wibox = require("wibox") +local math = math +local string = string +local type = type +local tonumber = tonumber + +-- PulseAudio volume bar +-- lain.widget.pulsebar + +local function factory(args) + local pulsebar = { + colors = { + background = "#000000", + mute = "#EB8F8F", + unmute = "#A4CE8A" + }, + + _current_level = 0, + _mute = "no", + device = "N/A" + } + + local args = args or {} + local timeout = args.timeout or 5 + local settings = args.settings or function() end + local width = args.width or 63 + local height = args.height or 1 + local margins = args.margins or 1 + local paddings = args.paddings or 1 + local ticks = args.ticks or false + local ticks_size = args.ticks_size or 7 + local tick = args.tick or "|" + local tick_pre = args.tick_pre or "[" + local tick_post = args.tick_post or "]" + local tick_none = args.tick_none or " " + + pulsebar.colors = args.colors or pulsebar.colors + pulsebar.followtag = args.followtag or false + pulsebar.notification_preset = args.notification_preset + pulsebar.devicetype = args.devicetype or "sink" + pulsebar.cmd = args.cmd or "pacmd list-" .. pulsebar.devicetype .. "s | sed -n -e '/*/,$!d' -e '/index/p' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'" + + if not pulsebar.notification_preset then + pulsebar.notification_preset = { + font = "Monospace 10" + } + end + + pulsebar.bar = wibox.widget { + color = pulsebar.colors.unmute, + background_color = pulsebar.colors.background, + forced_height = height, + forced_width = width, + margins = margins, + paddings = paddings, + ticks = ticks, + ticks_size = ticks_size, + widget = wibox.widget.progressbar, + } + + pulsebar.tooltip = awful.tooltip({ objects = { pulsebar.bar } }) + + function pulsebar.update(callback) + helpers.async({ awful.util.shell, "-c", type(pulsebar.cmd) == "string" and pulsebar.cmd or pulsebar.cmd() }, + function(s) + volume_now = { + index = string.match(s, "index: (%S+)") or "N/A", + device = string.match(s, "device.string = \"(%S+)\"") or "N/A", + muted = string.match(s, "muted: (%S+)") or "N/A" + } + + pulsebar.device = volume_now.index + + local ch = 1 + volume_now.channel = {} + for v in string.gmatch(s, ":.-(%d+)%%") do + volume_now.channel[ch] = v + ch = ch + 1 + end + + volume_now.left = volume_now.channel[1] or "N/A" + volume_now.right = volume_now.channel[2] or "N/A" + + local volu = volume_now.left + local mute = volume_now.muted + + if volu:match("N/A") or mute:match("N/A") then return end + + if volu ~= pulsebar._current_level or mute ~= pulsebar._mute then + pulsebar._current_level = tonumber(volu) + pulsebar.bar:set_value(pulsebar._current_level / 100) + if pulsebar._current_level == 0 or mute == "yes" then + pulsebar._mute = mute + pulsebar.tooltip:set_text ("[muted]") + pulsebar.bar.color = pulsebar.colors.mute + else + pulsebar._mute = "no" + pulsebar.tooltip:set_text(string.format("%s %s: %s", pulsebar.devicetype, pulsebar.device, volu)) + pulsebar.bar.color = pulsebar.colors.unmute + end + + settings() + + if type(callback) == "function" then callback() end + end + end) + end + + function pulsebar.notify() + pulsebar.update(function() + local preset = pulsebar.notification_preset + + preset.title = string.format("%s %s - %s%%", pulsebar.devicetype, pulsebar.device, pulsebar._current_level) + + if pulsebar._mute == "yes" then + preset.title = preset.title .. " muted" + end + + -- tot is the maximum number of ticks to display in the notification + -- fallback: default horizontal wibox height + local wib, tot = awful.screen.focused().mywibox, 20 + + -- if we can grab mywibox, tot is defined as its height if + -- horizontal, or width otherwise + if wib then + if wib.position == "left" or wib.position == "right" then + tot = wib.width + else + tot = wib.height + end + end + + int = math.modf((pulsebar._current_level / 100) * tot) + preset.text = string.format( + "%s%s%s%s", + tick_pre, + string.rep(tick, int), + string.rep(tick_none, tot - int), + tick_post + ) + + if pulsebar.followtag then preset.screen = awful.screen.focused() end + + if not pulsebar.notification then + pulsebar.notification = naughty.notify { + preset = preset, + destroy = function() pulsebar.notification = nil end + } + else + naughty.replace_text(pulsebar.notification, preset.title, preset.text) + end + end) + end + + helpers.newtimer(string.format("pulsebar-%s-%s", pulsebar.devicetype, pulsebar.device), timeout, pulsebar.update) + + return pulsebar +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/sysload.lua b/stow_home/awesome/.config/awesome/lain/widget/sysload.lua new file mode 100644 index 0000000..adf3e03 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/sysload.lua @@ -0,0 +1,38 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + * (c) 2010-2012, Peter Hofmann + +--]] + +local helpers = require("lain.helpers") +local wibox = require("wibox") +local open, match = io.open, string.match + +-- System load +-- lain.widget.sysload + +local function factory(args) + local sysload = { widget = wibox.widget.textbox() } + local args = args or {} + local timeout = args.timeout or 2 + local settings = args.settings or function() end + + function sysload.update() + local f = open("/proc/loadavg") + local ret = f:read("*all") + f:close() + + load_1, load_5, load_15 = match(ret, "([^%s]+) ([^%s]+) ([^%s]+)") + + widget = sysload.widget + settings() + end + + helpers.newtimer("sysload", timeout, sysload.update) + + return sysload +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/temp.lua b/stow_home/awesome/.config/awesome/lain/widget/temp.lua new file mode 100644 index 0000000..e909b32 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/temp.lua @@ -0,0 +1,44 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2013, Luca CPZ + +--]] + +local helpers = require("lain.helpers") +local wibox = require("wibox") +local tonumber = tonumber + +-- {thermal,core} temperature info +-- lain.widget.temp + +local function factory(args) + local temp = { widget = wibox.widget.textbox() } + local args = args or {} + local timeout = args.timeout or 30 + local tempfile = args.tempfile or "/sys/devices/virtual/thermal/thermal_zone0/temp" + local settings = args.settings or function() end + + function temp.update() + helpers.async({"find", "/sys/devices", "-type", "f", "-name", "*temp*"}, function(f) + temp_now = {} + local temp_fl, temp_value + for t in f:gmatch("[^\n]+") do + temp_fl = helpers.first_line(t) + if temp_fl then + temp_value = tonumber(temp_fl) + temp_now[t] = temp_value and temp_value/1e3 or temp_fl + end + end + coretemp_now = temp_now[tempfile] or "N/A" + widget = temp.widget + settings() + end) + end + + helpers.newtimer("thermal", timeout, temp.update) + + return temp +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/widget/weather.lua b/stow_home/awesome/.config/awesome/lain/widget/weather.lua new file mode 100644 index 0000000..9c1e797 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/widget/weather.lua @@ -0,0 +1,148 @@ +--[[ + + Licensed under GNU General Public License v2 + * (c) 2015, Luca CPZ + +--]] + +local helpers = require("lain.helpers") +local json = require("lain.util").dkjson +local focused = require("awful.screen").focused +local naughty = require("naughty") +local wibox = require("wibox") +local math = math +local os = os +local string = string +local type = type +local tonumber = tonumber + +-- OpenWeatherMap +-- current weather and X-days forecast +-- lain.widget.weather + +local function factory(args) + local weather = { widget = wibox.widget.textbox() } + local args = args or {} + local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain's default + local timeout = args.timeout or 60 * 15 -- 15 min + local timeout_forecast = args.timeout or 60 * 60 * 24 -- 24 hrs + local current_call = args.current_call or "curl -s 'http://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s&APPID=%s'" + local forecast_call = args.forecast_call or "curl -s 'http://api.openweathermap.org/data/2.5/forecast/daily?id=%s&units=%s&lang=%s&cnt=%s&APPID=%s'" + local city_id = args.city_id or 0 -- placeholder + local units = args.units or "metric" + local lang = args.lang or "en" + local cnt = args.cnt or 5 + local date_cmd = args.date_cmd or "date -u -d @%d +'%%a %%d'" + local icons_path = args.icons_path or helpers.icons_dir .. "openweathermap/" + local notification_preset = args.notification_preset or {} + local notification_text_fun = args.notification_text_fun or + function (wn) + local day = os.date("%a %d", wn["dt"]) + local tmin = math.floor(wn["temp"]["min"]) + local tmax = math.floor(wn["temp"]["max"]) + local desc = wn["weather"][1]["description"] + return string.format("%s: %s, %d - %d ", day, desc, tmin, tmax) + end + local weather_na_markup = args.weather_na_markup or " N/A " + local followtag = args.followtag or false + local showpopup = args.showpopup or "on" + local settings = args.settings or function() end + + weather.widget:set_markup(weather_na_markup) + weather.icon_path = icons_path .. "na.png" + weather.icon = wibox.widget.imagebox(weather.icon_path) + + function weather.show(seconds) + weather.hide() + + if followtag then + notification_preset.screen = focused() + end + + if not weather.notification_text then + weather.update() + weather.forecast_update() + end + + weather.notification = naughty.notify { + preset = notification_preset, + text = weather.notification_text, + icon = weather.icon_path, + timeout = type(seconds == "number") and seconds or notification_preset.timeout + } + end + + function weather.hide() + if weather.notification then + naughty.destroy(weather.notification) + weather.notification = nil + end + end + + function weather.attach(obj) + obj:connect_signal("mouse::enter", function() + weather.show(0) + end) + obj:connect_signal("mouse::leave", function() + weather.hide() + end) + end + + function weather.forecast_update() + local cmd = string.format(forecast_call, city_id, units, lang, cnt, APPID) + helpers.async(cmd, function(f) + local pos, err + weather_now, pos, err = json.decode(f, 1, nil) + + if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then + weather.notification_text = "" + for i = 1, weather_now["cnt"] do + weather.notification_text = weather.notification_text .. + notification_text_fun(weather_now["list"][i]) + if i < weather_now["cnt"] then + weather.notification_text = weather.notification_text .. "\n" + end + end + end + end) + end + + function weather.update() + local cmd = string.format(current_call, city_id, units, lang, APPID) + helpers.async(cmd, function(f) + local pos, err, icon + weather_now, pos, err = json.decode(f, 1, nil) + + if not err and type(weather_now) == "table" and tonumber(weather_now["cod"]) == 200 then + local sunrise = tonumber(weather_now["sys"]["sunrise"]) + local sunset = tonumber(weather_now["sys"]["sunset"]) + local icon = weather_now["weather"][1]["icon"] + local loc_now = os.time() + + if sunrise <= loc_now and loc_now <= sunset then + icon = string.gsub(icon, "n", "d") + else + icon = string.gsub(icon, "d", "n") + end + + weather.icon_path = icons_path .. icon .. ".png" + widget = weather.widget + settings() + else + weather.icon_path = icons_path .. "na.png" + weather.widget:set_markup(weather_na_markup) + end + + weather.icon:set_image(weather.icon_path) + end) + end + + if showpopup == "on" then weather.attach(weather.widget) end + + weather.timer = helpers.newtimer("weather-" .. city_id, timeout, weather.update, false, true) + weather.timer_forecast = helpers.newtimer("weather_forecast-" .. city_id, timeout, weather.forecast_update, false, true) + + return weather +end + +return factory diff --git a/stow_home/awesome/.config/awesome/lain/wiki/Home.md b/stow_home/awesome/.config/awesome/lain/wiki/Home.md new file mode 100644 index 0000000..d098efe --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/Home.md @@ -0,0 +1,43 @@ +Welcome to the Lain wiki! + +If you spot a typo or have a suggestion to improve these pages, please notify me opening an [issue](https://github.com/lcpz/lain/issues) format. Thank you. + +Dependencies +------------ + +Package | Requested by | Reasons of choice +--- | --- | --- +[curl](https://curl.haxx.se) | `imap`, `mpd`, and `weather` widgets | 1. faster and simpler to use than [LuaSocket](https://github.com/diegonehab/luasocket); 2. it's in the core of almost every distro; 3. can be called [asynchronously](https://awesomewm.org/doc/api/libraries/awful.spawn.html#easy_async) +GLib >= 2.54 | `fs` widget | Pure Awesome/Lua implementation. + +The second dependency will be removed once all major distros update their Gio/Glib versions. + +Installation +------------ + +### Arch Linux + +[AUR package](https://aur.archlinux.org/packages/lain-git/) + +### Other distributions + +```shell +git clone https://github.com/lcpz/lain.git ~/.config/awesome/lain +``` + +Also available via [LuaRocks](https://luarocks.org/modules/aajjbb/lain). + +Usage +-------- + +First, include it into your `rc.lua`: + +```lua +local lain = require("lain") +``` + +Then check out the submodules you want: + +- [Layouts](https://github.com/lcpz/lain/wiki/Layouts) +- [Widgets](https://github.com/lcpz/lain/wiki/Widgets) +- [Utilities](https://github.com/lcpz/lain/wiki/Utilities) diff --git a/stow_home/awesome/.config/awesome/lain/wiki/Layouts.md b/stow_home/awesome/.config/awesome/lain/wiki/Layouts.md new file mode 100644 index 0000000..0286d4b --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/Layouts.md @@ -0,0 +1,255 @@ + + lain/layout + . + |-- termfair + |-- termfair.center + |-- cascade + |-- cascade.tile + |-- centerwork + |-- centerwork.horizontal + +Usage +===== + +As usual, specify your favourites in `awful.layout.layouts`, or set them on specific tags with [`awful.layout.set`](https://awesomewm.org/doc/api/libraries/awful.layout.html#set). + +```lua +awful.layout.set(lain.layout.termfair, tag) +``` + +How do layouts work? +==================== + +`termfair` +-------- + +This layout restricts the size of each window. Each window will have the +same width but is variable in height. Furthermore, windows are +left-aligned. The basic workflow is as follows (the number above the +screen is the number of open windows, the number in a cell is the fixed +number of a client): + + (1) (2) (3) + +---+---+---+ +---+---+---+ +---+---+---+ + | | | | | | | | | | | | + | 1 | | | -> | 2 | 1 | | -> | 3 | 2 | 1 | -> + | | | | | | | | | | | | + +---+---+---+ +---+---+---+ +---+---+---+ + + (4) (5) (6) + +---+---+---+ +---+---+---+ +---+---+---+ + | 4 | | | | 5 | 4 | | | 6 | 5 | 4 | + +---+---+---+ -> +---+---+---+ -> +---+---+---+ + | 3 | 2 | 1 | | 3 | 2 | 1 | | 3 | 2 | 1 | + +---+---+---+ +---+---+---+ +---+---+---+ + +The first client will be located in the left column. When opening +another window, this new window will be placed in the left column while +moving the first window into the middle column. Once a row is full, +another row above it will be created. + +Default number of columns and rows are respectively taken from `nmaster` +and `ncol` values in `awful.tag`, but you can set your own. + +For example, this sets `termfair` to 3 columns and at least 1 row: + +```lua +lain.layout.termfair.nmaster = 3 +lain.layout.termfair.ncol = 1 +``` + +`termfair.center` +---------- + +Similar to `termfair`, but with fixed number of vertical columns. Cols are centerded until there are `nmaster` columns, then windows are stacked as slaves, with possibly `ncol` clients per column at most. + + (1) (2) (3) + +---+---+---+ +-+---+---+-+ +---+---+---+ + | | | | | | | | | | | | | + | | 1 | | -> | | 1 | 2 | | -> | 1 | 2 | 3 | -> + | | | | | | | | | | | | | + +---+---+---+ +-+---+---+-+ +---+---+---+ + + (4) (5) + +---+---+---+ +---+---+---+ + | | | 3 | | | 2 | 4 | + + 1 + 2 +---+ -> + 1 +---+---+ + | | | 4 | | | 3 | 5 | + +---+---+---+ +---+---+---+ + +Like `termfair`, default number of columns and rows are respectively taken from `nmaster` +and `ncol` values in `awful.tag`, but you can set your own. + +For example, this sets `termfair.center` to 3 columns and at least 1 row: + +```lua +lain.layout.termfair.center.nmaster = 3 +lain.layout.termfair.center.ncol = 1 +``` + +`cascade` +------- + +Cascade all windows of a tag. + +You can control the offsets by setting these two variables: + +```lua +lain.layout.cascade.offset_x = 64 +lain.layout.cascade.offset_y = 16 +``` + +The following reserves space for 5 windows: + +```lua +lain.layout.cascade.nmaster = 5 +``` + +That is, no window will get resized upon the creation of a new window, +unless there's more than 5 windows. + +`cascade.tile` +----------- + +Similar to `awful.layout.suit.tile` layout, however, clients in the slave +column are cascaded instead of tiled. + +Left column size can be set, otherwise is controlled by `mwfact` of the +tag. Additional windows will be opened in another column on the right. +New windows are placed above old windows. + +Whether the slave column is placed on top of the master window or not is +controlled by the value of `ncol`. A value of 1 means "overlapping slave column" +and anything else means "don't overlap windows". + +Usage example: + +```lua +lain.layout.cascade.tile.offset_x = 2 +lain.layout.cascade.tile.offset_y = 32 +lain.layout.cascade.tile.extra_padding = 5 +lain.layout.cascade.tile.nmaster = 5 +lain.layout.cascade.tile.ncol = 2 +``` + +`extra_padding` reduces the size of the master window if "overlapping +slave column" is activated. This allows you to see if there are any +windows in your slave column. + +Setting `offset_x` to a very small value or even 0 is recommended to avoid wasting space. + +`centerwork` +---------- + +You start with one window, centered horizontally: + + +--------------------------+ + | +----------+ | + | | | | + | | | | + | | | | + | | MAIN | | + | | | | + | | | | + | | | | + | | | | + | +----------+ | + +--------------------------+ + +This is your main working window. You do most of the work right here. +Sometimes, you may want to open up additional windows. They're put on left and right, alternately. + + +--------------------------+ + | +---+ +----------+ +---+ | + | | | | | | | | + | | | | | | | | + | | | | | | | | + | +---+ | MAIN | +---+ | + | +---+ | | +---+ | + | | | | | | | | + | | | | | | | | + | | | | | | | | + | +---+ +----------+ +---+ | + +--------------------------+ + +*Please note:* If you use Awesome's default configuration, navigation in +this layout may be very confusing. How do you get from the main window +to satellite ones depends on the order in which the windows are opened. +Thus, use of `awful.client.focus.bydirection()` is suggested. +Here's an example: + +```lua +globalkeys = awful.util.table.join( + -- [...] + awful.key({ modkey }, "j", + function() + awful.client.focus.bydirection("down") + if client.focus then client.focus:raise() end + end), + awful.key({ modkey }, "k", + function() + awful.client.focus.bydirection("up") + if client.focus then client.focus:raise() end + end), + awful.key({ modkey }, "h", + function() + awful.client.focus.bydirection("left") + if client.focus then client.focus:raise() end + end), + awful.key({ modkey }, "l", + function() + awful.client.focus.bydirection("right") + if client.focus then client.focus:raise() end + end), + -- [...] +) +``` + +`centerwork.horizontal` +----------- + +Same as `centerwork`, except that the main +window expands horizontally, and the additional windows +are put ontop/below it. Useful if you have a screen turned 90°. + +Pre 4.0 `uselesstile` patches +============================= + +In branch 3.5, this module provided useless gaps layouts. Since useless gaps have been implemented in Awesome 4.0, those layouts have been removed. + +Following are a couple of `uselesstile` variants that were not part of lain. They are kept only for reference and are not supported. + +Xmonad-like +----------- + +If you want to have `awful.layout.suit.tile` behave like xmonad, with internal gaps two times wider than external ones, download [this](https://gist.github.com/lcpz/9e56dcfbe66bfe14967c) as `lain/layout/uselesstile`. + +Inverted master +--------------- + +Want to invert master window position? Use [this](https://gist.github.com/lcpz/c59dc59c9f99d98218eb) version. You can set `single_gap` with `width` and `height` in your `theme.lua`, in order to define the window geometry when there's only one client, otherwise it goes maximized. An example: + + theme.single_gap = { width = 600, height = 100 } + +What about layout icons? +======================== + +They are located in ``lain/icons/layout``. + +To use them, define new `layout_*` variables in your ``theme.lua``. For instance: + +```lua +theme.lain_icons = os.getenv("HOME") .. + "/.config/awesome/lain/icons/layout/default/" +theme.layout_termfair = theme.lain_icons .. "termfair.png" +theme.layout_centerfair = theme.lain_icons .. "centerfair.png" -- termfair.center +theme.layout_cascade = theme.lain_icons .. "cascade.png" +theme.layout_cascadetile = theme.lain_icons .. "cascadetile.png" -- cascade.tile +theme.layout_centerwork = theme.lain_icons .. "centerwork.png" +theme.layout_centerworkh = theme.lain_icons .. "centerworkh.png" -- centerwork.horizontal +``` + +Credit goes to [Nicolas Estibals](https://github.com/nestibal) for creating +layout icons for default theme. + +You can use them as a template for your custom versions. \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/wiki/Utilities.md b/stow_home/awesome/.config/awesome/lain/wiki/Utilities.md new file mode 100644 index 0000000..4ec3057 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/Utilities.md @@ -0,0 +1,338 @@ +Quake +----- + +A Quake-like dropdown container for your favourite application. + +**Usage** + +Define it globally to have a single instance for all screens: + +```lua +local quake = lain.util.quake() +``` + +or define it in `connect_for_each_screen` to have one instance for each screen: + +```lua +awful.screen.connect_for_each_screen(function(s) + -- Quake application + s.quake = lain.util.quake() + -- [...] +``` + +**Keybinding example** + +If using a global instance: +```lua +awful.key({ modkey, }, "z", function () quake:toggle() end), +``` + +If using a per-screen instance: +```lua +awful.key({ modkey, }, "z", function () awful.screen.focused().quake:toggle() end), +``` + +**Input table** + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`app` | client to spawn | string | "xterm" +`name` | client name | string | "QuakeDD" +`argname` | how to specify client name | string | "-name %s" +`extra` | extra `app` arguments | string | empty string +`border` | border width | integer | 1 +`visible` | initially visible | boolean | false +`followtag` | always spawn on currently focused screen | boolean | false +`overlap` | Overlap the wibox or not | boolean | false +`settings` | Additional settings to make on the client | function | `nil` +`screen` | screen where to spawn the client | integer | `awful.screen.focused()` +`height` | dropdown client height | float in [0,1] or exact pixels number | 0.25 +`width` | dropdown client width | float in [0,1] or exact pixels number | 1 +`vert` | vertical position | string, possible values: "top", "bottom", "center" | "top" +`horiz` | horizontal position | string, possible values: "left", "right", "center" | "left" + +`height` and `width` express a fraction of the workspace. + +`settings` is a function which takes the client as input, and can be used to customize its properties. For instance: + +```lua +-- set the client sticky +s.quake = lain.util.quake { settings = function(c) c.sticky = true end } +``` + +Read [here](https://awesomewm.org/doc/api/classes/client.html#Object_properties) for the complete list of properties. + +**Notes** + +* [Does not work](https://github.com/lcpz/lain/issues/358) with `gnome-terminal`, `konsole`, or any other terminal which is strictly designed for a Desktop Environment. Just pick a better terminal, [there's plenty](https://wiki.archlinux.org/index.php/List_of_applications#Terminal_emulators). +* Set `followtag = true` if [experiencing issues with multiple screens](https://github.com/lcpz/lain/issues/346). +* If you have a `awful.client.setslave` rule for your application, ensure you use an exception for `QuakeDD` (or your defined `name`). Otherwise, you may run into problems with focus. +* If you are using a VTE-based terminal like `termite`, be sure to set [`argname = "--name %s"`](https://github.com/lcpz/lain/issues/211). + +Separators +---------- + +Adds Cairo separators. + +```lua +local separators = lain.util.separators +``` + +A separator function `separators.separator` takes two color arguments, defined as strings. `"alpha"` argument is allowed. Example: + +```lua +arrl_dl = separators.arrow_left(beautiful.bg_focus, "alpha") +arrl_ld = separators.arrow_left("alpha", beautiful.bg_focus) +``` + +You can customize height and width by setting `separators_height` and `separators_width` in your `theme.lua`. Default values are 0 and 9, respectively. + +List of functions: + + +-- separators + | + |`-- arrow_right() Draw a right arrow. + `-- arrow_left() Draw a left arrow. + +markup +------ + +Mades markup easier. + +```lua +local markup = lain.util.markup +``` + +List of functions: + + +-- markup + | + |`-- bold() Set bold. + |`-- italic() Set italicized text. + |`-- strike() Set strikethrough text. + |`-- underline() Set underlined text. + |`-- monospace() Set monospaced text. + |`-- big() Set bigger text. + |`-- small() Set smaller text. + |`-- font() Set the font of the text. + |`-- font() Set the font of the text. + |`-- color() Set background and foreground color. + |`-- fontfg() Set font and foreground color. + |`-- fontbg() Set font and background color. + `-- fontcolor() Set font, plus background and foreground colors. + | + |`--+ bg + | | + | `-- color() Set background color. + | + `--+ fg + | + `-- color() Set foreground color. + +they all take one argument, which is the text to markup, except the following: + +```lua +markup.font(font, text) +markup.color(fg, bg, text) +markup.fontfg(font, fg, text) +markup.fontbg(font, bg, text) +markup.fontcolor(font, fg, bg, text) +markup.fg.color(color, text) +markup.bg.color(color, text) +``` + +Dynamic tagging +--------------- + +That is: + +- add a new tag; +- rename current tag; +- move current tag; +- delete current tag. + +If you delete a tag, any rule set on it shall be broken, so be careful. + +Use it with key bindings like these: + +```lua +awful.key({ modkey, "Shift" }, "n", function () lain.util.add_tag(mylayout) end), +awful.key({ modkey, "Shift" }, "r", function () lain.util.rename_tag() end), +awful.key({ modkey, "Shift" }, "Left", function () lain.util.move_tag(1) end), -- move to next tag +awful.key({ modkey, "Shift" }, "Right", function () lain.util.move_tag(-1) end), -- move to previous tag +awful.key({ modkey, "Shift" }, "d", function () lain.util.delete_tag() end), +``` + +The argument in `lain.util.add_tag` represents the tag layout, and is optional: if not present, it will be defaulted to `awful.layout.suit.tile`. + +Useless gaps resize +--------------------- + +Changes `beautiful.useless_gaps` on the fly. + +```lua +lain.util.useless_gap_resize(thatmuch, s, t) +``` + +The argument `thatmuch` is the number of pixel to add to/substract from gaps (integer). + +The arguments `s` and `t` are the `awful.screen` and `awful.tag` in which you want to change the gap. They are optional. + +Following are example keybindings for changing client gaps on current screen and tag. + +Example 1: + +```lua +-- On the fly useless gaps change +awful.key({ altkey, "Control" }, "+", function () lain.util.useless_gaps_resize(1) end), +awful.key({ altkey, "Control" }, "-", function () lain.util.useless_gaps_resize(-1) end), +``` + +where `altkey = Mod1`. Example 2: + +```lua +mywidget:buttons(awful.util.table.join ( + awful.button({}, 4, function() lain.util.useless_gaps_resize(-1) end), + awful.button({}, 5, function() lain.util.useless_gaps_resize(1) end) + end) +)) +``` + +so when hovering the mouse over `mywidget`, you can adjust useless gaps size by scrolling with the mouse wheel. + +tag\_view\_nonempty +------------------- + +This function lets you jump to the next/previous non-empty tag. +It takes two arguments: + +* `direction`: `1` for next non-empty tag, `-1` for previous. +* `sc`: Screen which the taglist is in. Default is `mouse.screen` or `1`. This + argument is optional. + +You can use it with key bindings like these: + +```lua +-- Non-empty tag browsing +awful.key({ altkey }, "Left", function () lain.util.tag_view_nonempty(-1) end), +awful.key({ altkey }, "Right", function () lain.util.tag_view_nonempty(1) end), +``` + +where `altkey = "Mod1"`. + +magnify\_client +--------------- + +Set a client to floating and resize it in the same way the "magnifier" +layout does it. Place it on the "current" screen (derived from the mouse +position). This allows you to magnify any client you wish, regardless of +the currently used layout. Use it with a client keybinding like this: + +```lua +clientkeys = awful.util.table.join( + -- [...] + awful.key({ modkey, "Control" }, "m", lain.util.magnify_client), + -- [...] +) +``` + +If you want to "de-magnify" it, just retype the keybinding. + +If you want magnified client to respond to `incmwfact`, read [here](https://github.com/lcpz/lain/issues/195). + +menu\_clients\_current\_tags +---------------------------- + +Similar to `awful.menu.clients`, but this menu only shows the clients +of currently visible tags. Use it with a key binding like this: + +```lua +awful.key({ "Mod1" }, "Tab", function() + lain.util.menu_clients_current_tags({ width = 350 }, { keygrabber = true }) +end), +``` + +menu\_iterator +-------------- + +A generic menu utility which enables iteration over lists of possible +actions to execute. The perfect example is a menu for choosing what +configuration to apply to X with `xrandr`, as suggested on the [Awesome wiki page](https://awesomewm.org/recipes/xrandr). + +

+ +
An example Synergy menu, courtesy of sim590 +

+ +You can either manually create a menu by defining a table in this format: + +```lua +{ { "choice description 1", callbackFuction1 }, { "choice description 2", callbackFunction2 }, ... } +``` + +or use `lain.util.menu_iterator.menu`. Once you have your menu, use it with `lain.menu_iterator.iterate`. + +### Input tables + +**lain.menu_iterator.iterate** + +| Argument | Description | Type +|---|---| --- +| `menu` | the menu to iterate on | table +| `timeout` | time (in seconds) to wait on a choice before the choice is accepted | integer (default: 4) +| `icon` | path to the icon to display in `naughty.notify` window | string + +**lain.menu_iterator.menu** + +| Argument | Description | Type +|---|---| --- +`choices` | list of choices (e.g., `{ "choice1", "choice2", ... }`) | array of strings +`name` | name of the program related to this menu | string +`selected_cb` | callback to execute for each selected choice, it takes one choice (string) as argument; can be `nil` (no action to execute) | function +`rejected_cb` | callback to execute for all rejected choices (the remaining choices, once one is selected), it takes one choice (string) as argument; can be `nil` (no action to execute) | function +`extra_choices` | more choices to be added to the menu; unlike `choices`, these ones won't trigger `rejected_cb` | array of `{ choice, callback }` pairs, where `choice` is a string and `callback` is a function +`combination` | how choices have to be combined in the menu; possible values are: "single" (default), the set of possible choices will simply be the input set ; "powerset", the set of possible choices will be the [power set](https://en.wikipedia.org/wiki/Power_set) of the input set | string + +### Examples + +A simple example is: + +```lua +local mymenu_iterable = lain.util.menu_iterator.menu { + choices = {"My first choice", "My second choice"}, + name = "My awesome program", + selected_cb = function(choice) + -- do something with selected choice + end, + rejected_cb = function(choice) + -- do something with every rejected choice + end +} +``` + +The variable `mymenu_iterable` is a menu compatible with the function `lain.util.menu_iterator.iterate`, which will iterate over it and displays notification with `naughty.notify` every time it is called. You can use it like this: + +```lua +local confirm_timeout = 5 -- time to wait before confirming the menu selection +local my_notify_icon = "/path/to/icon" -- the icon to display in the notification +lain.util.menu_iterator.iterate(mymenu_iterable, confirm_timeout, my_notify_icon) +``` + +Once `confirm_timeout` has passed without anymore calls to `iterate`, the choice is made and the associated callbacks (both for selected and rejected choices) are spawned. + +A useful practice is to add a `Cancel` option as an extra choice for canceling a menu selection. Extending the above example: + +```lua +local mymenu_iterable = lain.util.menu_iterator.menu { + choices = {"My first choice", "My second choice"}, + name = "My awesome program", + selected_cb = function(choice) + -- do something with selected choice + end, + rejected_cb = function(choice) + -- do something with every rejected choice + end + -- nil means no action to do + extra_choices = { {"Cancel"}, nil } +} +``` diff --git a/stow_home/awesome/.config/awesome/lain/wiki/Widgets.md b/stow_home/awesome/.config/awesome/lain/wiki/Widgets.md new file mode 100644 index 0000000..34f518d --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/Widgets.md @@ -0,0 +1,55 @@ +# Usage + +Every lain widget is a table. + +A lain widget is generated by a `function`. + +The `function` signature, input and output arguments can be found in the [related wiki entry](https://github.com/lcpz/lain/wiki/Widgets#index). + +Every lain widget contains a `wibox.widget`, which is updated by a timed function. To access the widget, use the field `widget`, while to access the timed function, use the field `update`. Some lain widgets may also have an `icon` field, which is a `wibox.widget.imagebox`, and/or a `timer` field, which is the `gears.timer` on `update`. + +Every `function` may take either a table or a list of variables as input. + +If the input is a table, you must define a function variable called `settings` in it. There you will be able to define `widget` appearance. + +For instance, if `widget` is a textbox, to markup it call `widget:set_markup(...)` within `settings`. + +In the scope of `settings` you can use predefined arguments, which are specified in the wiki entries. + +Example of a lain widget: + +```lua +local cpu = lain.widget.cpu { + settings = function() + widget:set_markup("Cpu " .. cpu_now.usage) + end +} +-- to access the widget: cpu.widget +``` + +If you want to see some applications, check [awesome-copycats](https://github.com/lcpz/awesome-copycats). + +# Index + +- [alsa](https://github.com/lcpz/lain/wiki/alsa) +- [alsabar](https://github.com/lcpz/lain/wiki/alsabar) +- [bat](https://github.com/lcpz/lain/wiki/bat) +- [cal](https://github.com/lcpz/lain/wiki/cal) +- [cpu](https://github.com/lcpz/lain/wiki/cpu) +- [fs](https://github.com/lcpz/lain/wiki/fs) +- [imap](https://github.com/lcpz/lain/wiki/imap) +- [mem](https://github.com/lcpz/lain/wiki/mem) +- [mpd](https://github.com/lcpz/lain/wiki/mpd) +- [net](https://github.com/lcpz/lain/wiki/net) +- [pulse](https://github.com/lcpz/lain/wiki/pulse) +- [pulsebar](https://github.com/lcpz/lain/wiki/pulsebar) +- [sysload](https://github.com/lcpz/lain/wiki/sysload) +- [temp](https://github.com/lcpz/lain/wiki/temp) +- [weather](https://github.com/lcpz/lain/wiki/weather) + +## Users contributed + +- [moc](https://github.com/lcpz/lain/wiki/moc) +- [redshift](https://github.com/lcpz/lain/wiki/redshift) +- [task](https://github.com/lcpz/lain/wiki/task) +- [tp_smapi](https://github.com/lcpz/lain/wiki/tp_smapi) diff --git a/stow_home/awesome/.config/awesome/lain/wiki/_Footer.md b/stow_home/awesome/.config/awesome/lain/wiki/_Footer.md new file mode 100644 index 0000000..b64f13b --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/_Footer.md @@ -0,0 +1 @@ +[Home](https://github.com/lcpz/lain/wiki) • [Layouts](https://github.com/lcpz/lain/wiki/Layouts) • [Widgets](https://github.com/lcpz/lain/wiki/Widgets) • [Utilities](https://github.com/lcpz/lain/wiki/Utilities) diff --git a/stow_home/awesome/.config/awesome/lain/wiki/_Sidebar.md b/stow_home/awesome/.config/awesome/lain/wiki/_Sidebar.md new file mode 100644 index 0000000..0289783 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/_Sidebar.md @@ -0,0 +1,26 @@ +* [Home](https://github.com/lcpz/lain/wiki/Home) +* [Layouts](https://github.com/lcpz/lain/wiki/Layouts) + * [Usage](https://github.com/lcpz/lain/wiki/Layouts#Usage) + * [How do layouts work?](https://github.com/lcpz/lain/wiki/Layouts#how-do-layouts-work) + * [termfair](https://github.com/lcpz/lain/wiki/Layouts#termfair) + * [centerfair](https://github.com/lcpz/lain/wiki/Layouts#termfaircenter) + * [cascade](https://github.com/lcpz/lain/wiki/Layouts#cascade) + * [cascadetile](https://github.com/lcpz/lain/wiki/Layouts#cascadetile) + * [centerwork](https://github.com/lcpz/lain/wiki/Layouts#centerwork) + * [centerworkh](https://github.com/lcpz/lain/wiki/Layouts#centerworkhorizontal) + * [Pre 4.0 uselesstile patches](https://github.com/lcpz/lain/wiki/Layouts#pre-40-uselesstile-patches) + * [What about layout icons?](https://github.com/lcpz/lain/wiki/Layouts#what-about-layout-icons) +* [Widgets](https://github.com/lcpz/lain/wiki/Widgets) + * [Usage](https://github.com/lcpz/lain/wiki/Widgets#usage) + * [Index](https://github.com/lcpz/lain/wiki/Widgets#index) + * [Users contributed](https://github.com/lcpz/lain/wiki/Widgets#users-contributed) +* [Utilities](https://github.com/lcpz/lain/wiki/Utilities) + * [quake](https://github.com/lcpz/lain/wiki/Utilities#quake) + * [separators](https://github.com/lcpz/lain/wiki/Utilities#separators) + * [markup](https://github.com/lcpz/lain/wiki/Utilities#markup) + * [dynamic tagging](https://github.com/lcpz/lain/wiki/Utilities#dynamic-tagging) + * [useless_gaps_resize](https://github.com/lcpz/lain/wiki/Utilities#useless-gaps-resize) + * [tag_view_non_empty](https://github.com/lcpz/lain/wiki/Utilities#tag_view_nonempty) + * [magnify_client](https://github.com/lcpz/lain/wiki/Utilities#magnify_client) + * [menu_clients_current_tags](https://github.com/lcpz/lain/wiki/Utilities#menu_clients_current_tags) + * [menu_iterator](https://github.com/lcpz/lain/wiki/Utilities#menu_iterator) diff --git a/stow_home/awesome/.config/awesome/lain/wiki/alsa.md b/stow_home/awesome/.config/awesome/lain/wiki/alsa.md new file mode 100644 index 0000000..9c1e5c4 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/alsa.md @@ -0,0 +1,148 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows ALSA volume. + +```lua +local volume = lain.widget.alsa() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 5 +`cmd` | Alsa mixer command | string | "amixer" +`channel` | Mixer channel | string | "Master" +`togglechannel` | Toggle channel | string | `nil` +`settings` | User settings | function | empty function + +`cmd` is useful if you need to pass additional arguments to amixer. For instance, you may want to define `cmd = "amixer -c X"` in order to set amixer with card `X`. + +`settings` can use the following variables: + +Variable | Meaning | Type | Values +--- | --- | --- | --- +`volume_now.level` | Volume level | integer | 0-100 +`volume_now.status` | Device status | string | "on", "off" + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`channel` | ALSA channel | string +`update` | Update `widget` | function + +## Toggle channel + +In case mute toggling can't be mapped to master channel (this happens, for instance, when you are using an HDMI output), define togglechannel as your S/PDIF device. You can get the device ID with `scontents` command. + +For instance, if card number is 1 and S/PDIF number is 3: + +```shell +$ amixer -c 1 scontents +Simple mixer control 'Master',0 + Capabilities: volume + Playback channels: Front Left - Front Right + Capture channels: Front Left - Front Right + Limits: 0 - 255 + Front Left: 255 [100%] + Front Right: 255 [100%] +Simple mixer control 'IEC958',0 + Capabilities: pswitch pswitch-joined + Playback channels: Mono + Mono: Playback [on] +Simple mixer control 'IEC958',1 + Capabilities: pswitch pswitch-joined + Playback channels: Mono + Mono: Playback [on] +Simple mixer control 'IEC958',2 + Capabilities: pswitch pswitch-joined + Playback channels: Mono + Mono: Playback [on] +Simple mixer control 'IEC958',3 + Capabilities: pswitch pswitch-joined + Playback channels: Mono + Mono: Playback [on] +``` + +you have to set `togglechannel = "IEC958,3"`. + +## Buttons + +If you want buttons, just add the following after your widget in `rc.lua`. + +```lua +volume.widget:buttons(awful.util.table.join( + awful.button({}, 1, function() -- left click + awful.spawn(string.format("%s -e alsamixer", terminal)) + end), + awful.button({}, 2, function() -- middle click + os.execute(string.format("%s set %s 100%%", volume.cmd, volume.channel)) + volume.update() + end), + awful.button({}, 3, function() -- right click + os.execute(string.format("%s set %s toggle", volume.cmd, volume.togglechannel or volume.channel)) + volume.update() + end), + awful.button({}, 4, function() -- scroll up + os.execute(string.format("%s set %s 1%%+", volume.cmd, volume.channel)) + volume.update() + end), + awful.button({}, 5, function() -- scroll down + os.execute(string.format("%s set %s 1%%-", volume.cmd, volume.channel)) + volume.update() + end) +)) +``` + +## Keybindings + +You can control the widget with keybindings like these: + +```lua +-- ALSA volume control +awful.key({ altkey }, "Up", + function () + os.execute(string.format("amixer set %s 1%%+", volume.channel)) + volume.update() + end), +awful.key({ altkey }, "Down", + function () + os.execute(string.format("amixer set %s 1%%-", volume.channel)) + volume.update() + end), +awful.key({ altkey }, "m", + function () + os.execute(string.format("amixer set %s toggle", volume.togglechannel or volume.channel)) + volume.update() + end), +awful.key({ altkey, "Control" }, "m", + function () + os.execute(string.format("amixer set %s 100%%", volume.channel)) + volume.update() + end), +awful.key({ altkey, "Control" }, "0", + function () + os.execute(string.format("amixer set %s 0%%", volume.channel)) + volume.update() + end), +``` + +where `altkey = "Mod1"`. + +### Muting with PulseAudio + +If you are using this widget in conjuction with PulseAudio, add the option `-D pulse` to the muting keybinding, like this: + +```lua +awful.key({ altkey }, "m", + function () + os.execute(string.format("amixer -D pulse set %s toggle", volume.togglechannel or volume.channel)) + volume.update() + end), +``` diff --git a/stow_home/awesome/.config/awesome/lain/wiki/alsabar.md b/stow_home/awesome/.config/awesome/lain/wiki/alsabar.md new file mode 100644 index 0000000..a986d8f --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/alsabar.md @@ -0,0 +1,108 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows ALSA volume with a progressbar; provides tooltips and notifications. + +```lua +local volume = lain.widget.alsabar() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 5 +`settings` | User settings | function | empty function +`width` | Bar width | number | 63 +`height` | Bar height | number | 1 +`margins` | Bar margins | number | 1 +`paddings` | Bar paddings | number | 1 +`ticks` | Set bar ticks on | boolean | false +`ticks_size` | Ticks size | integer | 7 +`tick` | String for a notification tick | string | "|" +`tick_pre` | String for the left notification delimeter | string | "[" +`tick_post` | String for the right notification delimeter | string | "]" +`tick_none` | String for an empty notification tick | string | " " +`cmd` | ALSA mixer command | string | "amixer" +`channel` | Mixer channel | string | "Master" +`togglechannel` | Toggle channel | string | `nil` +`tick` | The character usef for ticks in the notification | string | "|" +`colors` | Bar colors | table | see [Default colors](https://github.com/lcpz/lain/wiki/alsabar#default-colors) +`notification_preset` | Notification preset | table | See [default `notification_preset`](https://github.com/lcpz/lain/wiki/alsabar#default-notification_preset) +`followtag` | Display the notification on currently focused screen | boolean | false + +`cmd` is useful if you need to pass additional arguments to `amixer`. For instance, you may want to define `cmd = "amixer -c X"` in order to set amixer with card `X`. + +In case mute toggling can't be mapped to master channel (this happens, for instance, when you are using an HDMI output), define `togglechannel` as your S/PDIF device. Read [`alsa`](https://github.com/lcpz/lain/wiki/alsa#toggle-channel) page to know how. + +To set the maximum number of ticks to display in the notification, define `max_ticks` (integer) in `notification_preset`. + +`settings` can use the following variables: + +Variable | Meaning | Type | Values +--- | --- | --- | --- +`volume_now.level` | Volume level | integer | 0-100 +`volume_now.status` | Device status | string | "on", "off" + +With multiple screens, the default behaviour is to show a visual notification pop-up window on the first screen. By setting `followtag` to `true` it will be shown on the currently focused tag screen. + +### Default colors + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`background` | Bar backgrund color | string | "#000000" +`mute` | Bar mute color | string | "#EB8F8F" +`unmute` | Bar unmute color | string | "#A4CE8A" + +### Default `notification_preset` + +```lua +notification_preset = { + font = "Monospace 10" +} +``` + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`bar` | The widget | `wibox.widget.progressbar` +`channel` | ALSA channel | string +`notify` | The notification | function +`update` | Update `bar` | function +`tooltip` | The tooltip | `awful.tooltip` + +## Buttons + +If you want buttons, just add the following after your widget in `rc.lua`. + +```lua +volume.bar:buttons(awful.util.table.join( + awful.button({}, 1, function() -- left click + awful.spawn(string.format("%s -e alsamixer", terminal)) + end), + awful.button({}, 2, function() -- middle click + os.execute(string.format("%s set %s 100%%", volume.cmd, volume.channel)) + volume.update() + end), + awful.button({}, 3, function() -- right click + os.execute(string.format("%s set %s toggle", volume.cmd, volume.togglechannel or volume.channel)) + volume.update() + end), + awful.button({}, 4, function() -- scroll up + os.execute(string.format("%s set %s 1%%+", volume.cmd, volume.channel)) + volume.update() + end), + awful.button({}, 5, function() -- scroll down + os.execute(string.format("%s set %s 1%%-", volume.cmd, volume.channel)) + volume.update() + end) +)) +``` + +## Keybindings + +Read [here](https://github.com/lcpz/lain/wiki/alsa#keybindings). If you want notifications, use `volume.notify()` instead of `volume.update()`. diff --git a/stow_home/awesome/.config/awesome/lain/wiki/bat.md b/stow_home/awesome/.config/awesome/lain/wiki/bat.md new file mode 100644 index 0000000..fb98166 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/bat.md @@ -0,0 +1,100 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows the remaining time and percentage capacity of your laptop battery, as well +as the current wattage. Multiple batteries are supported. + +Displays a notification when battery is fully charged, low, or critical. + +```lua +local mybattery = lain.widget.bat() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 30 +`pspath` | Power supply directory path | string | "/sys/class/power_supply/" +`battery` | Single battery id | string | autodetected +`batteries` | Multiple batteries id table | table of strings | autodetected +`ac` | AC | string | autodetected +`notify` | Show notification popups | string | "on" +`full_notify` | Show a notification popup when the battery's fully charged | string | inherited value from `notify` +`n_perc` | Percentages assumed for critical and low battery levels | table of integers | `{5, 15}` +`settings` | User settings | function | empty function + +The widget will try to autodetect `battery`, `batteries` and `ac`. If something +goes wrong, you will have to define them manually. In that case, you only have +to define one between `battery` and `batteries`. If you have one battery, you +can either use `args.battery = "BAT*"` or `args.batteries = {"BAT*"}`, where `BAT*` +is the identifier of your battery in `pspath` (do not use it as a wildcard). +Of course, if you have multiple batteries, you need to use the latter option. + +To disable notifications, set `notify` to `"off"`. + +If you define `pspath`, **be sure** to not forget the final slash (/). + +`settings` can use the `bat_now` table, which contains the following strings: + +- `status`, general status ("N/A", "Discharging", "Charging", "Full"); +- `n_status[i]`, i-th battery status (like above); +- `ac_status`, AC-plug flag (0 if cable is unplugged, 1 if plugged, "N/A" otherwise); +- `perc`, total charge percentage (integer between 0 and 100 or "N/A"); +- `n_perc[i]`, i-th battery charge percentage (like above); +- `time`, time remaining until charge if charging, until discharge if discharging (HH:MM string or "N/A"); +- `watt`, battery watts (float with 2 decimals). + +and can modify the following three tables, which will be the preset for the naughty notifications: +* `bat_notification_charged_preset` (used if battery is fully charged and connected to AC) +* `bat_notification_low_preset` (used if battery charge level <= 15) +* `bat_notification_critical_preset` (used if battery charge level <= 5) + +Check [here](https://awesomewm.org/doc/api/libraries/naughty.html#notify) for +the list of variables they can contain. Default definitions: + +```lua +bat_notification_charged_preset = { + title = "Battery full", + text = "You can unplug the cable", + timeout = 15, + fg = "#202020", + bg = "#CDCDCD" + } + +``` + +```lua +bat_notification_low_preset = { + title = "Battery low", + text = "Plug the cable!", + timeout = 15, + fg = "#202020", + bg = "#CDCDCD" +} +``` +```lua +bat_notification_critical_preset = { + title = "Battery exhausted", + text = "Shutdown imminent", + timeout = 15, + fg = "#000000", + bg = "#FFFFFF" +} +``` + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`update` | Update `widget` | function + +The `update` function can be used to refresh the widget before `timeout` expires. + +## Note + +Alternatively, you can try the [`upower` recipe](https://awesomewm.org/recipes/watch). diff --git a/stow_home/awesome/.config/awesome/lain/wiki/cal.md b/stow_home/awesome/.config/awesome/lain/wiki/cal.md new file mode 100644 index 0000000..3e14bf5 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/cal.md @@ -0,0 +1,83 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Creates a calendar notification that can be attached to widgets. + +This is a simpler but [faster](https://github.com/awesomeWM/awesome/issues/1861) +alternative to [`awful.widget.calendar_popup`](https://awesomewm.org/doc/api/classes/awful.widget.calendar_popup.html), which emulates UNIX's `cal`. + +```lua +local mycal = lain.widget.cal() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`attach_to` | List of widgets | table | empty table +`week_start` | First day of the week | integer | 2 (Monday) +`three` | Display three months spanning the date | boolean | false +`followtag` | Display the notification on currently focused screen | boolean | false +`week_number` | Display the week number | string ("none", "left" or "right") | "none" +`week_number_format` | Week number format | string | `"%3d \| "` for "left", `"\| %-3d"` for "right" +`icons` | Path to calendar icons | string | [icons/cal/white/](https://github.com/lcpz/lain/tree/master/icons/cal/white) +`notification_preset` | Notification preset | table | See [default `notification_preset`](https://github.com/lcpz/lain/wiki/calendar#default-notification_preset) + +Set `attach_to` as the list of widgets to which you want to attach the calendar, like this: + +```lua +local mycal = lain.widget.cal { + attach_to = { mywidget1, mywidget2, ... }, + -- [...] +} +``` + +For every widget in `attach_to`: + +- Left click / scroll down: switch to previous month. +- Middle click show current month. +- Right click / scroll up: switch to next month. + +With multiple screens, the default behaviour is to show a visual notification pop-up window on the first screen. By setting `followtag` to `true` it will be shown on the currently focused tag screen. + +### Default `notification_preset` + +```lua +notification_preset = { + font = "Monospace 10", + fg = "#FFFFFF", + bg = "#000000" +} +``` + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`attach` | Attach the calendar to an input widget | function +`show` | Show calendar | function +`hide` | Hide calendar | function + +`attach` takes as argument any widget you want to attach the calendar to, while +`show` takes as optional argument an integer to indicate the seconds to timeout. + +## Keybinding + +```lua +awful.key({ altkey }, "c", function () mycal.show(7) end) +``` + +Where `altkey = "Mod1"`. + +## Notes + +* Naughty notifications require `notification_preset.font` to be **monospaced**, in order to correctly display the output. +* If you want to [disable notification icon](https://github.com/lcpz/lain/pull/351), set `icons = ""` in the input table. +* If you want to localise the calendar, put `os.setlocale(os.getenv("LANG"))` in your `rc.lua`. +* If you want to get notifications [only with mouse clicks](https://github.com/lcpz/lain/issues/320) on a given widget, use this code: + ```lua + yourwidget:disconnect_signal("mouse::enter", mycal.hover_on) + ``` diff --git a/stow_home/awesome/.config/awesome/lain/wiki/cpu.md b/stow_home/awesome/.config/awesome/lain/wiki/cpu.md new file mode 100644 index 0000000..c13d05a --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/cpu.md @@ -0,0 +1,30 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows the current CPU usage, both in general and per core. + +```lua +local mycpu = lain.widget.cpu() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 2 +`settings` | User settings | function | empty function + +`settings` can use these strings: + +* `cpu_now.usage`, the general use percentage; +* `cpu_now[i].usage`, the i-th core use percentage, with `i` starting from 1. + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`update` | Update `widget` | function \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/wiki/fs.md b/stow_home/awesome/.config/awesome/lain/wiki/fs.md new file mode 100644 index 0000000..47d6bb2 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/fs.md @@ -0,0 +1,82 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows file systems informations. + +If a partition is given in input, a notification will be displayed when it is almost full. + +```lua +local mypartition = lain.widget.fs() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 600 +`partition` | (Optional) Partition to watch: a notification will be displayed when full | string | `nil` +`threshold` | Percentage threshold at which the notification is triggered | integer | 99 +`notification_preset` | Notification preset | table | See [default `notification_preset`](https://github.com/lcpz/lain/wiki/fs#default-notification_preset) +`followtag` | Display the notification on currently focused screen | boolean | false +`showpopup` | Display popups with mouse hovering | string, possible values: "on", "off" | "on" +`settings` | User settings | function | empty function + +`settings` can use the table `fs_now`, which contains a string entry for each file system path available. For instance, root infos are located in the variable `fs_now["/"]`. Every entry in this table have the following variables: + +Variable | Meaning | Type +--- | --- | --- +`units` | (multiple of) units used | string ("Kb", "Mb", "Gb", and so on) +`percentage` | the used percentage | integer +`size` | size in `units` of the given fs | float +`used` | amount of space used in the given fs, expressed in `units` | float +`free` | amount of free space in the given fs, expressed in `units` | float + +Usage example: + +```lua +-- shows used (percentage) and remaining space in home partition +local fsroothome = lain.widget.fs({ + settings = function() + widget:set_text("/home: " .. fs_now["/home"].percentage .. "% (" .. + fs_now["/home"].free .. " " .. fs_now["/home"].units .. " left)") + end +}) +-- output example: "/home: 37% (239.4 Gb left)" +``` + +With multiple screens, the default behaviour is to show a visual notification pop-up window on the first screen. By setting `followtag` to `true` it will be shown on the currently focused tag screen. + +### Default `notification_preset` + +```lua +notification_preset = { + font = "Monospace 10", + fg = "#FFFFFF", + bg = "#000000" +} +``` + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`show` | The notification | function + +You can display the notification with a key binding like this: + +```lua +awful.key({ altkey }, "h", function () mypartition.show(seconds, scr) end), +``` + +where ``altkey = "Mod1"`` and ``show`` arguments, both optionals, are: + +* `seconds`, notification time in seconds +* `scr`, screen which to display the notification in + +## Note + +Naughty notifications require `notification_preset.font` to be **monospaced**, in order to correctly display the output. diff --git a/stow_home/awesome/.config/awesome/lain/wiki/imap.md b/stow_home/awesome/.config/awesome/lain/wiki/imap.md new file mode 100644 index 0000000..683777e --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/imap.md @@ -0,0 +1,115 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows mails count fetching over IMAP. + +```lua +local myimap = lain.widget.imap(args) +``` + +New mails are notified like this: + + +--------------------------------------------+ + | +---+ | + | |\ /| donald@disney.org has 3 new messages | + | +---+ | + +--------------------------------------------+ + +## Input table + +Required parameters are: + +Variable | Meaning | Type +--- | --- | --- +`server` | Mail server | string +`mail` | User mail | string +`password` | User password | string + +while the optional are: + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`port` | IMAP port | integer | 993 +`timeout` | Refresh timeout (in seconds) | integer | 60 +`pwdtimeout` | Timeout for password retrieval function (see [here](https://github.com/lcpz/lain/wiki/imap#password-security)) | integer | 10 +`is_plain` | Define whether `password` is a plain password (true) or a command that retrieves it (false) | boolean | false +`followtag` | Notification behaviour | boolean | false +`notify` | Show notification popups | string | "on" +`settings` | User settings | function | empty function + +`settings` can use `imap_now` table, which contains the following non negative integers: + +- `["MESSAGES"]` +- `["RECENT"]` +- `["UNSEEN"]` + +example of fetch: `total = imap_now["MESSAGES"]`. For backwards compatibility, `settings` can also use `mailcount`, a pointer to `imap_now["UNSEEN"]`. + +Also, `settings` can modify `mail_notification_preset` table, which will be the preset for the naughty notifications. Check [here](https://awesomewm.org/apidoc/libraries/naughty.html#notify) for the list of variables it can contain. Default definition: + +```lua +mail_notification _preset = { + icon = "lain/icons/mail.png", + position = "top_left" +} +``` + +Note that `mailcount` and `imap_now` elements are equals to 0 either if there are no new mails or credentials are invalid, so make sure that your settings are correct. + +With multiple screens, the default behaviour is to show a visual notification pop-up window on the first screen. By setting `followtag` to `true` it will be shown on the currently focused tag screen. + +You can have multiple instances of this widget at the same time. + +## Password security + +The reason why `is_plain` is false by default is to discourage the habit of storing passwords in plain. + +In general, when `is_plain == false`, `password` can be either a string, a table or a function: the widget will execute it asynchronously in the first two cases. + +### Using plain passwords + +You can set your password in plain like this: + +```lua +myimapcheck = lain.widget.imap { + is_plain = true, + password = "mymailpassword", + -- [...] +} +``` + +and you will have the same security provided by `~/.netrc`. + +### Using a password manager + +I recommend to use [spm](https://notabug.org/kl3/spm) or [pass](https://www.passwordstore.org). In this case, `password` has to be a function. Example stub: + +```lua +myimapcheck = lain.widget.imap { + password = function() + -- do your retrieval + return retrieved_password, try_again + end, + -- [...] +} +``` + +Where `retrieved_password` is the password retrieved from the manager, and `try_again` supports [DBus Secret Service](https://specifications.freedesktop.org/secret-service). + +The process flow is that the first `password()` call spawns the unlock prompt, then the second call retrieves the password. [Here](https://gist.github.com/lcpz/1854fc4320f4701957cd5309c8eed4a6) is an example of `password` function. + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`update` | Update `widget` | function +`timer` | The widget timer | [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html) +`pwdtimer` | Password retrieval timer (available only if `password` is a function)| [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html) + +The `update` function can be used to refresh the widget before `timeout` expires. + +You can use `timer` to start/stop the widget as you like. diff --git a/stow_home/awesome/.config/awesome/lain/wiki/mem.md b/stow_home/awesome/.config/awesome/lain/wiki/mem.md new file mode 100644 index 0000000..205d535 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/mem.md @@ -0,0 +1,33 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows memory status in MiB, [like `top` and `free -h`](https://github.com/lcpz/lain/issues/271). + +```lua +local mymem = lain.widget.mem() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 2 +`settings` | User settings | function | empty function + +in `settings` you can use the following variables: + +Variable | Meaning | Type +--- | --- | --- +`mem_now.used` | Memory used (MiB) | string +`mem_now.swapused` | Swap memory used (MiB) | string +`mem_now.perc` | Memory percentage | int + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`update` | Update `widget` | function \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/wiki/moc.md b/stow_home/awesome/.config/awesome/lain/wiki/moc.md new file mode 100644 index 0000000..130bccb --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/moc.md @@ -0,0 +1,122 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +A widget for showing the current song track's information from MOC (Music On Console). + +```lua +local mymoc = lain.widget.contrib.moc() +``` + +Now playing songs are notified like this: + + +--------------------------------------------------------+ + | +-------+ | + | |/^\_/^\| Now playing | + | |\ O O /| Cannibal Corpse (Hammer Smashed Face) - 1993 | + | | '.o.' | Hammer Smashed Face (Radio Disney Version) | + | +-------+ | + +--------------------------------------------------------+ + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 1 +`music_dir` | Music directory | string | "~/Music" +`cover_size` | Album art notification size (both height and width) | integer | 100 +`cover_pattern` | Pattern for the album art file | string | `*\\.(jpg|jpeg|png|gif)`* +`default_art` | Default art | string | "" +`followtag` | Display the notification on currently focused screen | boolean | false +`settings` | User settings | function | empty function + +\* In Lua, "\\\\" means "\" escaped. + +Default `cover_pattern` definition will made the widget set the first jpg, jpeg, png or gif file found in the directory as the album art. + +Pay attention to case sensitivity when defining `music_dir`. + +`settings` can use `moc_now` table, which contains the following string values: + +- state (possible values: "PLAY", "PAUSE", "STOP") +- file +- artist +- title +- album +- elapsed (Time elapsed for the current track) +- total (The current track's total time) + +and can modify `moc_notification_preset` table, which will be the preset for the naughty notifications. Check [here](https://awesomewm.org/apidoc/libraries/naughty.html#notify) for the list of variables it can contain. Default definition: + +```lua +moc_notification_preset = { + title = "Now playing", + timeout = 6, + text = string.format("%s (%s) - %s\n%s", moc_now.artist, + moc_now.album, moc_now.elapsed, moc_now.title) +} +``` + +With multiple screens, the default behaviour is to show a visual notification pop-up window on the first screen. By setting `followtag` to `true` it will be shown on the currently focused tag screen. + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`update` | Update `widget` | function +`timer` | The widget timer | [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html) + +The `update` function can be used to refresh the widget before `timeout` expires. + +You can use `timer` to start/stop the widget as you like. + +## Keybindings + +You can control the widget with key bindings like these: + +```lua +-- MOC control +awful.key({ altkey, "Control" }, "Up", + function () + os.execute("mocp -G") -- toggle + moc.update() + end), +awful.key({ altkey, "Control" }, "Down", + function () + os.execute("mocp -s") -- stop + moc.update() + end), +awful.key({ altkey, "Control" }, "Left", + function () + os.execute("mocp -r") -- previous + moc.update() + end), +awful.key({ altkey, "Control" }, "Right", + function () + os.execute("mocp -f") -- next + moc.update() + end), +``` + +where `altkey = "Mod1"`. + +If you don't use the widget for long periods and wish to spare CPU, you can toggle it with a keybinding like this: + +```lua +-- toggle MOC widget +awful.key({ altkey }, "0", + function () + local common = { text = "MOC widget ", position = "top_middle", timeout = 2 } + if moc.timer.started then + moc.timer:stop() + common.text = common.text .. markup.bold("OFF") + else + moc.timer:start() + common.text = common.text .. markup.bold("ON") + end + naughty.notify(common) + end), +``` diff --git a/stow_home/awesome/.config/awesome/lain/wiki/mpd.md b/stow_home/awesome/.config/awesome/lain/wiki/mpd.md new file mode 100644 index 0000000..cd114a5 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/mpd.md @@ -0,0 +1,180 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows MPD status. + +```lua +local mympd = lain.widget.mpd() +``` + +Now playing songs are notified like this: + + +--------------------------------------------------------+ + | +-------+ | + | |/^\_/^\| Now playing | + | |\ O O /| Cannibal Corpse (Hammer Smashed Face) - 1993 | + | | '.o.' | Hammer Smashed Face (Radio Disney Version) | + | +-------+ | + +--------------------------------------------------------+ + +**Note:** if MPD is turned off or not set correctly, the widget will constantly display "N/A" values. + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 2 +`password` | MPD password | string | "" +`host` | MPD server | string | "127.0.0.1" +`port` | MPD port | string | "6600" +`music_dir` | Music directory | string | "~/Music" +`cover_size` | Album art notification size (both height and width) | integer | 100 +`cover_pattern` | Pattern for the album art file | string | `*.(jpg\|jpeg\|png\|gif)$` +`default_art` | Default art | string | `nil` +`notify` | Show notification popups | string | "on" +`followtag` | Notification behaviour | boolean | false +`settings` | User settings | function | empty function + +\* In Lua, "\\\\" means "\" escaped. + +Default `cover_pattern` definition will made the widget set the first jpg, jpeg, png or gif file found in the directory as the album art. + +Pay attention to case sensitivity when defining `music_dir`. + +`settings` can use `mpd_now` table, which contains the following values: + +(**note:** the first four are boolean [flags](https://github.com/lcpz/lain/pull/205), the remaining are all strings) + +- random_mode +- single_mode +- repeat_mode +- consume_mode +- pls_pos (playlist position) +- pls_len (playlist length) +- state (possible values: "play", "pause", "stop") +- file +- artist +- title +- name +- album +- track +- genre +- date +- [time](https://github.com/lcpz/lain/pull/90) (length of current song, in seconds) +- [elapsed](https://github.com/lcpz/lain/pull/90) (elapsed time of current song, in seconds) + +and can modify `mpd_notification_preset` table, which will be the preset for the naughty notifications. Check [here](https://awesomewm.org/doc/api/libraries/naughty.html#notify) for the list of variables it can contain. Default definition: + +```lua +mpd_notification_preset = { + title = "Now playing", + timeout = 6, + text = string.format("%s (%s) - %s\n%s", mpd_now.artist, + mpd_now.album, mpd_now.date, mpd_now.title) +} +``` + +With multiple screens, the default behaviour is to show a visual notification pop-up window on the first screen. By setting `followtag` to `true` it will be shown on the currently focused tag screen. + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The textbox | `wibox.widget.textbox` +`update` | Update `widget` | function +`timer` | The widget timer | [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html) + +The `update` function can be used to refresh the widget before `timeout` expires. + +You can use `timer` to start/stop the widget as you like. + +## Keybindings + +You can control the widget with keybindings like these: + +```lua +-- MPD control +awful.key({ altkey, "Control" }, "Up", + function () + awful.spawn.with_shell("mpc toggle || ncmpc toggle || pms toggle") + mympd.update() + end), +awful.key({ altkey, "Control" }, "Down", + function () + awful.spawn.with_shell("mpc stop || ncmpc stop || pms stop") + mympd.update() + end), +awful.key({ altkey, "Control" }, "Left", + function () + awful.spawn.with_shell("mpc prev || ncmpc prev || pms prev") + mympd.update() + end), +awful.key({ altkey, "Control" }, "Right", + function () + awful.spawn.with_shell("mpc next || ncmpc next || pms next") + mympd.update() + end), +``` + +where `altkey = "Mod1"`. + +If you don't use the widget for long periods and wish to spare CPU, you can toggle it with a keybinding like this: + +```lua +-- disable MPD widget +awful.key({ altkey }, "0", + function () + local common = { + text = "MPD widget ", + position = "top_middle", + timeout = 2 + } + if mympd.timer.started then + mympd.timer:stop() + common.text = common.text .. markup.bold("OFF") + else + mympd.timer:start() + common.text = common.text .. markup.bold("ON") + end + naughty.notify(common) + end), +``` + +## Notes + +### Cover not showing in notifications + +If the cover file is existent but not showed in notifications, [try](https://github.com/lcpz/lain/issues/393) setting `music_dir` to a symlink of your music folder, rather than to a physical path. This can be easily done through +```shell +ln -s /the/real_path_to_your_music/ /home/username/Music +``` +However, this only applies if the music is stored outside your user-specific folder, for instance in an external partition. + +### Always use `set_markup` + +In `settings`, if you use `widget:set_text`, [it will ignore Pango markup](https://github.com/lcpz/lain/issues/258), so be sure to always use `widget:set_markup`. + +### Volume fade in toggling MPD + +If you want a fade in/out in toggling MPD, you can put [this script](https://gist.github.com/lcpz/76e315bc27c6cdf7edd5021964b88df1) in your local `bin` directory: + +```shell +$ curl https://gist.githubusercontent.com/lcpz/76e315bc27c6cdf7edd5021964b88df1/raw/97f7ba586418a4e07637cfbc91d2974278dfa623/mpd-fade -o ~/bin/mpc-fade +$ chmod +x ~/bin/mpc-fade +``` + +Set your 1% decrease/increase commands [here](https://gist.github.com/lcpz/76e315bc27c6cdf7edd5021964b88df1#file-mpd-fade-L8-L9), then use a keybinding like this: + +```lua +-- MPD toggle with volume fading +awful.key({ "Shift" }, "Pause", + function() + awful.spawn.easy_async("mpc-fade 20 4", -- mpc-fade + function(stdout, stderr, reason, exit_code) + mympd.update() + end) + end), +``` diff --git a/stow_home/awesome/.config/awesome/lain/wiki/net.md b/stow_home/awesome/.config/awesome/lain/wiki/net.md new file mode 100644 index 0000000..252399e --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/net.md @@ -0,0 +1,115 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Monitors network interfaces and shows current traffic. + +```lua +local mynet = lain.widget.net() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 2 +`iface` | Network device(s) | string (single interface) or table of strings (multiple interfaces) | autodetected +`units` | Units | integer | 1024 (kilobytes) +`notify` | Display "no carrier" notifications | string | "on" +`wifi_state` | Get wifi connection status | string | "off" +`eth_state` | Get ethernet connection status | string | "off" +`screen` | Notifications screen | integer | 1 +`settings` | User settings | function | empty function + +`iface` can be a string or an table of the form `{ "eth0", "eth1", ... }` containing a list of the devices to collect data on. + +If more than one device is included, `net_now.sent` and `net_now.received` will contain cumulative values over all given devices. +Use `net_now.devices["eth0"]` to access `sent`, `received`, `state` or `carrier` per device. + +Possible alternative values for `units` are 1 (byte) or multiple of 1024: 1024^2 (mb), 1024^3 (gb), and so on. + +If `notify = "off"` is set, the widget won't display a notification when there's no carrier. + +`settings` can use the following `iface` related strings: + +- `net_now.carrier` ("0", "1"); +- `net_now.state` ("up", "down"); +- `net_now.sent` and `net_now.received` (numbers) will be the sum across all specified interfaces; +- `net_now.devices["interface"]` contains the same attributes as the old api for each interface. More on this in the "Multiple devices" section below. + +If `wifi_state = "on"` is set, `settings` can use the following extra strings attached to `net_now.devices["wireless interface"]`: +- `wifi` (true, false) indicates if the interface is connected to a network; +- `signal` (number) is the connection signal strength in dBm; + +If `eth_state = "on"` is set, `settings` can use the following extra string: `net_now.devices["ethernet interface"].ethernet`, which is a boolean indicating if an ethernet connection's active. + +For compatibility reasons, if multiple devices are given, `net_now.carrier` and `net_now.state` correspond to the last interface in the iface table and should not be relied upon (deprecated). + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`update` | Update `widget` | function + +## Notes + +### Setting `iface` manually + +If the widget [spawns a "no carrier" notification and you are sure to have an active network device](https://github.com/lcpz/lain/issues/102), then autodetection is probably not working. This may due to [your user privileges](https://github.com/lcpz/lain/issues/102#issuecomment-246470526). In this case you can set `iface` manually. You can see which device is **UP,LOWER_UP** with the following command: + +```shell +ip link show +``` +## Usage examples +### Two widgets for upload/download rates from the same `iface` + +```lua +local mynetdown = wibox.widget.textbox() +local mynetup = lain.widget.net { + settings = function() + widget:set_markup(net_now.sent) + netdowninfo:set_markup(net_now.received) + end +} +``` +### Wifi connection + signal strength indicator and ethernet connection indicator +```lua +local wifi_icon = wibox.widget.imagebox() +local eth_icon = wibox.widget.imagebox() +local net = lain.widget.net { + notify = "off", + wifi_state = "on", + eth_state = "on", + settings = function() + local eth0 = net_now.devices.eth0 + if eth0 then + if eth0.ethernet then + eth_icon:set_image(ethernet_icon_filename) + else + eth_icon:set_image() + end + end + + local wlan0 = net_now.devices.wlan0 + if wlan0 then + if wlan0.wifi then + local signal = wlan0.signal + if signal < -83 then + wifi_icon:set_image(wifi_weak_filename) + elseif signal < -70 then + wifi_icon:set_image(wifi_mid_filename) + elseif signal < -53 then + wifi_icon:set_image(wifi_good_filename) + elseif signal >= -53 then + wifi_icon:set_image(wifi_great_filename) + end + else + wifi_icon:set_image() + end + end + end +} +``` diff --git a/stow_home/awesome/.config/awesome/lain/wiki/pulse.md b/stow_home/awesome/.config/awesome/lain/wiki/pulse.md new file mode 100644 index 0000000..cea432a --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/pulse.md @@ -0,0 +1,135 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows and controls PulseAudio volume. + +```lua +local volume = lain.widget.pulse() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 5 +`devicetype` | PulseAudio device type | string ("sink", "source") | "sink" +`cmd` | PulseAudio command | string or function | see [here](https://github.com/lcpz/lain/blob/master/widget/pulse.lua#L26) +`settings` | User settings | function | empty function + +`cmd` is a terminal command to catch infos from current default device. You can redefine it, being sure that the ouput is something like this: + +```shell +* index: 0 + volume: front-left: 18340 / 28% / -33.18 dB, front-right: 18340 / 28% / -33.18 dB + muted: no + device.string = "front:1" +``` + +If your devices change dynamically, you can define it as a function which returns a command string. + +If sed doesn't work, you can try with a grep variant: + +```lua +cmd = "pacmd list-" .. pulse.devicetype .. "s | grep -e $(pactl info | grep -e 'ink' | cut -d' ' -f3) -e 'volume: front' -e 'muted'" +``` + +### `settings` variables + +`settings` can use the following variables: + +Variable | Meaning | Type | Values +--- | --- | --- | --- +`volume_now.device` | Device name | string | device name or "N/A" +`volume_now.index` | Device index | string | >= "0" +`volume_now.muted` | Device mute status | string | "yes", "no", "N/A" +`volume_now.channel` | Device channels | table of string integers | `volume_now.channel[i]`, where `i >= 1` +`volume_now.left` | Front left sink level or first source | string | "0"-"100" +`volume_now.right` | Front right sink level or second source | string | "0"-"100" + +`volume_now.channel` is a table of your PulseAudio devices. Fetch a channel level like this: `volume_now.channel[i]`, where `i >= 1`. + +`volume_now.{left,right}` are pointers for `volume_now.{channel[1], channel[2]}` (stereo). + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`update` | Update `widget` | function + +## Buttons + +```lua +volume.widget:buttons(awful.util.table.join( + awful.button({}, 1, function() -- left click + awful.spawn("pavucontrol") + end), + awful.button({}, 2, function() -- middle click + os.execute(string.format("pactl set-sink-volume %s 100%%", volume.device)) + volume.update() + end), + awful.button({}, 3, function() -- right click + os.execute(string.format("pactl set-sink-mute %s toggle", volume.device)) + volume.update() + end), + awful.button({}, 4, function() -- scroll up + os.execute(string.format("pactl set-sink-volume %s +1%%", volume.device)) + volume.update() + end), + awful.button({}, 5, function() -- scroll down + os.execute(string.format("pactl set-sink-volume %s -1%%", volume.device)) + volume.update() + end) +)) +``` + +## Keybindings + +```lua +-- PulseAudio volume control +awful.key({ altkey }, "Up", + function () + os.execute(string.format("pactl set-sink-volume %s +1%%", volume.device)) + volume.update() + end), +awful.key({ altkey }, "Down", + function () + os.execute(string.format("pactl set-sink-volume %s -1%%", volume.device)) + volume.update() + end), +awful.key({ altkey }, "m", + function () + os.execute(string.format("pactl set-sink-mute %s toggle", volume.device)) + volume.update() + end), +awful.key({ altkey, "Control" }, "m", + function () + os.execute(string.format("pactl set-sink-volume %s 100%%", volume.device)) + volume.update() + end), +awful.key({ altkey, "Control" }, "0", + function () + os.execute(string.format("pactl set-sink-volume %s 0%%", volume.device)) + volume.update() + end), +``` + +where `altkey = "Mod1"`. + +## Example + +```lua +-- PulseAudio volume (based on multicolor theme) +local volume = lain.widget.pulse { + settings = function() + vlevel = volume_now.left .. "-" .. volume_now.right .. "% | " .. volume_now.device + if volume_now.muted == "yes" then + vlevel = vlevel .. " M" + end + widget:set_markup(lain.util.markup("#7493d2", vlevel)) + end +} +``` diff --git a/stow_home/awesome/.config/awesome/lain/wiki/pulsebar.md b/stow_home/awesome/.config/awesome/lain/wiki/pulsebar.md new file mode 100644 index 0000000..de3a475 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/pulsebar.md @@ -0,0 +1,98 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows PulseAudio volume with a progressbar; provides tooltips and notifications. + +```lua +local volume = lain.widget.pulsebar() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 5 +`settings` | User settings | function | empty function +`width` | Bar width | number | 63 +`height` | Bar height | number | 1 +`margins` | Bar margins | number | 1 +`paddings` | Bar paddings | number | 1 +`ticks` | Set bar ticks on | boolean | false +`ticks_size` | Ticks size | number | 7 +`tick` | String for a notification tick | string | "|" +`tick_pre` | String for the left notification delimeter | string | "[" +`tick_post` | String for the right notification delimeter | string | "]" +`tick_none` | String for an empty notification tick | string | " " +`scallback` | [PulseAudio sink callback](https://github.com/lcpz/lain/wiki/pulseaudio/) | function | `nil` +`sink` | Mixer sink | number | 0 +`colors` | Bar colors | table | see [Default colors](https://github.com/lcpz/lain/wiki/pulsebar#default-colors) +`notification_preset` | Notification preset | table | See [default `notification_preset`](https://github.com/lcpz/lain/wiki/pulsebar#default-notification_preset) +`followtag` | Display the notification on currently focused screen | boolean | false +`notification_preset` | Notification preset | table | See [default `notification_preset`](https://github.com/lcpz/lain/wiki/pulsebar#default-notification_preset) +`devicetype` | PulseAudio device type | string ("sink", "source") | "sink" +`cmd` | PulseAudio command | string or function | see [here](https://github.com/lcpz/lain/blob/master/widget/pulsebar.lua#L48) + +Read [pulse](https://github.com/lcpz/lain/wiki/pulse) page for `cmd` settings. + +`settings` can use [these variables](https://github.com/lcpz/lain/wiki/pulse#settings-variables). + +With multiple screens, the default behaviour is to show a visual notification pop-up window on the first screen. By setting `followtag` to `true` it will be shown on the currently focused tag screen. + +### Default colors + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`background` | Bar backgrund color | string | "#000000" +`mute` | Bar mute color | string | "#EB8F8F" +`unmute` | Bar unmute color | string | "#A4CE8A" + +### Default `notification_preset` + +```lua +notification_preset = { + font = "Monospace 10" +} +``` + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`bar` | The widget | `wibox.widget.progressbar` +`device` | PulseAudio device | string +`notify` | The notification | function +`update` | Update state | function +`tooltip` | The tooltip | `awful.tooltip` + +## Buttons + +```lua +volume.bar:buttons(awful.util.table.join( + awful.button({}, 1, function() -- left click + awful.spawn("pavucontrol") + end), + awful.button({}, 2, function() -- middle click + os.execute(string.format("pactl set-sink-volume %d 100%%", volume.device)) + volume.update() + end), + awful.button({}, 3, function() -- right click + os.execute(string.format("pactl set-sink-mute %d toggle", volume.device)) + volume.update() + end), + awful.button({}, 4, function() -- scroll up + os.execute(string.format("pactl set-sink-volume %d +1%%", volume.device)) + volume.update() + end), + awful.button({}, 5, function() -- scroll down + os.execute(string.format("pactl set-sink-volume %d -1%%", volume.device)) + volume.update() + end) +)) +``` + +## Keybindings + +Same as [here](https://github.com/lcpz/lain/wiki/pulse#keybindings). If you want notifications, use `volume.notify()` instead of `volume.update()`. diff --git a/stow_home/awesome/.config/awesome/lain/wiki/redshift.md b/stow_home/awesome/.config/awesome/lain/wiki/redshift.md new file mode 100644 index 0000000..b83ad3a --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/redshift.md @@ -0,0 +1,100 @@ +### What is Redshift? # + +[**Project homepage**](http://jonls.dk/redshift/) + +>**Redshift** is an application that adjusts the computer display's color temperature based upon the Sun's apparent position in relation to the user's location on Earth. +> +>The program is free software, inspired by the proprietary f.lux, and can be used to reduce eye strain as well as insomnia and delayed sleep phase syndrome. +> +>The computer display's color temperature transitions evenly from night to daytime temperature to allow the user's eyes to slowly adapt. At night, the color temperature is low and is typically 3000–4000 K (default is 3500 K), preferably matching the room's lighting temperature. Typical color temperature during the daytime is 5500–6500 K (default is 5500 K). + +**Source:** [Wikipedia](https://en.wikipedia.org/wiki/Redshift_%28software%29) + +### Preparations + +**Redshift must be installed** on your system if you want to use this widget. + +Packages should be available for most distributions. Source code and build instructions can be found on Github [here](https://github.com/jonls/redshift). + +You also need a valid config file. Please see the [project homepage](http://jonls.dk/redshift/) for details. An example: [`~/.config/redshift.conf`](https://github.com/jonls/redshift/blob/master/redshift.conf.sample). + +You have to match the location settings to your personal situation: you can adjust the `lat` and `lon` variables using a [web service](https://encrypted.google.com/search?q=get+latitude+and+longitude). + +You might also want to modify the color temperatures to fit your preferences. + +### Using the widget + +This widget provides the following functions: + +| function | meaning | +| --- | --- | +| `redshift:toggle()` | Toggles Redshift adjustments on or off, and also restarts it if terminates. | +| `redshift:attach(widget, update_function)` | Attach to a widget. Click on the widget to toggle redshift on or off. `update_function` is a callback function which will be triggered each time Redshift changes its status. (See the examples below.) | + +### Usage examples + +#### Textbox status widget + +```lua +myredshift = wibox.widget.textbox() +lain.widget.contrib.redshift:attach( + myredshift, + function (active) + if active then + myredshift:set_text("RS on") + else + myredshift:set_text("RS off") + end + end +) +``` + +Then add `myredshift.widget` to your wibox. + +#### Checkbox status widget + +```lua +local markup = lain.util.markup + +local myredshift = wibox.widget{ + checked = false, + check_color = "#EB8F8F", + border_color = "#EB8F8F", + border_width = 1, + shape = gears.shape.square, + widget = wibox.widget.checkbox +} + +local myredshift_text = wibox.widget{ + align = "center", + widget = wibox.widget.textbox, +} + +local myredshift_stack = wibox.widget{ + myredshift, + myredshift_text, + layout = wibox.layout.stack +} + +lain.widget.contrib.redshift:attach( + myredshift, + function (active) + if active then + myredshift_text:set_markup(markup(beautiful.bg_normal, "R")) + else + myredshift_text:set_markup(markup(beautiful.fg_normal, "R")) + end + myredshift.checked = active + end +) +``` + +Then add the `myredshift_stack` widget to your wibox. + +#### Keybinding + +Add this to the keybindings in your `rc.lua`: +```lua +-- Toggle redshift with Mod+Shift+t +awful.key({ modkey, "Shift" }, "t", function () lain.widget.contrib.redshift:toggle() end), +``` \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/wiki/sysload.md b/stow_home/awesome/.config/awesome/lain/wiki/sysload.md new file mode 100644 index 0000000..6fb1c04 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/sysload.md @@ -0,0 +1,27 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows the current system load. + +```lua +mysysload = lain.widget.sysload() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 2 +`settings` | User settings | function | empty function + +`settings` can use strings `load_1`, `load_5` and `load_15`, which are the load averages over 1, 5, and 15 minutes. + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`update` | Update `widget` | function \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/wiki/task.md b/stow_home/awesome/.config/awesome/lain/wiki/task.md new file mode 100644 index 0000000..af53a6a --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/task.md @@ -0,0 +1,51 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Attaches a [taskwarrior](http://taskwarrior.org) notifications to a widget, and lets you execute `task` commands from the promptbox. + +```lua +lain.widget.contrib.task.attach(widget, args) +``` + +`args` is an optional table which can contain: + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`show_cmd` | Taskwarrior command to show in the popup | string | "task next" +`prompt_text` | Prompt text | string | "Enter task command: " +`followtag` | Display the notification on currently focused screen | boolean | false +`notification_preset` | Notification preset | table | See [default `notification_preset`](https://github.com/lcpz/lain/wiki/task#default-notification_preset) + +The tasks are shown in a notification popup when the mouse is moved over the attached `widget`, and the popup is hidden when the mouse is moved away. By default, the notification will show the output of `task next`. With `show_cmd`, the `task` popup command can be customized, for example if you want to [filter the tasks](https://taskwarrior.org/docs/filter.html) or show a [custom report](https://github.com/lcpz/lain/pull/213). + +With multiple screens, the default behaviour is to show a visual notification pop-up window on the first screen. By setting `followtag` to `true` it will be shown on the currently focused tag screen. + +You can call the notification with a keybinding like this: + +```lua +awful.key({ modkey, altkey }, "t", function () lain.widget.contrib.task.show(scr) end), +``` + +where ``altkey = "Mod1"`` and `scr` (optional) indicates the screen which you want the notification in. + +And you can prompt to input a `task` command with a keybinding like this: + +```lua +awful.key({ altkey }, "t", lain.widget.contrib.task.prompt), +``` + +### Default `notification_preset` + +```lua +notification_preset = { + font = "Monospace 10", + icon = helpers.icons_dir .. "/taskwarrior.png" +} +``` + +## Note + +* If your widget does not display `task next` output, try changing Taskwarrior verbose, for instance: `show_cmd = 'task rc.verbose:label'` or `show_cmd = 'task rc.verbose:nothing'`. \ No newline at end of file diff --git a/stow_home/awesome/.config/awesome/lain/wiki/temp.md b/stow_home/awesome/.config/awesome/lain/wiki/temp.md new file mode 100644 index 0000000..4ec5828 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/temp.md @@ -0,0 +1,35 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Shows the current CPU temperature. + +```lua +local mytemp = lain.widget.temp() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout (in seconds) | integer | 30 +`tempfile` | Path of file which stores core temperature value | string | "/sys/devices/virtual/thermal/thermal_zone0/temp" +`settings` | User settings | function | empty function + +`settings` can use the string `coretemp_now`, which contains the info retrieved from `tempfile`, and the table `temp_now`, which contains an entry for each `*temp*` file in each directory in the following paths: + +```shell +/sys/class/devices/virtual/thermal/thermal_zone* +/sys/class/devices/platform/coretemp*/hwmon/hwon* +``` + +All values are expressed in Celsius (GNU/Linux standard). + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`update` | Update `widget` | function diff --git a/stow_home/awesome/.config/awesome/lain/wiki/tp_smapi.md b/stow_home/awesome/.config/awesome/lain/wiki/tp_smapi.md new file mode 100644 index 0000000..edb108f --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/tp_smapi.md @@ -0,0 +1,103 @@ +# Description + +[`tp_smapi`](http://www.thinkwiki.org/wiki/Tp_smapi) interface and widget creator. + +```lua +local tp_smapi = lain.widget.contrib.tp_smapi(apipath) +``` + +The argument `apipath` is an optional string which defines the API path. Its default value is `"/sys/devices/platform/smapi"`. + +# Functions + +## tp_smapi.get(batid, feature) + +Gets the `feature` of battery `batid`. Returns a string. The list of available features is available at [this page](https://www.thinkwiki.org/wiki/Tp_smapi#Battery_status_features). + +## tp_smapi.installed(batid) + +Checks if battery `batid` is installed. Returns a boolean. + +## tp_smapi.status(batid) + +Gets the status of battery `batid`. Returns a string ("charging", "discharging", or "full"). + +## tp_smapi.percentage(batid) + +Gets the percentage of battery `batid`. Returns a numeric string. + +## tp_smapi.time(batid) + +Gets the time of battery `batid`. Depending on the current status, it can be either running or charging time. Returns a string of the format `HH:MM`. + +## tp_smapi.hide() + +Removes any notification spawned by `tp_smapi.show`. + +## tp_smapi.show(batid, seconds, scr) + +Notifies the current information of battery `batid` for `seconds` seconds on screen `scr`. +The argument `scr` is optional, and if missing, the notification will be displayed on the currently focused screen. + +## tp_smapi.create_widget(args) + +Creates a [lain widget](https://github.com/lcpz/lain/wiki/Widgets#usage) of the available ThinkPad batteries. + +```lua +local tpbat = tp_smapi.create_widget() +``` + +### Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`widget` | The widget type to use | [`wibox.widget`](https://awesomewm.org/doc/api/classes/wibox.widget.html) | [`wibox.widget.textbox`](https://awesomewm.org/doc/api/classes/wibox.widget.textbox.html) +`timeout` | Refresh timeout (in seconds) | integer | 30 +`pspath` | Power supply directory path | string | "/sys/class/power_supply/" +`battery` | Single battery id | string | autodetected +`batteries` | Multiple batteries id table | table of strings | autodetected +`settings` | User settings | function | empty function + +The widget will try to autodetect `battery` and `batteries`. If something +goes wrong, you will have to define them manually. In that case, you only have +to define one between `battery` and `batteries`. If you have one battery, you +can either use `args.battery = "BAT*"` or `args.batteries = {"BAT*"}`, where `BAT*` +is the identifier of your battery in `pspath` (do not use it as a wildcard). +Of course, if you have multiple batteries, you need to use the latter option. + +If you define `pspath`, **be sure** to not forget the final slash (/). + +`settings` can use the `tpbat_now` table, which contains the following strings: + +- `status`, general status ("N/A", "discharging", "charging", "full"); +- `n_status[i]`, i-th battery status (like above); +- `n_perc[i]`, i-th battery charge percentage (like above); +- `n_time[i]`, i-th battery running or charging time (HH:MM string or "N/A"); + +`n_time[i]` is the running time of battery `i` when it is discharging, and the charging time otherwise. + +### Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | [`wibox.widget`](https://awesomewm.org/doc/api/classes/wibox.widget.html) | [textbox](https://awesomewm.org/doc/api/classes/wibox.widget.textbox.html) +`batteries` | Battery identifiers | Table of strings +`update` | Update `widget` | function +`timer` | The widget timer | [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html) + +The `update` function can be used to refresh the widget before `timeout` expires. + +### Usage example + +```lua +local tp_smapi = lain.widget.contrib.tp_smapi() +local bat = tp_smapi.create_widget { + battery = "BAT0", + settings = function() + widget:set_markup(tpbat_now.n_perc[1] .. "%") + end +} + +bat.widget:connect_signal("mouse::enter", function () tp_smapi.show("BAT0") end) +bat.widget:connect_signal("mouse::leave", function () tp_smapi.hide() end) +``` diff --git a/stow_home/awesome/.config/awesome/lain/wiki/watch.md b/stow_home/awesome/.config/awesome/lain/wiki/watch.md new file mode 100644 index 0000000..ff18a5c --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/watch.md @@ -0,0 +1,222 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Template for asynchronous watcher widgets. + +Executes an input command and makes the user feed a `wibox.widget` with the output. + +```lua +local mywatch = lain.widget.watch() +``` + +This has been implemented in Awesome 4.0 as [`awful.widget.watch`](https://awesomewm.org/doc/api/classes/awful.widget.watch.html). But while Awesome `watch` returns only the widget, Lain one returns a table including its timer and internal update function too. + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`widget` | Widget to feed | `wibox.widget` | `wibox.widget.textbox` +`timeout` | Refresh timeout seconds | number | 5 +`cmd` | The command to execute | string **or** table | `nil` +`nostart` | Widget timer doesn't start immediately | boolean | false +`stoppable` | Widget timer is stoppable | boolean | false +`settings` | User settings | function | see [Default `settings` function](https://github.com/lcpz/lain/wiki/watch#default-settings-function) + +If your command needs a shell, you need to set `cmd` as an array of 3 strings, where the first contains the shell, the second contains `-c`, and the third contains the actual command. Example: + +```lua +cmd = { awful.util.shell, "-c", "myactualcommand" } +``` + +`settings` can use the string `output`, which is the output of `cmd`. + +### Default `settings` function + +```lua +settings = function() widget:set_text(output) end +``` +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | input widget type or `wibox.widget.textbox` +`update` | Update `widget` | function +`timer` | The widget timer | [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html) or `nil` + +The `update` function can be used to refresh the widget before `timeout` expires. + +If `stoppable == true`, the widget will have an ad-hoc timer, which you can control though `timer` variable. + +## Use case examples + +### bitcoin + +```lua +-- Bitcoin to USD current price, using Coinbase V1 API +local bitcoin = lain.widget.watch({ + timeout = 43200, -- half day + stoppable = true, + cmd = "curl -m5 -s 'https://coinbase.com/api/v1/prices/buy'", + settings = function() + local btc, pos, err = require("lain.util").dkjson.decode(output, 1, nil) + local btc_price = (not err and btc and btc["subtotal"]["amount"]) or "N/A" + + -- customize here + widget:set_text(btc_price) + end +}) +``` + +### btrfs + +```lua +-- btrfs root df +local myrootfs = lain.widget.watch({ + timeout = 600, + cmd = "btrfs filesystem df -g /", + settings = function() + local total, used = string.match(output, "Data.-total=(%d+%.%d+)GiB.-used=(%d+%.%d+)GiB") + local percent_used = math.ceil((tonumber(used) / tonumber(total)) * 100) + + -- customize here + widget:set_text(" [/: " .. percent_used .. "%] ") + end +}) +``` + +### cmus + +```lua +-- cmus audio player +local cmus = lain.widget.watch({ + timeout = 2, + stoppable = true, + cmd = "cmus-remote -Q", + settings = function() + local cmus_now = { + state = "N/A", + artist = "N/A", + title = "N/A", + album = "N/A" + } + + for w in string.gmatch(output, "(.-)tag") do + a, b = w:match("(%w+) (.-)\n") + cmus_now[a] = b + end + + -- customize here + widget:set_text(cmus_now.artist .. " - " .. cmus_now.title) + end +}) +``` + +### maildir + +```lua +-- checks whether there are files in the "new" directories of a mail dirtree +local mailpath = "~/Mail" +local mymaildir = lain.widget.watch({ + timeout = 60, + stoppable = true, + cmd = { awful.util.shell, "-c", string.format("ls -1dr %s/*/new/*", mailpath) }, + settings = function() + local inbox_now = { digest = "" } + + for dir in output:gmatch(".-/(%w+)/new") do + inbox_now[dir] = 1 + for _ in output:gmatch(dir) do + inbox_now[dir] = inbox_now[dir] + 1 + end + if #inbox_now.digest > 0 then inbox_now.digest = inbox_now.digest .. ", " end + inbox_now.digest = inbox_now.digest .. string.format("%s (%d)", dir, inbox_now[dir]) + end + + -- customize here + widget:set_text("mail: " .. inbox_now.digest) + end +}) +``` + +### mpris + +```lua +-- infos from mpris clients such as spotify and VLC +-- based on https://github.com/acrisci/playerctl +local mpris = lain.widget.watch({ + cmd = "playerctl status && playerctl metadata", + timeout = 2, + stoppable = true, + settings = function() + local escape_f = require("awful.util").escape + local mpris_now = { + state = "N/A", + artist = "N/A", + title = "N/A", + art_url = "N/A", + album = "N/A", + album_artist = "N/A" + } + + mpris_now.state = string.match(output, "Playing") or + string.match(output, "Paused") or "N/A" + + for k, v in string.gmatch(output, "'[^:]+:([^']+)':[%s]<%[?'([^']+)'%]?>") + do + if k == "artUrl" then mpris_now.art_url = v + elseif k == "artist" then mpris_now.artist = escape_f(v) + elseif k == "title" then mpris_now.title = escape_f(v) + elseif k == "album" then mpris_now.album = escape_f(v) + elseif k == "albumArtist" then mpris_now.album_artist = escape_f(v) + end + end + + -- customize here + widget:set_text(mpris_now.artist .. " - " .. mpris_now.title) + end +}) +``` + +### upower + +```lua +-- battery infos from freedesktop upower +local mybattery = lain.widget.watch({ + timeout = 30, + cmd = { awful.util.shell, "-c", "upower -i /org/freedesktop/UPower/devices/battery_BAT | sed -n '/present/,/icon-name/p'" }, + settings = function() + local bat_now = { + present = "N/A", + state = "N/A", + warninglevel = "N/A", + energy = "N/A", + energyfull = "N/A", + energyrate = "N/A", + voltage = "N/A", + percentage = "N/A", + capacity = "N/A", + icon = "N/A" + } + + for k, v in string.gmatch(output, '([%a]+[%a|-]+):%s*([%a|%d]+[,|%a|%d]-)') do + if k == "present" then bat_now.present = v + elseif k == "state" then bat_now.state = v + elseif k == "warning-level" then bat_now.warninglevel = v + elseif k == "energy" then bat_now.energy = string.gsub(v, ",", ".") -- Wh + elseif k == "energy-full" then bat_now.energyfull = string.gsub(v, ",", ".") -- Wh + elseif k == "energy-rate" then bat_now.energyrate = string.gsub(v, ",", ".") -- W + elseif k == "voltage" then bat_now.voltage = string.gsub(v, ",", ".") -- V + elseif k == "percentage" then bat_now.percentage = tonumber(v) -- % + elseif k == "capacity" then bat_now.capacity = string.gsub(v, ",", ".") -- % + elseif k == "icon-name" then bat_now.icon = v + end + end + + -- customize here + widget:set_text("Bat: " .. bat_now.percentage .. " " .. bat_now.state) + end +}) +``` diff --git a/stow_home/awesome/.config/awesome/lain/wiki/weather.md b/stow_home/awesome/.config/awesome/lain/wiki/weather.md new file mode 100644 index 0000000..1875965 --- /dev/null +++ b/stow_home/awesome/.config/awesome/lain/wiki/weather.md @@ -0,0 +1,150 @@ +## Usage + +[Read here.](https://github.com/lcpz/lain/wiki/Widgets#usage) + +### Description + +Provides current weather status widgets and X-days forecast popup notifications. + +Powered by [OpenWeatherMap](http://openweathermap.org/api) API. + +By default, it uses [current](http://openweathermap.org/current) for current weather data and [forecast16](http://openweathermap.org/forecast16) for forecasts. + +```lua +local myweather = lain.widget.weather() +``` + +## Input table + +Variable | Meaning | Type | Default +--- | --- | --- | --- +`timeout` | Refresh timeout seconds for current weather status | number | 900 (15 min) +`timeout_forecast` | Refresh timeout seconds for forecast notification | number | 86400 (24 hrs) +`current_call` | Command to fetch weather status data from the API | string | see `default_current_call` +`forecast_call` | Command to fetch forecast data from the API | string | see `default_forecast_call` +`city_id` | API city code | number | not set +`utc_offset` | UTC time offset | function | see [here](https://github.com/lcpz/lain/blob/master/widget/weather.lua#L35-L39) +`units` | Temperature units system | string | "metric" +`lang` | API data localization | string | "en" +`cnt` | Forecast days interval | integer | 5 +`date_cmd` | Forecast notification format style | string | "date -u -d @%d +'%%a %%d'" +`icons_path` | Icons path | string | `lain/icons/openweathermap` +`notification_preset` | Preset for notifications | table | empty table +`notification_text_fun` | Function to format forecast notifications | function | see `notification_text_fun` below +`weather_na_markup` | Markup to be used when weather textbox is not available | text | " N/A " +`followtag` | Display the notification on currently focused screen | boolean | false +`showpopup` | Display popups with mouse hovering | string, possible values: "on", "off" | "on" +`settings` | User settings | function | empty function + +- ``default_current_call`` + + `"curl -s 'http://api.openweathermap.org/data/2.5/weather?id=%s&units=%s&lang=%s'"` + + You can rewrite it using any fetcher solution you like, or you can modify it in order to fetch data by city name, instead of ID: just replace `id` with `q`: + + `"curl -s 'http://api.openweathermap.org/data/2.5/weather?q=%s&units=%s&lang=%s'"` + + and set `city_id` with your city name, for instance `city_id = "London,UK"`. + +- ``default_forecast_call`` + + `"curl -s 'http://api.openweathermap.org/data/2.5/forecast/daily?id=%s&units=%s&lang=%s&cnt=%s'"` + + Like above. + If you want to use [forecast5](http://openweathermap.org/forecast5), use this API call string: + `http://api.openweathermap.org/data/2.5/forecast?id=%s&units=%s&lang=%s&cnt=%s` + +- ``city_id`` + + An integer that defines the OpenWeatherMap ID code of your city. + To obtain it go to [OpenWeatherMap](http://openweathermap.org/) and query for your city in the top search bar. The link will look like this: + + http://openweathermap.org/city/2643743 + + your `city_id` is the number at the end. + +- ``units`` + + - For temperature in Fahrenheit use `units = "imperial"` + - For temperature in Celsius use `units = "metric"` (Lain default) + - For temperature in Kelvin use `units = "standard"` (OpenWeatherMap default) + +- ``lang`` + + See *Multilingual Support* section [here](http://openweathermap.org/current). + +- ``cnt`` + + Determines how many days to show in the forecast notification. Up to 16 if you use [forecast16](http://openweathermap.org/forecast16) (default), and up to 5 if you use [forecast5](http://openweathermap.org/forecast5). + +- ``date_cmd`` + + OpenWeatherMap time is in UNIX format, so this variable uses `date` to determine how each line in the forecast notification is formatted. Default looks like this: + + day #daynumber: forecast, temp_min - temp_max + + see `man date` for your customizations. + +- ``icons_path`` + + You can set your own icons path if you don't wish to use `lain/icons/openweathermap`. Just be sure that your icons are PNGs and named exactly like [OpenWeatherMap ones](http://openweathermap.org/weather-conditions). + +- ``notification_preset`` + + Notifications preset table. See [here](https://awesomewm.org/doc/api/libraries/naughty.html#notify) for the details. + +- ``notification_text_fun`` + ```lua + function (wn) + local day = string.gsub(read_pipe(string.format(date_cmd, wn["dt"])), "\n", "") + local tmin = math.floor(wn["temp"]["min"]) + local tmax = math.floor(wn["temp"]["max"]) + local desc = wn["weather"][1]["description"] + + return string.format("%s: %s, %d - %d ", day, desc, tmin, tmax) + end + ``` + See [here](https://github.com/lcpz/lain/issues/186#issuecomment-203400918) for a complete customization example. + +- ``followtag`` + + With multiple screens, the default behaviour is to show a visual notification pop-up window on the first screen. By setting `followtag` to `true` it will be shown on the currently focused tag screen. + +- ``settings`` + + In your `settings` function, you can use `widget` variable to refer to the textbox, and the dictionary `weather_now` to refer to data retrieved by `current_call`. The dictionary is built with [dkjson library](http://dkolf.de/src/dkjson-lua.fsl/home), and its structure is defined [here](http://openweathermap.org/weather-data). + For instance, you can retrieve current weather status and temperature in this way: + ```lua + descr = weather_now["weather"][1]["description"]:lower() + units = math.floor(weather_now["main"]["temp"]) + ``` + +## Output table + +Variable | Meaning | Type +--- | --- | --- +`widget` | The widget | `wibox.widget.textbox` +`icon` | The icon | `wibox.widget.imagebox` +`update` | Update `widget` | function +`timer` | The widget timer | [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html) +`timer_forecast` | The forecast notification timer | [`gears.timer`](https://awesomewm.org/doc/api/classes/gears.timer.html) + +## Functions + +You can attach the forecast notification to any widget like this: + +```lua +myweather.attach(obj) +``` + +Hovering over ``obj`` will display the notification. + +## Keybindings + +You can create a keybinding for the weather popup like this: + +```lua +awful.key( { "Mod1" }, "w", function () myweather.show(5) end ) +``` + +where ``show`` argument is an integer defining timeout seconds. diff --git a/stow_home/awesome/.config/awesome/rc.lua b/stow_home/awesome/.config/awesome/rc.lua new file mode 100644 index 0000000..103389d --- /dev/null +++ b/stow_home/awesome/.config/awesome/rc.lua @@ -0,0 +1,659 @@ +-- If LuaRocks is installed, make sure that packages installed through it are +-- found (e.g. lgi). If LuaRocks is not installed, do nothing. +pcall(require, "luarocks.loader") + +-- Standard awesome library +local gears = require("gears") +local lain = require("lain") +local awful = require("awful") +require("awful.autofocus") +-- Widget and layout library +local wibox = require("wibox") +-- Theme handling library +local beautiful = require("beautiful") +-- Notification library +local naughty = require("naughty") +local menubar = require("menubar") +local hotkeys_popup = require("awful.hotkeys_popup") +-- Enable hotkeys help widget for VIM and other apps +-- when client with a matching name is opened: +require("awful.hotkeys_popup.keys") + +-- {{{ Error handling +-- Check if awesome encountered an error during startup and fell back to +-- another config (This code will only ever execute for the fallback config) +if awesome.startup_errors then + naughty.notify({ preset = naughty.config.presets.critical, + title = "Oops, there were errors during startup!", + text = awesome.startup_errors }) +end + +-- Handle runtime errors after startup +do + local in_error = false + awesome.connect_signal("debug::error", function (err) + -- Make sure we don't go into an endless error loop + if in_error then return end + in_error = true + + naughty.notify({ preset = naughty.config.presets.critical, + title = "Oops, an error happened!", + text = tostring(err) }) + in_error = false + end) +end +-- }}} + +-- {{{ Variable definitions +-- Themes define colours, icons, font and wallpapers. +beautiful.init("~/.config/awesome/themes/zenburn/theme.lua") + +-- This is used later as the default terminal and editor to run. +terminal = "alacritty" +editor = os.getenv("EDITOR") or "nano" +editor_cmd = terminal .. " -e " .. editor + +-- Default modkey. +-- Usually, Mod4 is the key with a logo between Control and Alt. +-- If you do not like this or do not have such a key, +-- I suggest you to remap Mod4 to another key using xmodmap or other tools. +-- However, you can use another modifier likeMod1, but it may interact with others. +modkey = "Mod4" +local altkey = "Mod1" +-- Table of layouts to cover with awful.layout.inc, order matters. +awful.layout.layouts = { + awful.layout.suit.tile, + awful.layout.suit.tile.left, + awful.layout.suit.tile.bottom, + awful.layout.suit.tile.top, + awful.layout.suit.fair, + awful.layout.suit.spiral, + awful.layout.suit.max.fullscreen, + --awful.layout.suit.fair.horizontal, + --awful.layout.suit.spiral.dwindle, + --awful.layout.suit.max, + --awful.layout.suit.floating, + --awful.layout.suit.magnifier, + --awful.layout.suit.corner.nw, + -- awful.layout.suit.corner.ne, + -- awful.layout.suit.corner.sw, + -- awful.layout.suit.corner.se, +} +-- }}} + +-- {{{ Menu +-- Create a launcher widget and a main menu +myawesomemenu = { + { "hotkeys", function() hotkeys_popup.show_help(nil, awful.screen.focused()) end }, + { "manual", terminal .. " -e man awesome" }, + { "edit config", editor_cmd .. " " .. awesome.conffile }, + { "restart", awesome.restart }, + { "quit", function() awesome.quit() end }, +} + +mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, + { "open terminal", terminal } + } + }) + +mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, + menu = mymainmenu }) + +-- Menubar configuration +menubar.utils.terminal = terminal -- Set the terminal for applications that require it +-- }}} + +-- Keyboard map indicator and switcher +mykeyboardlayout = awful.widget.keyboardlayout() + +-- {{{ Wibar +-- Create a textclock widget +-- +mytextclock = wibox.widget.textclock("%B %d %I:%M %P " )--{ format = ) + +-- Create a wibox for each screen and add it +local taglist_buttons = gears.table.join( + awful.button({ }, 1, function(t) t:view_only() end), + awful.button({ modkey }, 1, function(t) + if client.focus then + client.focus:move_to_tag(t) + end + end), + awful.button({ }, 3, awful.tag.viewtoggle), + awful.button({ modkey }, 3, function(t) + if client.focus then + client.focus:toggle_tag(t) + end + end), + awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end), + awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end) + ) + +local tasklist_buttons = gears.table.join( + awful.button({ }, 1, function (c) + if c == client.focus then + c.minimized = true + else + c:emit_signal( + "request::activate", + "tasklist", + {raise = true} + ) + end + end), + awful.button({ }, 3, function() + awful.menu.client_list({ theme = { width = 250 } }) + end), + awful.button({ }, 4, function () + awful.client.focus.byidx(1) + end), + awful.button({ }, 5, function () + awful.client.focus.byidx(-1) + end)) + +local function set_wallpaper(s) + -- Wallpaper + if beautiful.wallpaper then + local wallpaper = beautiful.wallpaper + -- If wallpaper is a function, call it with the screen + if type(wallpaper) == "function" then + wallpaper = wallpaper(s) + end + gears.wallpaper.maximized(wallpaper, s, true) + end +end + +-- Re-set wallpaper when a screen's geometry changes (e.g. different resolution) +screen.connect_signal("property::geometry", set_wallpaper) + +awful.screen.connect_for_each_screen(function(s) + -- Wallpaper + set_wallpaper(s) + + -- Each screen has its own tag table. + awful.tag({ " ", " ", " ", " ", " ", " ", " ", " ", " ", " " }, s, awful.layout.layouts[1]) + -- Create a promptbox for each screen + s.mypromptbox = awful.widget.prompt() + -- Create an imagebox widget which will contain an icon indicating which layout we're using. + -- We need one layoutbox per screen. + s.mylayoutbox = awful.widget.layoutbox(s) + s.mylayoutbox:buttons(gears.table.join( + awful.button({ }, 1, function () awful.layout.inc( 1) end), + awful.button({ }, 3, function () awful.layout.inc(-1) end), + awful.button({ }, 4, function () awful.layout.inc( 1) end), + awful.button({ }, 5, function () awful.layout.inc(-1) end))) + -- Create a taglist widget + s.mytaglist = awful.widget.taglist { + screen = s, + filter = awful.widget.taglist.filter.all, + buttons = taglist_buttons, + } + + -- Create a tasklist widget + s.mytasklist = awful.widget.tasklist { + screen = s, + filter = awful.widget.tasklist.filter.currenttags, + buttons = tasklist_buttons + } + + -- Create the wibox + s.mywibox = awful.wibar({ position = "top", screen = s }) + + -- Add widgets to the wibox + s.mywibox:setup { + layout = wibox.layout.align.horizontal, + { -- Left widgets + layout = wibox.layout.fixed.horizontal, + mylauncher, + s.mytaglist, + s.mypromptbox, + }, + s.mytasklist, -- Middle widget + { -- Right widgets + layout = wibox.layout.fixed.horizontal, + mykeyboardlayout, + wibox.layout.margin(wibox.widget.systray(), 3, 3, 3, 3), + mytextclock, + s.mylayoutbox, + }, + } + end) +-- }}} + +-- {{{ Mouse bindings +root.buttons(gears.table.join( + awful.button({ }, 3, function () mymainmenu:toggle() end), + awful.button({ }, 4, awful.tag.viewnext), + awful.button({ }, 5, awful.tag.viewprev) +)) +-- }}} + +-- {{{ Key bindings +globalkeys = gears.table.join( + awful.key({ modkey, }, "s", hotkeys_popup.show_help, + {description="show help", group="awesome"}), + awful.key({ modkey, }, "Left", awful.tag.viewprev, + {description = "view previous", group = "tag"}), + awful.key({ modkey, }, "Right", awful.tag.viewnext, + {description = "view next", group = "tag"}), + awful.key({ modkey, }, "Escape", awful.tag.history.restore, + {description = "go back", group = "tag"}), + -- move window to previous tag + awful.key({ modkey, "Shift" }, "Left", + function () + -- get current tag + local t = client.focus and client.focus.first_tag or nil + if t == nil then + return + end + -- get previous tag (modulo of tag n excluding 0 to wrap from tag 1 to tag n) + local tag = client.focus.screen.tags[(t.index - 2) % 10 + 1] + if tag then + client.focus:move_to_tag(tag) + awful.tag.viewprev() + end + end, + {description = "carry focused client to previous tag", group = "client"}), + -- move window to next tag + awful.key({ modkey, "Shift" }, "Right", + function () + -- get current tag + local t = client.focus and client.focus.first_tag or nil + if t == nil then + return + end + -- get next tag (modulo of tag n excluding 0 to wrap from tag n to tag 1) + local tag = client.focus.screen.tags[(t.index % 10) + 1] + if tag then + client.focus:move_to_tag(tag) + awful.tag.viewnext() + end + end, + {description = "carry focused client to next tag", group = "client"}), + + awful.key({ modkey, }, "j", + function () + awful.client.focus.byidx( 1) + end, + {description = "focus next by index", group = "client"} + ), + awful.key({ modkey, }, "k", + function () + awful.client.focus.byidx(-1) + end, + {description = "focus previous by index", group = "client"} + ), + awful.key({ modkey, }, "w", function () mymainmenu:show() end, + {description = "show main menu", group = "awesome"}), + + -- On the fly useless gaps change + awful.key({ altkey, "Control" }, "l", function () lain.util.useless_gaps_resize(1) end, + {description = "increment useless gaps", group = "tag"}), + awful.key({ altkey, "Control" }, "h", function () lain.util.useless_gaps_resize(-1) end, + {description = "decrement useless gaps", group = "tag"}), + -- Layout manipulation + -- + awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end, + {description = "swap with next client by index", group = "client"}), + awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end, + {description = "swap with previous client by index", group = "client"}), + awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end, + {description = "focus the next screen", group = "screen"}), + awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end, + {description = "focus the previous screen", group = "screen"}), + awful.key({ modkey, }, "u", awful.client.urgent.jumpto, + {description = "jump to urgent client", group = "client"}), + awful.key({ modkey, }, "Tab", + function () + awful.client.focus.history.previous() + if client.focus then + client.focus:raise() + end + end, + {description = "go back", group = "client"}), + + -- Standard program + awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end, + {description = "open a terminal", group = "launcher"}), + awful.key({ modkey, "Shift" }, "r", awesome.restart, + {description = "reload awesome", group = "awesome"}), + awful.key({ modkey, "Control" }, "q", awesome.quit, + {description = "quit awesome", group = "awesome"}), + + awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end, + {description = "increase master width factor", group = "layout"}), + awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end, + {description = "decrease master width factor", group = "layout"}), + awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end, + {description = "increase the number of master clients", group = "layout"}), + awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end, + {description = "decrease the number of master clients", group = "layout"}), + awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end, + {description = "increase the number of columns", group = "layout"}), + awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end, + {description = "decrease the number of columns", group = "layout"}), + awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end, + {description = "select next", group = "layout"}), + awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end, + {description = "select previous", group = "layout"}), + + awful.key({ modkey, "Control" }, "n", + function () + local c = awful.client.restore() + -- Focus restored client + if c then + c:emit_signal( + "request::activate", "key.unminimize", {raise = true} + ) + end + end, + {description = "restore minimized", group = "client"}), + + --[[ Prompt + awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end, + {description = "run prompt", group = "launcher"}), + + awful.key({ modkey }, "x", + function () + awful.prompt.run { + prompt = "Run Lua code: ", + textbox = awful.screen.focused().mypromptbox.widget, + exe_callback = awful.util.eval, + history_path = awful.util.get_cache_dir() .. "/history_eval" + } + end, + {description = "lua execute prompt", group = "awesome"}), + -- Menubar + awful.key({ modkey }, "p", function() menubar.show() end, + {description = "show the menubar", group = "launcher"}) + ]]--) + + + -- User programs + awful.key({ modkey, altkey }, "b", function () awful.spawn("qutebrowser") end, + {description = "run browser", group = "launcher"}), + awful.key({ modkey }, "a", function () awful.spawn(gui_editor) end, + {description = "run gui editor", group = "launcher"}), + awful.key({ modkey, altkey }, "d", function () awful.spawn("Discord") end, + {description = "run discord messaging client", group = "launcher"}), + awful.key({ modkey, altkey }, "f", function () awful.spawn("pcmanfm") end, + {description = "run gui file manager", group = "launcher"}), + awful.key({ modkey}, "p", function () awful.spawn("rofi -show drun") end, + {description = "run rofi prompt (drun)", group = "Rofi launcher"}), + awful.key({ modkey,"Shift"}, "q", function () awful.spawn("/home/joelchrono12/.config/rofi/scripts/power-menu.sh") end, + {description = "run rofi power menu script", group = "Rofi launcher"}), + awful.key({ modkey,altkey}, "k", function () awful.spawn("rofi-pass") end, + {description = "run rofi power menu script", group = "Rofi launcher"}), + awful.key({ modkey }, "r", function () awful.spawn("rofi -show run") end, + {description = "run prompt", group = "launcher"}), + awful.key({ modkey,"Shift"}, "s", function () awful.spawn("flameshot gui") end, + {description = "run gui editor", group = "launcher"}), + awful.key({ modkey, altkey }, "p", function () awful.spawn("/home/joelchrono12/.config/rofi/scripts/qpost.sh") end, + {description = "create new blogpost", group = "launcher"})) +clientkeys = gears.table.join( + awful.key({ modkey, }, "f", + function (c) + c.fullscreen = not c.fullscreen + c:raise() + end, + {description = "toggle fullscreen", group = "client"}), + awful.key({ modkey, }, "q", function (c) c:kill() end, + {description = "close", group = "client"}), + awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle , + {description = "toggle floating", group = "client"}), + awful.key({ modkey, "Shift" }, "Return", function (c) c:swap(awful.client.getmaster()) end, + {description = "move to master", group = "client"}), + awful.key({ modkey, }, "o", function (c) c:move_to_screen() end, + {description = "move to screen", group = "client"}), + awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end, + {description = "toggle keep on top", group = "client"}), + awful.key({ modkey, }, "n", + function (c) + -- The client currently has the input focus, so it cannot be + -- minimized, since minimized clients can't have the focus. + c.minimized = true + end , + {description = "minimize", group = "client"}), + awful.key({ modkey, }, "m", + function (c) + c.maximized = not c.maximized + c:raise() + end , + {description = "(un)maximize", group = "client"}), + awful.key({ modkey, "Control" }, "m", + function (c) + c.maximized_vertical = not c.maximized_vertical + c:raise() + end , + {description = "(un)maximize vertically", group = "client"}), + awful.key({ modkey, "Shift" }, "m", + function (c) + c.maximized_horizontal = not c.maximized_horizontal + c:raise() + end , + {description = "(un)maximize horizontally", group = "client"}) +) + +-- Bind all key numbers to tags. +-- Be careful: we use keycodes to make it work on any keyboard layout. +-- This should map on the top row of your keyboard, usually 1 to 9. +for i = 1, 9 do + globalkeys = gears.table.join(globalkeys, + -- View tag only. + awful.key({ modkey }, "#" .. i + 9, + function () + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + tag:view_only() + end + end, + {description = "view tag #"..i, group = "tag"}), + -- Toggle tag display. + awful.key({ modkey, "Control" }, "#" .. i + 9, + function () + local screen = awful.screen.focused() + local tag = screen.tags[i] + if tag then + awful.tag.viewtoggle(tag) + end + end, + {description = "toggle tag #" .. i, group = "tag"}), + -- Move client to tag. + awful.key({ modkey, "Shift" }, "#" .. i + 9, + function () + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:move_to_tag(tag) + end + end + end, + {description = "move focused client to tag #"..i, group = "tag"}), + -- Toggle tag on focused client. + awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, + function () + if client.focus then + local tag = client.focus.screen.tags[i] + if tag then + client.focus:toggle_tag(tag) + end + end + end, + {description = "toggle focused client on tag #" .. i, group = "tag"}) + ) +end + +clientbuttons = gears.table.join( + awful.button({ }, 1, function (c) + c:emit_signal("request::activate", "mouse_click", {raise = true}) + end), + awful.button({ modkey }, 1, function (c) + c:emit_signal("request::activate", "mouse_click", {raise = true}) + awful.mouse.client.move(c) + end), + awful.button({ modkey }, 3, function (c) + c:emit_signal("request::activate", "mouse_click", {raise = true}) + awful.mouse.client.resize(c) + end) +) + +-- Set keys +root.keys(globalkeys) +-- }}} + +-- {{{ Rules +-- Rules to apply to new clients (through the "manage" signal). +awful.rules.rules = { + -- All clients will match this rule. + { rule = { }, + properties = { border_width = beautiful.border_width, + border_color = beautiful.border_normal, + focus = awful.client.focus.filter, + raise = true, + keys = clientkeys, + buttons = clientbuttons, + screen = awful.screen.preferred, + placement = awful.placement.no_overlap+awful.placement.no_offscreen + } + }, + + -- Floating clients. + { rule_any = { + instance = { + "DTA", -- Firefox addon DownThemAll. + "copyq", -- Includes session name in class. + "pinentry", + }, + class = { + "Arandr", + "Blueman-manager", + "Nitrogen", + "Gpick", + "Kruler", + "MessageWin", -- kalarm. + "Sxiv", + "Tor Browser", -- Needs a fixed window size to avoid fingerprinting by screen size. + "Wpa_gui", + "veromix", + "xtightvncviewer"}, + + -- Note that the name property shown in xprop might be set slightly after creation of the client + -- and the name shown there might not match defined rules here. + name = { + "Event Tester", -- xev. + }, + role = { + "AlarmWindow", -- Thunderbird's calendar. + "ConfigManager", -- Thunderbird's about:config. + "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. + } + }, properties = { floating = true }}, + + -- Add titlebars to normal clients and dialogs + { rule_any = {type = { "normal", "dialog" } + }, properties = { titlebars_enabled = false } + }, + + -- Set Firefox to always map on the tag named "2" on screen 1. + -- { rule = { class = "Firefox" }, + -- properties = { screen = 1, tag = "2" } }, +} +-- }}} + +-- {{{ Signals +-- Signal function to execute when a new client appears. +client.connect_signal("manage", function (c) + -- Set the windows at the slave, + -- i.e. put it at the end of others instead of setting it master. + if not awesome.startup then awful.client.setslave(c) end + + if awesome.startup + and not c.size_hints.user_position + and not c.size_hints.program_position then + -- Prevent clients from being unreachable after screen count changes. + awful.placement.no_offscreen(c) + end +end) + +-- Add a titlebar if titlebars_enabled is set to true in the rules. +client.connect_signal("request::titlebars", function(c) + -- buttons for the titlebar + local buttons = gears.table.join( + awful.button({ }, 1, function() + c:emit_signal("request::activate", "titlebar", {raise = true}) + awful.mouse.client.move(c) + end), + awful.button({ }, 3, function() + c:emit_signal("request::activate", "titlebar", {raise = true}) + awful.mouse.client.resize(c) + end) + ) + + awful.titlebar(c) : setup { + { -- Left + awful.titlebar.widget.iconwidget(c), + buttons = buttons, + layout = wibox.layout.fixed.horizontal + }, + { -- Middle + { -- Title + align = "center", + widget = awful.titlebar.widget.titlewidget(c) + }, + buttons = buttons, + layout = wibox.layout.flex.horizontal + }, + { -- Right + awful.titlebar.widget.floatingbutton (c), + awful.titlebar.widget.maximizedbutton(c), + awful.titlebar.widget.stickybutton (c), + awful.titlebar.widget.ontopbutton (c), + awful.titlebar.widget.closebutton (c), + layout = wibox.layout.fixed.horizontal() + }, + layout = wibox.layout.align.horizontal + } +end) + +beautiful.notification_icon_size = 64 +-- Enable sloppy focus, so that focus follows mouse. +--client.connect_signal("mouse::enter", function(c) +-- c:emit_signal("request::activate", "mouse_enter", {raise = false}) +--end) + +client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end) +client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end) +-- }}} +-- +-- +-- +-- +-- Add rounded corners to awesome wm +client.connect_signal("manage", function (c) + c.shape = function(cr,w,h) + gears.shape.rounded_rect(cr,w,h,12) + end +end) + +local autorun = true +autorunApps = +{ + "pipewire", + "volumeicon", + "picom", + "lxpolkit", + "xfce4-power-manager", + "nm-applet", + "syncthing-gtk -m", + --"/home/joelchrono12/.config/polybar/launch.sh", + --"touchpad-indicator", + "setxkbmap -layout latam", + "nitrogen --restore", + --"cbatticon", +} +if autorun then + for app = 1, #autorunApps do + awful.util.spawn(autorunApps[app]) + end +end diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/awesome-icon.png b/stow_home/awesome/.config/awesome/themes/zenburn/awesome-icon.png new file mode 100755 index 0000000..9ca448a Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/awesome-icon.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/darkpcnordwall.png b/stow_home/awesome/.config/awesome/themes/zenburn/darkpcnordwall.png new file mode 100755 index 0000000..7695dce Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/darkpcnordwall.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/ac.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/ac.png new file mode 100755 index 0000000..453af4e Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/ac.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/awesome.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/awesome.png new file mode 100755 index 0000000..2db19ca Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/awesome.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/battery.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/battery.png new file mode 100755 index 0000000..7dd78a5 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/battery.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/battery_empty.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/battery_empty.png new file mode 100755 index 0000000..763aa93 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/battery_empty.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/battery_low.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/battery_low.png new file mode 100755 index 0000000..626222f Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/battery_low.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/cpu.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/cpu.png new file mode 100755 index 0000000..c28a787 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/cpu.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/dish.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/dish.png new file mode 100755 index 0000000..1fc4a6b Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/dish.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/floating.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/floating.png new file mode 100755 index 0000000..add7f2b Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/floating.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/fwd.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/fwd.png new file mode 100755 index 0000000..e9b875e Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/fwd.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/hdd.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/hdd.png new file mode 100755 index 0000000..8922eaa Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/hdd.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/mail.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/mail.png new file mode 100755 index 0000000..be656ed Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/mail.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/mail_on.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/mail_on.png new file mode 100755 index 0000000..ce8984f Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/mail_on.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/mem.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/mem.png new file mode 100755 index 0000000..ee6d480 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/mem.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/net.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/net.png new file mode 100755 index 0000000..769bfec Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/net.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/next.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/next.png new file mode 100755 index 0000000..9a62593 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/next.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/note.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/note.png new file mode 100755 index 0000000..19866aa Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/note.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/note_on.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/note_on.png new file mode 100755 index 0000000..aae5ca3 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/note_on.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/pacman.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/pacman.png new file mode 100755 index 0000000..575144a Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/pacman.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/pause.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/pause.png new file mode 100755 index 0000000..d4546e6 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/pause.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/phones.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/phones.png new file mode 100755 index 0000000..bec0e57 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/phones.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/play.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/play.png new file mode 100755 index 0000000..b228f74 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/play.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/prev.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/prev.png new file mode 100755 index 0000000..4c4ca40 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/prev.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/rwd.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/rwd.png new file mode 100755 index 0000000..ac3d6f4 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/rwd.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/scissors.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/scissors.png new file mode 100755 index 0000000..30f867d Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/scissors.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/square_sel.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/square_sel.png new file mode 100755 index 0000000..874a3a5 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/square_sel.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/square_unsel.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/square_unsel.png new file mode 100755 index 0000000..979642f Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/square_unsel.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/stop.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/stop.png new file mode 100755 index 0000000..207915b Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/stop.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/submenu.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/submenu.png new file mode 100755 index 0000000..e9a6b7c Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/submenu.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/task.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/task.png new file mode 100755 index 0000000..962b51a Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/task.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/temp.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/temp.png new file mode 100755 index 0000000..7952de8 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/temp.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/tile.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/tile.png new file mode 100755 index 0000000..98fe539 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/tile.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/tilebottom.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/tilebottom.png new file mode 100755 index 0000000..80ce045 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/tilebottom.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/tileleft.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/tileleft.png new file mode 100755 index 0000000..216dec9 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/tileleft.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/tiletop.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/tiletop.png new file mode 100755 index 0000000..8bf290e Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/tiletop.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/close_focus.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/close_focus.png new file mode 100755 index 0000000..cccbadc Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/close_focus.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/close_normal.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/close_normal.png new file mode 100755 index 0000000..cb0c3fa Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/close_normal.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_focus_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_focus_active.png new file mode 100755 index 0000000..77ea127 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_focus_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_focus_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_focus_inactive.png new file mode 100755 index 0000000..d254a73 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_focus_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_normal_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_normal_active.png new file mode 100755 index 0000000..c5ce3de Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_normal_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_normal_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_normal_inactive.png new file mode 100755 index 0000000..850b602 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/floating_normal_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_focus_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_focus_active.png new file mode 100755 index 0000000..9fc0483 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_focus_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_focus_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_focus_inactive.png new file mode 100755 index 0000000..f684470 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_focus_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_normal_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_normal_active.png new file mode 100755 index 0000000..4aa4196 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_normal_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_normal_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_normal_inactive.png new file mode 100755 index 0000000..bfe01a3 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/maximized_normal_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_focus_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_focus_active.png new file mode 100755 index 0000000..86e61b7 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_focus_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_focus_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_focus_inactive.png new file mode 100755 index 0000000..286d439 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_focus_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_normal_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_normal_active.png new file mode 100755 index 0000000..fcee772 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_normal_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_normal_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_normal_inactive.png new file mode 100755 index 0000000..a628626 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/ontop_normal_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_focus_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_focus_active.png new file mode 100755 index 0000000..5af45c1 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_focus_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_focus_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_focus_inactive.png new file mode 100755 index 0000000..22d7453 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_focus_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_normal_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_normal_active.png new file mode 100755 index 0000000..aad079e Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_normal_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_normal_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_normal_inactive.png new file mode 100755 index 0000000..5f3e655 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/titlebar/sticky_normal_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol.png new file mode 100755 index 0000000..8fb9622 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol_low.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol_low.png new file mode 100755 index 0000000..32ad78f Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol_low.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol_mute.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol_mute.png new file mode 100755 index 0000000..77148fb Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol_mute.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol_no.png b/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol_no.png new file mode 100755 index 0000000..f22ed63 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/icons/vol_no.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornerne.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornerne.png new file mode 100755 index 0000000..f6014fd Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornerne.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornernw.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornernw.png new file mode 100755 index 0000000..cdc085b Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornernw.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornerse.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornerse.png new file mode 100755 index 0000000..393202f Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornerse.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornersw.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornersw.png new file mode 100755 index 0000000..09298f5 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/cornersw.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/dwindle.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/dwindle.png new file mode 100755 index 0000000..6091e80 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/dwindle.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/fairh.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/fairh.png new file mode 100755 index 0000000..cf96a98 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/fairh.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/fairv.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/fairv.png new file mode 100755 index 0000000..7ce1e6f Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/fairv.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/floating.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/floating.png new file mode 100755 index 0000000..6db461c Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/floating.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/fullscreen.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/fullscreen.png new file mode 100755 index 0000000..11a0c89 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/fullscreen.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/magnifier.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/magnifier.png new file mode 100755 index 0000000..a765ad0 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/magnifier.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/max.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/max.png new file mode 100755 index 0000000..95e4774 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/max.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/spiral.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/spiral.png new file mode 100755 index 0000000..249e80d Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/spiral.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tile.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tile.png new file mode 100755 index 0000000..410e2b0 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tile.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tilebottom.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tilebottom.png new file mode 100755 index 0000000..f957c74 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tilebottom.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tileleft.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tileleft.png new file mode 100755 index 0000000..c269e71 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tileleft.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tiletop.png b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tiletop.png new file mode 100755 index 0000000..4d21c20 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/layouts/tiletop.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/taglist/squarefz.png b/stow_home/awesome/.config/awesome/themes/zenburn/taglist/squarefz.png new file mode 100755 index 0000000..5724708 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/taglist/squarefz.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/taglist/squarez.png b/stow_home/awesome/.config/awesome/themes/zenburn/taglist/squarez.png new file mode 100755 index 0000000..517f937 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/taglist/squarez.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/theme.lua b/stow_home/awesome/.config/awesome/themes/zenburn/theme.lua new file mode 100755 index 0000000..d97253d --- /dev/null +++ b/stow_home/awesome/.config/awesome/themes/zenburn/theme.lua @@ -0,0 +1,130 @@ +------------------------------- +-- "Zenburn" awesome theme -- +-- By Adrian C. (anrxc) -- +------------------------------- + +local themes_path = require("gears.filesystem").get_themes_dir() +local dpi = require("beautiful.xresources").apply_dpi +local lain = require("lain") +local awful = require("awful") +local wibox = require("wibox") + +-- {{{ Main +local theme = {} +theme.wallpaper = themes_path .. "zenburn/darkpcnordwall.png" +-- }}} + +-- {{{ Styles + +-- {{{ Colors +theme.font = "mononoki Nerd Font 11" +theme.taglist_font = "Roboto Mono Nerd Font 13" +theme.fg_normal = "#eceff4" -- white +theme.fg_focus = "#434c5e" -- dark blue not so +theme.fg_urgent = "#b48ead" -- purple +theme.bg_normal = "#2e3440" -- dark blue +theme.bg_focus = "#a3be8c" -- green +theme.bg_urgent = "#b48ead" + +theme.taglist_fg_focus = "#282a36" + +theme.tasklist_bg_focus = "#4c566a" -- dark light blue +theme.tasklist_fg_focus = "#a3be8c" -- green + +theme.titlebar_bg_focus = "#3F3F3F" +theme.titlebar_bg_normal = "#3F3F3F" +theme.titlebar_bg_focus = theme.bg_focus +theme.titlebar_bg_normal = theme.bg_normal +theme.titlebar_fg_focus = theme.fg_focus +-- }}} + +-- {{{ Borders +theme.border_width = 1 +theme.border_normal = "#5e81ac" +theme.border_focus = "#bf616a" +theme.border_marked = "#CC9393" +theme.useless_gap = 0 +-- }}} + +-- {{{ Titlebars +theme.titlebar_bg_focus = "#3F3F3F" +theme.titlebar_bg_normal = "#3F3F3F" + +theme.tasklist_plain_task_name = true +theme.tasklist_disable_icon = true +-- }}} + +-- There are other variable sets +-- overriding the default one when +-- defined, the sets are: +-- [taglist|tasklist]_[bg|fg]_[focus|urgent|occupied|empty|volatile] +-- titlebar_[normal|focus] +-- tooltip_[font|opacity|fg_color|bg_color|border_width|border_color] +-- Example: +--theme.taglist_bg_focus = "#CC9393" +-- }}} + +-- {{{ Widgets +-- You can add as many variables as +-- you wish and access them by using +-- beautiful.variable in your rc.lua +--theme.fg_widget = "#AECF96" +--theme.fg_center_widget = "#88A175" +--theme.fg_end_widget = "#FF5656" +--theme.bg_widget = "#494B4F" +--theme.border_widget = "#3F3F3F" +-- }}} + +-- {{{ Mouse finder +theme.mouse_finder_color = "#CC9393" +-- mouse_finder_[timeout|animate_timeout|radius|factor] +-- }}} + +-- {{{ Menu +-- Variables set for theming the menu: +-- menu_[bg|fg]_[normal|focus] +-- menu_[border_color|border_width] + +theme.menu_height = dpi(20) +theme.menu_width = dpi(130) +-- }}} + +-- {{{ Icons +-- {{{ Taglist +theme.taglist_squares_sel = themes_path .. "zenburn/taglist/squarefz.png" +theme.taglist_squares_unsel = themes_path .. "zenburn/taglist/squarez.png" +--theme.taglist_squares_resize = "false" +-- }}} + +-- {{{ Misc +theme.awesome_icon = themes_path .. "zenburn/icons/awesome.png" +theme.menu_submenu_icon = themes_path .. "zenburn/icons/submenu.png" +-- }}} + +-- {{{ Layout +theme.layout_tile = themes_path .. "zenburn/layouts/tile.png" +theme.layout_tileleft = themes_path .. "zenburn/layouts/tileleft.png" +theme.layout_tilebottom = themes_path .. "zenburn/layouts/tilebottom.png" +theme.layout_tiletop = themes_path .. "zenburn/layouts/tiletop.png" +theme.layout_fairv = themes_path .. "zenburn/layouts/fairv.png" +theme.layout_fairh = themes_path .. "zenburn/layouts/fairh.png" +theme.layout_spiral = themes_path .. "zenburn/layouts/spiral.png" +theme.layout_dwindle = themes_path .. "zenburn/layouts/dwindle.png" +theme.layout_max = themes_path .. "zenburn/layouts/max.png" +theme.layout_fullscreen = themes_path .. "zenburn/layouts/fullscreen.png" +theme.layout_magnifier = themes_path .. "zenburn/layouts/magnifier.png" +theme.layout_floating = themes_path .. "zenburn/layouts/floating.png" +theme.layout_cornernw = themes_path .. "zenburn/layouts/cornernw.png" +theme.layout_cornerne = themes_path .. "zenburn/layouts/cornerne.png" +theme.layout_cornersw = themes_path .. "zenburn/layouts/cornersw.png" +theme.layout_cornerse = themes_path .. "zenburn/layouts/cornerse.png" +-- }}} + +-- {{{ Titlebar + +-- }}} +-- }}} + +return theme + +-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/close_focus.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/close_focus.png new file mode 100755 index 0000000..9fc8ea2 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/close_focus.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/close_normal.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/close_normal.png new file mode 100755 index 0000000..6e6b645 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/close_normal.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_focus_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_focus_active.png new file mode 100755 index 0000000..044ba1d Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_focus_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_focus_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_focus_inactive.png new file mode 100755 index 0000000..94b0360 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_focus_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_normal_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_normal_active.png new file mode 100755 index 0000000..878a9fb Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_normal_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_normal_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_normal_inactive.png new file mode 100755 index 0000000..4147c7d Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/floating_normal_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_focus_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_focus_active.png new file mode 100755 index 0000000..e5af7e9 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_focus_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_focus_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_focus_inactive.png new file mode 100755 index 0000000..298751c Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_focus_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_normal_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_normal_active.png new file mode 100755 index 0000000..1dca071 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_normal_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_normal_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_normal_inactive.png new file mode 100755 index 0000000..f943ac7 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/maximized_normal_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_focus_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_focus_active.png new file mode 100755 index 0000000..b2a79bd Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_focus_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_focus_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_focus_inactive.png new file mode 100755 index 0000000..04bc63a Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_focus_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_normal_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_normal_active.png new file mode 100755 index 0000000..8d9cb5b Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_normal_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_normal_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_normal_inactive.png new file mode 100755 index 0000000..d383c77 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/ontop_normal_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_focus_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_focus_active.png new file mode 100755 index 0000000..bbba813 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_focus_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_focus_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_focus_inactive.png new file mode 100755 index 0000000..1a0c481 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_focus_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_normal_active.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_normal_active.png new file mode 100755 index 0000000..50a6d2b Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_normal_active.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_normal_inactive.png b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_normal_inactive.png new file mode 100755 index 0000000..ea09406 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/titlebar/sticky_normal_inactive.png differ diff --git a/stow_home/awesome/.config/awesome/themes/zenburn/zenburn-background.png b/stow_home/awesome/.config/awesome/themes/zenburn/zenburn-background.png new file mode 100755 index 0000000..6dd7df2 Binary files /dev/null and b/stow_home/awesome/.config/awesome/themes/zenburn/zenburn-background.png differ diff --git a/stow_home/bat/.config/bat/config b/stow_home/bat/.config/bat/config new file mode 100644 index 0000000..9f9ebe5 --- /dev/null +++ b/stow_home/bat/.config/bat/config @@ -0,0 +1,4 @@ +# Quite a simple config file right? +--theme="Nord" +--italic-text=always + diff --git a/stow_home/dunst/.config/dunst/dunstrc b/stow_home/dunst/.config/dunst/dunstrc new file mode 100644 index 0000000..787991a --- /dev/null +++ b/stow_home/dunst/.config/dunst/dunstrc @@ -0,0 +1,325 @@ +[global] + monitor = 0 + + follow = mouse + + geometry = "0x0-8+30" + + # Turn on the progess bar + progress_bar = true + + # Set the progress bar height. This includes the frame, so make sure + # it's at least twice as big as the frame width. + progress_bar_height = 5 + + # Set the frame width of the progress bar + progress_bar_frame_width = 1 + + # Set the minimum width for the progress bar + progress_bar_min_width = 150 + + # Set the maximum width for the progress bar + progress_bar_max_width = 300 + + + # Show how many messages are currently hidden (because of geometry). + indicate_hidden = yes + + # Shrink window if it's smaller than the width. Will be ignored if + # width is 0. + shrink = no + + # The transparency of the window. Range: [0; 100]. + # This option will only work if a compositing window manager is + # present (e.g. xcompmgr, compiz, etc.). + transparency = 0 + + # The height of the entire notification. If the height is smaller + # than the font height and padding combined, it will be raised + # to the font height and padding. + notification_height = 2 + + # Draw a line of "separator_height" pixel height between two + # notifications. + # Set to 0 to disable. + separator_height = 3 + + # Padding between text and separator. + padding = 8 + + # Horizontal padding. + horizontal_padding = 8 + + # Padding between text and icon. + text_icon_padding = 0 + + # Defines width in pixels of frame around the notification window. + # Set to 0 to disable. + frame_width = 3 + + # Defines color of the frame around the notification window. + frame_color = "#a3be8c" +#bar_color[1] = rgb:2e/34/40,rgb:eb/cb/8b,rgb:a3/be/8c,rgb:bf/61/6a,rgb:b4/8e/ + # Define a color for the separator. + # possible values are: + # * auto: dunst tries to find a color fitting to the background; + # * foreground: use the same color as the foreground; + # * frame: use the same color as the frame; + # * anything else will be interpreted as a X color. + separator_color = auto + + # Sort messages by urgency. + sort = yes + + # Don't remove messages, if the user is idle (no mouse or keyboard input) + # for longer than idle_threshold seconds. + # Set to 0 to disable. + # A client can set the 'transient' hint to bypass this. See the rules + # section for how to disable this if necessary + idle_threshold = 120 + + ### Text ### + + font = BlexMono Nerd Font 10 + + # The spacing between lines. If the height is smaller than the + # font height, it will get raised to the font height. + line_height = 0 + + # Possible values are: + # full: Allow a small subset of html markup in notifications: + # bold + # italic + # strikethrough + # underline + # + # For a complete reference see + # . + # + # strip: This setting is provided for compatibility with some broken + # clients that send markup even though it's not enabled on the + # server. Dunst will try to strip the markup but the parsing is + # simplistic so using this option outside of matching rules for + # specific applications *IS GREATLY DISCOURAGED*. + # + # no: Disable markup parsing, incoming notifications will be treated as + # plain text. Dunst will not advertise that it has the body-markup + # capability if this is set as a global setting. + # + # It's important to note that markup inside the format option will be parsed + # regardless of what this is set to. + markup = full + + # The format of the message. Possible variables are: + # %a appname + # %s summary + # %b body + # %i iconname (including its path) + # %I iconname (without its path) + # %p progress value if set ([ 0%] to [100%]) or nothing + # %n progress value if set without any extra characters + # %% Literal % + # Markup is allowed + format = "%s\n%b" + + # Alignment of message text. + # Possible values are "left", "center" and "right". + alignment = left + + # Vertical alignment of message text and icon. + # Possible values are "top", "center" and "bottom". + vertical_alignment = center + + # Show age of message if message is older than show_age_threshold + # seconds. + # Set to -1 to disable. + show_age_threshold = 60 + + # Split notifications into multiple lines if they don't fit into + # geometry. + word_wrap = yes + + # When word_wrap is set to no, specify where to make an ellipsis in long lines. + # Possible values are "start", "middle" and "end". + ellipsize = middle + + # Ignore newlines '\n' in notifications. + ignore_newline = no + + # Stack together notifications with the same content + stack_duplicates = true + + # Hide the count of stacked notifications with the same content + hide_duplicate_count = false + + # Display indicators for URLs (U) and actions (A). + show_indicators = yes + + ### Icons ### + + # Align icons left/right/off + icon_position = left + + # Scale small icons up to this size, set to 0 to disable. Helpful + # for e.g. small files or high-dpi screens. In case of conflict, + # max_icon_size takes precedence over this. + min_icon_size = 20 + + # Scale larger icons down to this size, set to 0 to disable + max_icon_size = 22 + + # Paths to default icons. + icon_path = /usr/share/icons/gnome/16x16/status/:/usr/share/icons/gnome/16x16/devices/ + + ### History ### + + # Should a notification popped up from history be sticky or timeout + # as if it would normally do. + sticky_history = yes + + # Maximum amount of notifications kept in history + history_length = 20 + + ### Misc/Advanced ### + + # dmenu path. + dmenu = /usr/bin/dmenu -p dunst: + + # Browser for opening urls in context menu. + browser = /usr/bin/firefox -new-tab + + # Always run rule-defined scripts, even if the notification is suppressed + always_run_script = true + + # Define the title of the windows spawned by dunst + title = Dunst + + # Define the class of the windows spawned by dunst + class = Dunst + + # Print a notification on startup. + # This is mainly for error detection, since dbus (re-)starts dunst + # automatically after a crash. + startup_notification = false + + # Manage dunst's desire for talking + # Can be one of the following values: + # crit: Critical features. Dunst aborts + # warn: Only non-fatal warnings + # mesg: Important Messages + # info: all unimportant stuff + # debug: all less than unimportant stuff + verbosity = mesg + + # Define the corner radius of the notification window + # in pixel size. If the radius is 0, you have no rounded + # corners. + # The radius will be automatically lowered if it exceeds half of the + # notification height to avoid clipping text and/or icons. + corner_radius = 7 + + # Ignore the dbus closeNotification message. + # Useful to enforce the timeout set by dunst configuration. Without this + # parameter, an application may close the notification sent before the + # user defined timeout. + ignore_dbusclose = false + + ### Wayland ### + # These settings are Wayland-specific. They have no effect when using X11 + + # Uncomment this if you want to let notications appear under fullscreen + # applications (default: overlay) + # layer = top + + # Set this to true to use X11 output on Wayland. + force_xwayland = false + + ### Legacy + + # Use the Xinerama extension instead of RandR for multi-monitor support. + # This setting is provided for compatibility with older nVidia drivers that + # do not support RandR and using it on systems that support RandR is highly + # discouraged. + # + # By enabling this setting dunst will not be able to detect when a monitor + # is connected or disconnected which might break follow mode if the screen + # layout changes. + force_xinerama = false + + ### mouse + + # Defines list of actions for each mouse event + # Possible values are: + # * none: Don't do anything. + # * do_action: If the notification has exactly one action, or one is marked as default, + # invoke it. If there are multiple and no default, open the context menu. + # * close_current: Close current notification. + # * close_all: Close all notifications. + # These values can be strung together for each mouse event, and + # will be executed in sequence. + mouse_left_click = do_action, close_current + mouse_middle_click = close_all + mouse_right_click = close_current + +# Experimental features that may or may not work correctly. Do not expect them +# to have a consistent behaviour across releases. +[experimental] + # Calculate the dpi to use on a per-monitor basis. + # If this setting is enabled the Xft.dpi value will be ignored and instead + # dunst will attempt to calculate an appropriate dpi value for each monitor + # using the resolution and physical size. This might be useful in setups + # where there are multiple screens with very different dpi values. + per_monitor_dpi = false + +# The internal keyboard shortcut support in dunst is now considered deprecated +# and should be replaced by dunstctl calls. You can use the configuration of your +# WM or DE to bind these to shortcuts of your choice. +# Check the dunstctl manual page for more info. +[shortcuts] + + # Shortcuts are specified as [modifier+][modifier+]...key + # Available modifiers are "ctrl", "mod1" (the alt-key), "mod2", + # "mod3" and "mod4" (windows-key). + # Xev might be helpful to find names for keys. + + # Close notification. Equivalent dunstctl command: + # dunstctl close + # close = ctrl+space + + # Close all notifications. Equivalent dunstctl command: + # dunstctl close-all + # close_all = ctrl+shift+space + + # Redisplay last message(s). Equivalent dunstctl command: + # dunstctl history-pop + # history = ctrl+grave + + # Context menu. Equivalent dunstctl command: + # dunstctl context + # context = ctrl+shift+period + +[urgency_low] + # IMPORTANT: colors have to be defined in quotation marks. + # Otherwise the "#" and following would be interpreted as a comment. + background = "#434c5e" + foreground = "eceff4" + timeout = 6 + # Icon for notifications with low urgency, uncomment to enable + #icon = /path/to/icon + +[urgency_normal] + background = "#434c5e" + foreground = "#eceff4" + timeout = 6 + # Icon for notifications with normal urgency, uncomment to enable + #icon = /path/to/icon + +[urgency_critical] + background = "#900000" + foreground = "#eceff4" + frame_color = "#ff0000" + timeout = 0 + # Icon for notifications with critical urgency, uncomment to enable + #icon = /path/to/icon + + diff --git a/stow_home/nvim/.config/nvim/autoload/plug.vim b/stow_home/nvim/.config/nvim/autoload/plug.vim new file mode 100644 index 0000000..6a958cb --- /dev/null +++ b/stow_home/nvim/.config/nvim/autoload/plug.vim @@ -0,0 +1,2801 @@ +" vim-plug: Vim plugin manager +" ============================ +" +" Download plug.vim and put it in ~/.vim/autoload +" +" curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ +" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim +" +" Edit your .vimrc +" +" call plug#begin('~/.vim/plugged') +" +" " Make sure you use single quotes +" +" " Shorthand notation; fetches https://github.com/junegunn/vim-easy-align +" Plug 'junegunn/vim-easy-align' +" +" " Any valid git URL is allowed +" Plug 'https://github.com/junegunn/vim-github-dashboard.git' +" +" " Multiple Plug commands can be written in a single line using | separators +" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets' +" +" " On-demand loading +" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } +" Plug 'tpope/vim-fireplace', { 'for': 'clojure' } +" +" " Using a non-default branch +" Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' } +" +" " Using a tagged release; wildcard allowed (requires git 1.9.2 or above) +" Plug 'fatih/vim-go', { 'tag': '*' } +" +" " Plugin options +" Plug 'nsf/gocode', { 'tag': 'v.20150303', 'rtp': 'vim' } +" +" " Plugin outside ~/.vim/plugged with post-update hook +" Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } +" +" " Unmanaged plugin (manually installed and updated) +" Plug '~/my-prototype-plugin' +" +" " Initialize plugin system +" call plug#end() +" +" Then reload .vimrc and :PlugInstall to install plugins. +" +" Plug options: +" +"| Option | Description | +"| ----------------------- | ------------------------------------------------ | +"| `branch`/`tag`/`commit` | Branch/tag/commit of the repository to use | +"| `rtp` | Subdirectory that contains Vim plugin | +"| `dir` | Custom directory for the plugin | +"| `as` | Use different name for the plugin | +"| `do` | Post-update hook (string or funcref) | +"| `on` | On-demand loading: Commands or ``-mappings | +"| `for` | On-demand loading: File types | +"| `frozen` | Do not update unless explicitly specified | +" +" More information: https://github.com/junegunn/vim-plug +" +" +" Copyright (c) 2017 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +if exists('g:loaded_plug') + finish +endif +let g:loaded_plug = 1 + +let s:cpo_save = &cpo +set cpo&vim + +let s:plug_src = 'https://github.com/junegunn/vim-plug.git' +let s:plug_tab = get(s:, 'plug_tab', -1) +let s:plug_buf = get(s:, 'plug_buf', -1) +let s:mac_gui = has('gui_macvim') && has('gui_running') +let s:is_win = has('win32') +let s:nvim = has('nvim-0.2') || (has('nvim') && exists('*jobwait') && !s:is_win) +let s:vim8 = has('patch-8.0.0039') && exists('*job_start') +if s:is_win && &shellslash + set noshellslash + let s:me = resolve(expand(':p')) + set shellslash +else + let s:me = resolve(expand(':p')) +endif +let s:base_spec = { 'branch': '', 'frozen': 0 } +let s:TYPE = { +\ 'string': type(''), +\ 'list': type([]), +\ 'dict': type({}), +\ 'funcref': type(function('call')) +\ } +let s:loaded = get(s:, 'loaded', {}) +let s:triggers = get(s:, 'triggers', {}) + +function! s:is_powershell(shell) + return a:shell =~# 'powershell\(\.exe\)\?$' || a:shell =~# 'pwsh\(\.exe\)\?$' +endfunction + +function! s:isabsolute(dir) abort + return a:dir =~# '^/' || (has('win32') && a:dir =~? '^\%(\\\|[A-Z]:\)') +endfunction + +function! s:git_dir(dir) abort + let gitdir = s:trim(a:dir) . '/.git' + if isdirectory(gitdir) + return gitdir + endif + if !filereadable(gitdir) + return '' + endif + let gitdir = matchstr(get(readfile(gitdir), 0, ''), '^gitdir: \zs.*') + if len(gitdir) && !s:isabsolute(gitdir) + let gitdir = a:dir . '/' . gitdir + endif + return isdirectory(gitdir) ? gitdir : '' +endfunction + +function! s:git_origin_url(dir) abort + let gitdir = s:git_dir(a:dir) + let config = gitdir . '/config' + if empty(gitdir) || !filereadable(config) + return '' + endif + return matchstr(join(readfile(config)), '\[remote "origin"\].\{-}url\s*=\s*\zs\S*\ze') +endfunction + +function! s:git_revision(dir) abort + let gitdir = s:git_dir(a:dir) + let head = gitdir . '/HEAD' + if empty(gitdir) || !filereadable(head) + return '' + endif + + let line = get(readfile(head), 0, '') + let ref = matchstr(line, '^ref: \zs.*') + if empty(ref) + return line + endif + + if filereadable(gitdir . '/' . ref) + return get(readfile(gitdir . '/' . ref), 0, '') + endif + + if filereadable(gitdir . '/packed-refs') + for line in readfile(gitdir . '/packed-refs') + if line =~# ' ' . ref + return matchstr(line, '^[0-9a-f]*') + endif + endfor + endif + + return '' +endfunction + +function! s:git_local_branch(dir) abort + let gitdir = s:git_dir(a:dir) + let head = gitdir . '/HEAD' + if empty(gitdir) || !filereadable(head) + return '' + endif + let branch = matchstr(get(readfile(head), 0, ''), '^ref: refs/heads/\zs.*') + return len(branch) ? branch : 'HEAD' +endfunction + +function! s:git_origin_branch(spec) + if len(a:spec.branch) + return a:spec.branch + endif + + " The file may not be present if this is a local repository + let gitdir = s:git_dir(a:spec.dir) + let origin_head = gitdir.'/refs/remotes/origin/HEAD' + if len(gitdir) && filereadable(origin_head) + return matchstr(get(readfile(origin_head), 0, ''), + \ '^ref: refs/remotes/origin/\zs.*') + endif + + " The command may not return the name of a branch in detached HEAD state + let result = s:lines(s:system('git symbolic-ref --short HEAD', a:spec.dir)) + return v:shell_error ? '' : result[-1] +endfunction + +if s:is_win + function! s:plug_call(fn, ...) + let shellslash = &shellslash + try + set noshellslash + return call(a:fn, a:000) + finally + let &shellslash = shellslash + endtry + endfunction +else + function! s:plug_call(fn, ...) + return call(a:fn, a:000) + endfunction +endif + +function! s:plug_getcwd() + return s:plug_call('getcwd') +endfunction + +function! s:plug_fnamemodify(fname, mods) + return s:plug_call('fnamemodify', a:fname, a:mods) +endfunction + +function! s:plug_expand(fmt) + return s:plug_call('expand', a:fmt, 1) +endfunction + +function! s:plug_tempname() + return s:plug_call('tempname') +endfunction + +function! plug#begin(...) + if a:0 > 0 + let s:plug_home_org = a:1 + let home = s:path(s:plug_fnamemodify(s:plug_expand(a:1), ':p')) + elseif exists('g:plug_home') + let home = s:path(g:plug_home) + elseif !empty(&rtp) + let home = s:path(split(&rtp, ',')[0]) . '/plugged' + else + return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.') + endif + if s:plug_fnamemodify(home, ':t') ==# 'plugin' && s:plug_fnamemodify(home, ':h') ==# s:first_rtp + return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.') + endif + + let g:plug_home = home + let g:plugs = {} + let g:plugs_order = [] + let s:triggers = {} + + call s:define_commands() + return 1 +endfunction + +function! s:define_commands() + command! -nargs=+ -bar Plug call plug#() + if !executable('git') + return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') + endif + if has('win32') + \ && &shellslash + \ && (&shell =~# 'cmd\(\.exe\)\?$' || s:is_powershell(&shell)) + return s:err('vim-plug does not support shell, ' . &shell . ', when shellslash is set.') + endif + if !has('nvim') + \ && (has('win32') || has('win32unix')) + \ && !has('multi_byte') + return s:err('Vim needs +multi_byte feature on Windows to run shell commands. Enable +iconv for best results.') + endif + command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install(0, []) + command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update(0, []) + command! -nargs=0 -bar -bang PlugClean call s:clean(0) + command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:esc(s:me) | endif + command! -nargs=0 -bar PlugStatus call s:status() + command! -nargs=0 -bar PlugDiff call s:diff() + command! -nargs=? -bar -bang -complete=file PlugSnapshot call s:snapshot(0, ) +endfunction + +function! s:to_a(v) + return type(a:v) == s:TYPE.list ? a:v : [a:v] +endfunction + +function! s:to_s(v) + return type(a:v) == s:TYPE.string ? a:v : join(a:v, "\n") . "\n" +endfunction + +function! s:glob(from, pattern) + return s:lines(globpath(a:from, a:pattern)) +endfunction + +function! s:source(from, ...) + let found = 0 + for pattern in a:000 + for vim in s:glob(a:from, pattern) + execute 'source' s:esc(vim) + let found = 1 + endfor + endfor + return found +endfunction + +function! s:assoc(dict, key, val) + let a:dict[a:key] = add(get(a:dict, a:key, []), a:val) +endfunction + +function! s:ask(message, ...) + call inputsave() + echohl WarningMsg + let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) ')) + echohl None + call inputrestore() + echo "\r" + return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0 +endfunction + +function! s:ask_no_interrupt(...) + try + return call('s:ask', a:000) + catch + return 0 + endtry +endfunction + +function! s:lazy(plug, opt) + return has_key(a:plug, a:opt) && + \ (empty(s:to_a(a:plug[a:opt])) || + \ !isdirectory(a:plug.dir) || + \ len(s:glob(s:rtp(a:plug), 'plugin')) || + \ len(s:glob(s:rtp(a:plug), 'after/plugin'))) +endfunction + +function! plug#end() + if !exists('g:plugs') + return s:err('plug#end() called without calling plug#begin() first') + endif + + if exists('#PlugLOD') + augroup PlugLOD + autocmd! + augroup END + augroup! PlugLOD + endif + let lod = { 'ft': {}, 'map': {}, 'cmd': {} } + + if exists('g:did_load_filetypes') + filetype off + endif + for name in g:plugs_order + if !has_key(g:plugs, name) + continue + endif + let plug = g:plugs[name] + if get(s:loaded, name, 0) || !s:lazy(plug, 'on') && !s:lazy(plug, 'for') + let s:loaded[name] = 1 + continue + endif + + if has_key(plug, 'on') + let s:triggers[name] = { 'map': [], 'cmd': [] } + for cmd in s:to_a(plug.on) + if cmd =~? '^.\+' + if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) + call s:assoc(lod.map, cmd, name) + endif + call add(s:triggers[name].map, cmd) + elseif cmd =~# '^[A-Z]' + let cmd = substitute(cmd, '!*$', '', '') + if exists(':'.cmd) != 2 + call s:assoc(lod.cmd, cmd, name) + endif + call add(s:triggers[name].cmd, cmd) + else + call s:err('Invalid `on` option: '.cmd. + \ '. Should start with an uppercase letter or ``.') + endif + endfor + endif + + if has_key(plug, 'for') + let types = s:to_a(plug.for) + if !empty(types) + augroup filetypedetect + call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim') + augroup END + endif + for type in types + call s:assoc(lod.ft, type, name) + endfor + endif + endfor + + for [cmd, names] in items(lod.cmd) + execute printf( + \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "", , , , %s)', + \ cmd, string(cmd), string(names)) + endfor + + for [map, names] in items(lod.map) + for [mode, map_prefix, key_prefix] in + \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] + execute printf( + \ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")', + \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix) + endfor + endfor + + for [ft, names] in items(lod.ft) + augroup PlugLOD + execute printf('autocmd FileType %s call lod_ft(%s, %s)', + \ ft, string(ft), string(names)) + augroup END + endfor + + call s:reorg_rtp() + filetype plugin indent on + if has('vim_starting') + if has('syntax') && !exists('g:syntax_on') + syntax enable + end + else + call s:reload_plugins() + endif +endfunction + +function! s:loaded_names() + return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)') +endfunction + +function! s:load_plugin(spec) + call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim') +endfunction + +function! s:reload_plugins() + for name in s:loaded_names() + call s:load_plugin(g:plugs[name]) + endfor +endfunction + +function! s:trim(str) + return substitute(a:str, '[\/]\+$', '', '') +endfunction + +function! s:version_requirement(val, min) + for idx in range(0, len(a:min) - 1) + let v = get(a:val, idx, 0) + if v < a:min[idx] | return 0 + elseif v > a:min[idx] | return 1 + endif + endfor + return 1 +endfunction + +function! s:git_version_requirement(...) + if !exists('s:git_version') + let s:git_version = map(split(split(s:system(['git', '--version']))[2], '\.'), 'str2nr(v:val)') + endif + return s:version_requirement(s:git_version, a:000) +endfunction + +function! s:progress_opt(base) + return a:base && !s:is_win && + \ s:git_version_requirement(1, 7, 1) ? '--progress' : '' +endfunction + +function! s:rtp(spec) + return s:path(a:spec.dir . get(a:spec, 'rtp', '')) +endfunction + +if s:is_win + function! s:path(path) + return s:trim(substitute(a:path, '/', '\', 'g')) + endfunction + + function! s:dirpath(path) + return s:path(a:path) . '\' + endfunction + + function! s:is_local_plug(repo) + return a:repo =~? '^[a-z]:\|^[%~]' + endfunction + + " Copied from fzf + function! s:wrap_cmds(cmds) + let cmds = [ + \ '@echo off', + \ 'setlocal enabledelayedexpansion'] + \ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) + \ + ['endlocal'] + if has('iconv') + if !exists('s:codepage') + let s:codepage = libcallnr('kernel32.dll', 'GetACP', 0) + endif + return map(cmds, printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage)) + endif + return map(cmds, 'v:val."\r"') + endfunction + + function! s:batchfile(cmd) + let batchfile = s:plug_tempname().'.bat' + call writefile(s:wrap_cmds(a:cmd), batchfile) + let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 0}) + if s:is_powershell(&shell) + let cmd = '& ' . cmd + endif + return [batchfile, cmd] + endfunction +else + function! s:path(path) + return s:trim(a:path) + endfunction + + function! s:dirpath(path) + return substitute(a:path, '[/\\]*$', '/', '') + endfunction + + function! s:is_local_plug(repo) + return a:repo[0] =~ '[/$~]' + endfunction +endif + +function! s:err(msg) + echohl ErrorMsg + echom '[vim-plug] '.a:msg + echohl None +endfunction + +function! s:warn(cmd, msg) + echohl WarningMsg + execute a:cmd 'a:msg' + echohl None +endfunction + +function! s:esc(path) + return escape(a:path, ' ') +endfunction + +function! s:escrtp(path) + return escape(a:path, ' ,') +endfunction + +function! s:remove_rtp() + for name in s:loaded_names() + let rtp = s:rtp(g:plugs[name]) + execute 'set rtp-='.s:escrtp(rtp) + let after = globpath(rtp, 'after') + if isdirectory(after) + execute 'set rtp-='.s:escrtp(after) + endif + endfor +endfunction + +function! s:reorg_rtp() + if !empty(s:first_rtp) + execute 'set rtp-='.s:first_rtp + execute 'set rtp-='.s:last_rtp + endif + + " &rtp is modified from outside + if exists('s:prtp') && s:prtp !=# &rtp + call s:remove_rtp() + unlet! s:middle + endif + + let s:middle = get(s:, 'middle', &rtp) + let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])') + let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), '!empty(v:val)') + let rtp = join(map(rtps, 'escape(v:val, ",")'), ',') + \ . ','.s:middle.',' + \ . join(map(afters, 'escape(v:val, ",")'), ',') + let &rtp = substitute(substitute(rtp, ',,*', ',', 'g'), '^,\|,$', '', 'g') + let s:prtp = &rtp + + if !empty(s:first_rtp) + execute 'set rtp^='.s:first_rtp + execute 'set rtp+='.s:last_rtp + endif +endfunction + +function! s:doautocmd(...) + if exists('#'.join(a:000, '#')) + execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '' : '') join(a:000) + endif +endfunction + +function! s:dobufread(names) + for name in a:names + let path = s:rtp(g:plugs[name]) + for dir in ['ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin'] + if len(finddir(dir, path)) + if exists('#BufRead') + doautocmd BufRead + endif + return + endif + endfor + endfor +endfunction + +function! plug#load(...) + if a:0 == 0 + return s:err('Argument missing: plugin name(s) required') + endif + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + let names = a:0 == 1 && type(a:1) == s:TYPE.list ? a:1 : a:000 + let unknowns = filter(copy(names), '!has_key(g:plugs, v:val)') + if !empty(unknowns) + let s = len(unknowns) > 1 ? 's' : '' + return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', '))) + end + let unloaded = filter(copy(names), '!get(s:loaded, v:val, 0)') + if !empty(unloaded) + for name in unloaded + call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + endfor + call s:dobufread(unloaded) + return 1 + end + return 0 +endfunction + +function! s:remove_triggers(name) + if !has_key(s:triggers, a:name) + return + endif + for cmd in s:triggers[a:name].cmd + execute 'silent! delc' cmd + endfor + for map in s:triggers[a:name].map + execute 'silent! unmap' map + execute 'silent! iunmap' map + endfor + call remove(s:triggers, a:name) +endfunction + +function! s:lod(names, types, ...) + for name in a:names + call s:remove_triggers(name) + let s:loaded[name] = 1 + endfor + call s:reorg_rtp() + + for name in a:names + let rtp = s:rtp(g:plugs[name]) + for dir in a:types + call s:source(rtp, dir.'/**/*.vim') + endfor + if a:0 + if !s:source(rtp, a:1) && !empty(s:glob(rtp, a:2)) + execute 'runtime' a:1 + endif + call s:source(rtp, a:2) + endif + call s:doautocmd('User', name) + endfor +endfunction + +function! s:lod_ft(pat, names) + let syn = 'syntax/'.a:pat.'.vim' + call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn) + execute 'autocmd! PlugLOD FileType' a:pat + call s:doautocmd('filetypeplugin', 'FileType') + call s:doautocmd('filetypeindent', 'FileType') +endfunction + +function! s:lod_cmd(cmd, bang, l1, l2, args, names) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) +endfunction + +function! s:lod_map(map, names, with_prefix, prefix) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + let extra = '' + while 1 + let c = getchar(0) + if c == 0 + break + endif + let extra .= nr2char(c) + endwhile + + if a:with_prefix + let prefix = v:count ? v:count : '' + let prefix .= '"'.v:register.a:prefix + if mode(1) == 'no' + if v:operator == 'c' + let prefix = "\" . prefix + endif + let prefix .= v:operator + endif + call feedkeys(prefix, 'n') + endif + call feedkeys(substitute(a:map, '^', "\", '') . extra) +endfunction + +function! plug#(repo, ...) + if a:0 > 1 + return s:err('Invalid number of arguments (1..2)') + endif + + try + let repo = s:trim(a:repo) + let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec + let name = get(opts, 'as', s:plug_fnamemodify(repo, ':t:s?\.git$??')) + let spec = extend(s:infer_properties(name, repo), opts) + if !has_key(g:plugs, name) + call add(g:plugs_order, name) + endif + let g:plugs[name] = spec + let s:loaded[name] = get(s:loaded, name, 0) + catch + return s:err(repo . ' ' . v:exception) + endtry +endfunction + +function! s:parse_options(arg) + let opts = copy(s:base_spec) + let type = type(a:arg) + let opt_errfmt = 'Invalid argument for "%s" option of :Plug (expected: %s)' + if type == s:TYPE.string + if empty(a:arg) + throw printf(opt_errfmt, 'tag', 'string') + endif + let opts.tag = a:arg + elseif type == s:TYPE.dict + for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as'] + if has_key(a:arg, opt) + \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt])) + throw printf(opt_errfmt, opt, 'string') + endif + endfor + for opt in ['on', 'for'] + if has_key(a:arg, opt) + \ && type(a:arg[opt]) != s:TYPE.list + \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt])) + throw printf(opt_errfmt, opt, 'string or list') + endif + endfor + if has_key(a:arg, 'do') + \ && type(a:arg.do) != s:TYPE.funcref + \ && (type(a:arg.do) != s:TYPE.string || empty(a:arg.do)) + throw printf(opt_errfmt, 'do', 'string or funcref') + endif + call extend(opts, a:arg) + if has_key(opts, 'dir') + let opts.dir = s:dirpath(s:plug_expand(opts.dir)) + endif + else + throw 'Invalid argument type (expected: string or dictionary)' + endif + return opts +endfunction + +function! s:infer_properties(name, repo) + let repo = a:repo + if s:is_local_plug(repo) + return { 'dir': s:dirpath(s:plug_expand(repo)) } + else + if repo =~ ':' + let uri = repo + else + if repo !~ '/' + throw printf('Invalid argument: %s (implicit `vim-scripts'' expansion is deprecated)', repo) + endif + let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git') + let uri = printf(fmt, repo) + endif + return { 'dir': s:dirpath(g:plug_home.'/'.a:name), 'uri': uri } + endif +endfunction + +function! s:install(force, names) + call s:update_impl(0, a:force, a:names) +endfunction + +function! s:update(force, names) + call s:update_impl(1, a:force, a:names) +endfunction + +function! plug#helptags() + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + for spec in values(g:plugs) + let docd = join([s:rtp(spec), 'doc'], '/') + if isdirectory(docd) + silent! execute 'helptags' s:esc(docd) + endif + endfor + return 1 +endfunction + +function! s:syntax() + syntax clear + syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber + syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX + syn match plugNumber /[0-9]\+[0-9.]*/ contained + syn match plugBracket /[[\]]/ contained + syn match plugX /x/ contained + syn match plugDash /^-\{1}\ / + syn match plugPlus /^+/ + syn match plugStar /^*/ + syn match plugMessage /\(^- \)\@<=.*/ + syn match plugName /\(^- \)\@<=[^ ]*:/ + syn match plugSha /\%(: \)\@<=[0-9a-f]\{4,}$/ + syn match plugTag /(tag: [^)]\+)/ + syn match plugInstall /\(^+ \)\@<=[^:]*/ + syn match plugUpdate /\(^* \)\@<=[^:]*/ + syn match plugCommit /^ \X*[0-9a-f]\{7,9} .*/ contains=plugRelDate,plugEdge,plugTag + syn match plugEdge /^ \X\+$/ + syn match plugEdge /^ \X*/ contained nextgroup=plugSha + syn match plugSha /[0-9a-f]\{7,9}/ contained + syn match plugRelDate /([^)]*)$/ contained + syn match plugNotLoaded /(not loaded)$/ + syn match plugError /^x.*/ + syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/ + syn match plugH2 /^.*:\n-\+$/ + syn match plugH2 /^-\{2,}/ + syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean + hi def link plug1 Title + hi def link plug2 Repeat + hi def link plugH2 Type + hi def link plugX Exception + hi def link plugBracket Structure + hi def link plugNumber Number + + hi def link plugDash Special + hi def link plugPlus Constant + hi def link plugStar Boolean + + hi def link plugMessage Function + hi def link plugName Label + hi def link plugInstall Function + hi def link plugUpdate Type + + hi def link plugError Error + hi def link plugDeleted Ignore + hi def link plugRelDate Comment + hi def link plugEdge PreProc + hi def link plugSha Identifier + hi def link plugTag Constant + + hi def link plugNotLoaded Comment +endfunction + +function! s:lpad(str, len) + return a:str . repeat(' ', a:len - len(a:str)) +endfunction + +function! s:lines(msg) + return split(a:msg, "[\r\n]") +endfunction + +function! s:lastline(msg) + return get(s:lines(a:msg), -1, '') +endfunction + +function! s:new_window() + execute get(g:, 'plug_window', 'vertical topleft new') +endfunction + +function! s:plug_window_exists() + let buflist = tabpagebuflist(s:plug_tab) + return !empty(buflist) && index(buflist, s:plug_buf) >= 0 +endfunction + +function! s:switch_in() + if !s:plug_window_exists() + return 0 + endif + + if winbufnr(0) != s:plug_buf + let s:pos = [tabpagenr(), winnr(), winsaveview()] + execute 'normal!' s:plug_tab.'gt' + let winnr = bufwinnr(s:plug_buf) + execute winnr.'wincmd w' + call add(s:pos, winsaveview()) + else + let s:pos = [winsaveview()] + endif + + setlocal modifiable + return 1 +endfunction + +function! s:switch_out(...) + call winrestview(s:pos[-1]) + setlocal nomodifiable + if a:0 > 0 + execute a:1 + endif + + if len(s:pos) > 1 + execute 'normal!' s:pos[0].'gt' + execute s:pos[1] 'wincmd w' + call winrestview(s:pos[2]) + endif +endfunction + +function! s:finish_bindings() + nnoremap R :call retry() + nnoremap D :PlugDiff + nnoremap S :PlugStatus + nnoremap U :call status_update() + xnoremap U :call status_update() + nnoremap ]] :silent! call section('') + nnoremap [[ :silent! call section('b') +endfunction + +function! s:prepare(...) + if empty(s:plug_getcwd()) + throw 'Invalid current working directory. Cannot proceed.' + endif + + for evar in ['$GIT_DIR', '$GIT_WORK_TREE'] + if exists(evar) + throw evar.' detected. Cannot proceed.' + endif + endfor + + call s:job_abort() + if s:switch_in() + if b:plug_preview == 1 + pc + endif + enew + else + call s:new_window() + endif + + nnoremap q :call close_pane() + if a:0 == 0 + call s:finish_bindings() + endif + let b:plug_preview = -1 + let s:plug_tab = tabpagenr() + let s:plug_buf = winbufnr(0) + call s:assign_name() + + for k in ['', 'L', 'o', 'X', 'd', 'dd'] + execute 'silent! unmap ' k + endfor + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell + if exists('+colorcolumn') + setlocal colorcolumn= + endif + setf vim-plug + if exists('g:syntax_on') + call s:syntax() + endif +endfunction + +function! s:close_pane() + if b:plug_preview == 1 + pc + let b:plug_preview = -1 + else + bd + endif +endfunction + +function! s:assign_name() + " Assign buffer name + let prefix = '[Plugins]' + let name = prefix + let idx = 2 + while bufexists(name) + let name = printf('%s (%s)', prefix, idx) + let idx = idx + 1 + endwhile + silent! execute 'f' fnameescape(name) +endfunction + +function! s:chsh(swap) + let prev = [&shell, &shellcmdflag, &shellredir] + if !s:is_win + set shell=sh + endif + if a:swap + if s:is_powershell(&shell) + let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s' + elseif &shell =~# 'sh' || &shell =~# 'cmd\(\.exe\)\?$' + set shellredir=>%s\ 2>&1 + endif + endif + return prev +endfunction + +function! s:bang(cmd, ...) + let batchfile = '' + try + let [sh, shellcmdflag, shrd] = s:chsh(a:0) + " FIXME: Escaping is incomplete. We could use shellescape with eval, + " but it won't work on Windows. + let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd + if s:is_win + let [batchfile, cmd] = s:batchfile(cmd) + endif + let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%') + execute "normal! :execute g:_plug_bang\\" + finally + unlet g:_plug_bang + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win && filereadable(batchfile) + call delete(batchfile) + endif + endtry + return v:shell_error ? 'Exit status: ' . v:shell_error : '' +endfunction + +function! s:regress_bar() + let bar = substitute(getline(2)[1:-2], '.*\zs=', 'x', '') + call s:progress_bar(2, bar, len(bar)) +endfunction + +function! s:is_updated(dir) + return !empty(s:system_chomp(['git', 'log', '--pretty=format:%h', 'HEAD...HEAD@{1}'], a:dir)) +endfunction + +function! s:do(pull, force, todo) + for [name, spec] in items(a:todo) + if !isdirectory(spec.dir) + continue + endif + let installed = has_key(s:update.new, name) + let updated = installed ? 0 : + \ (a:pull && index(s:update.errors, name) < 0 && s:is_updated(spec.dir)) + if a:force || installed || updated + execute 'cd' s:esc(spec.dir) + call append(3, '- Post-update hook for '. name .' ... ') + let error = '' + let type = type(spec.do) + if type == s:TYPE.string + if spec.do[0] == ':' + if !get(s:loaded, name, 0) + let s:loaded[name] = 1 + call s:reorg_rtp() + endif + call s:load_plugin(spec) + try + execute spec.do[1:] + catch + let error = v:exception + endtry + if !s:plug_window_exists() + cd - + throw 'Warning: vim-plug was terminated by the post-update hook of '.name + endif + else + let error = s:bang(spec.do) + endif + elseif type == s:TYPE.funcref + try + call s:load_plugin(spec) + let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged') + call spec.do({ 'name': name, 'status': status, 'force': a:force }) + catch + let error = v:exception + endtry + else + let error = 'Invalid hook type' + endif + call s:switch_in() + call setline(4, empty(error) ? (getline(4) . 'OK') + \ : ('x' . getline(4)[1:] . error)) + if !empty(error) + call add(s:update.errors, name) + call s:regress_bar() + endif + cd - + endif + endfor +endfunction + +function! s:hash_match(a, b) + return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0 +endfunction + +function! s:checkout(spec) + let sha = a:spec.commit + let output = s:git_revision(a:spec.dir) + if !empty(output) && !s:hash_match(sha, s:lines(output)[0]) + let credential_helper = s:git_version_requirement(2) ? '-c credential.helper= ' : '' + let output = s:system( + \ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir) + endif + return output +endfunction + +function! s:finish(pull) + let new_frozen = len(filter(keys(s:update.new), 'g:plugs[v:val].frozen')) + if new_frozen + let s = new_frozen > 1 ? 's' : '' + call append(3, printf('- Installed %d frozen plugin%s', new_frozen, s)) + endif + call append(3, '- Finishing ... ') | 4 + redraw + call plug#helptags() + call plug#end() + call setline(4, getline(4) . 'Done!') + redraw + let msgs = [] + if !empty(s:update.errors) + call add(msgs, "Press 'R' to retry.") + endif + if a:pull && len(s:update.new) < len(filter(getline(5, '$'), + \ "v:val =~ '^- ' && v:val !~# 'Already up.to.date'")) + call add(msgs, "Press 'D' to see the updated changes.") + endif + echo join(msgs, ' ') + call s:finish_bindings() +endfunction + +function! s:retry() + if empty(s:update.errors) + return + endif + echo + call s:update_impl(s:update.pull, s:update.force, + \ extend(copy(s:update.errors), [s:update.threads])) +endfunction + +function! s:is_managed(name) + return has_key(g:plugs[a:name], 'uri') +endfunction + +function! s:names(...) + return sort(filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)')) +endfunction + +function! s:check_ruby() + silent! ruby require 'thread'; VIM::command("let g:plug_ruby = '#{RUBY_VERSION}'") + if !exists('g:plug_ruby') + redraw! + return s:warn('echom', 'Warning: Ruby interface is broken') + endif + let ruby_version = split(g:plug_ruby, '\.') + unlet g:plug_ruby + return s:version_requirement(ruby_version, [1, 8, 7]) +endfunction + +function! s:update_impl(pull, force, args) abort + let sync = index(a:args, '--sync') >= 0 || has('vim_starting') + let args = filter(copy(a:args), 'v:val != "--sync"') + let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ? + \ remove(args, -1) : get(g:, 'plug_threads', 16) + + let managed = filter(copy(g:plugs), 's:is_managed(v:key)') + let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') : + \ filter(managed, 'index(args, v:key) >= 0') + + if empty(todo) + return s:warn('echo', 'No plugin to '. (a:pull ? 'update' : 'install')) + endif + + if !s:is_win && s:git_version_requirement(2, 3) + let s:git_terminal_prompt = exists('$GIT_TERMINAL_PROMPT') ? $GIT_TERMINAL_PROMPT : '' + let $GIT_TERMINAL_PROMPT = 0 + for plug in values(todo) + let plug.uri = substitute(plug.uri, + \ '^https://git::@github\.com', 'https://github.com', '') + endfor + endif + + if !isdirectory(g:plug_home) + try + call mkdir(g:plug_home, 'p') + catch + return s:err(printf('Invalid plug directory: %s. '. + \ 'Try to call plug#begin with a valid directory', g:plug_home)) + endtry + endif + + if has('nvim') && !exists('*jobwait') && threads > 1 + call s:warn('echom', '[vim-plug] Update Neovim for parallel installer') + endif + + let use_job = s:nvim || s:vim8 + let python = (has('python') || has('python3')) && !use_job + let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && threads > 1 && s:check_ruby() + + let s:update = { + \ 'start': reltime(), + \ 'all': todo, + \ 'todo': copy(todo), + \ 'errors': [], + \ 'pull': a:pull, + \ 'force': a:force, + \ 'new': {}, + \ 'threads': (python || ruby || use_job) ? min([len(todo), threads]) : 1, + \ 'bar': '', + \ 'fin': 0 + \ } + + call s:prepare(1) + call append(0, ['', '']) + normal! 2G + silent! redraw + + let s:clone_opt = [] + if get(g:, 'plug_shallow', 1) + call extend(s:clone_opt, ['--depth', '1']) + if s:git_version_requirement(1, 7, 10) + call add(s:clone_opt, '--no-single-branch') + endif + endif + + if has('win32unix') || has('wsl') + call extend(s:clone_opt, ['-c', 'core.eol=lf', '-c', 'core.autocrlf=input']) + endif + + let s:submodule_opt = s:git_version_requirement(2, 8) ? ' --jobs='.threads : '' + + " Python version requirement (>= 2.7) + if python && !has('python3') && !ruby && !use_job && s:update.threads > 1 + redir => pyv + silent python import platform; print platform.python_version() + redir END + let python = s:version_requirement( + \ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6]) + endif + + if (python || ruby) && s:update.threads > 1 + try + let imd = &imd + if s:mac_gui + set noimd + endif + if ruby + call s:update_ruby() + else + call s:update_python() + endif + catch + let lines = getline(4, '$') + let printed = {} + silent! 4,$d _ + for line in lines + let name = s:extract_name(line, '.', '') + if empty(name) || !has_key(printed, name) + call append('$', line) + if !empty(name) + let printed[name] = 1 + if line[0] == 'x' && index(s:update.errors, name) < 0 + call add(s:update.errors, name) + end + endif + endif + endfor + finally + let &imd = imd + call s:update_finish() + endtry + else + call s:update_vim() + while use_job && sync + sleep 100m + if s:update.fin + break + endif + endwhile + endif +endfunction + +function! s:log4(name, msg) + call setline(4, printf('- %s (%s)', a:msg, a:name)) + redraw +endfunction + +function! s:update_finish() + if exists('s:git_terminal_prompt') + let $GIT_TERMINAL_PROMPT = s:git_terminal_prompt + endif + if s:switch_in() + call append(3, '- Updating ...') | 4 + for [name, spec] in items(filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && (s:update.force || s:update.pull || has_key(s:update.new, v:key))')) + let [pos, _] = s:logpos(name) + if !pos + continue + endif + if has_key(spec, 'commit') + call s:log4(name, 'Checking out '.spec.commit) + let out = s:checkout(spec) + elseif has_key(spec, 'tag') + let tag = spec.tag + if tag =~ '\*' + let tags = s:lines(s:system('git tag --list '.plug#shellescape(tag).' --sort -version:refname 2>&1', spec.dir)) + if !v:shell_error && !empty(tags) + let tag = tags[0] + call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag)) + call append(3, '') + endif + endif + call s:log4(name, 'Checking out '.tag) + let out = s:system('git checkout -q '.plug#shellescape(tag).' -- 2>&1', spec.dir) + else + let branch = s:git_origin_branch(spec) + call s:log4(name, 'Merging origin/'.s:esc(branch)) + let out = s:system('git checkout -q '.plug#shellescape(branch).' -- 2>&1' + \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only '.plug#shellescape('origin/'.branch).' 2>&1')), spec.dir) + endif + if !v:shell_error && filereadable(spec.dir.'/.gitmodules') && + \ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir)) + call s:log4(name, 'Updating submodules. This may take a while.') + let out .= s:bang('git submodule update --init --recursive'.s:submodule_opt.' 2>&1', spec.dir) + endif + let msg = s:format_message(v:shell_error ? 'x': '-', name, out) + if v:shell_error + call add(s:update.errors, name) + call s:regress_bar() + silent execute pos 'd _' + call append(4, msg) | 4 + elseif !empty(out) + call setline(pos, msg[0]) + endif + redraw + endfor + silent 4 d _ + try + call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")')) + catch + call s:warn('echom', v:exception) + call s:warn('echo', '') + return + endtry + call s:finish(s:update.pull) + call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.') + call s:switch_out('normal! gg') + endif +endfunction + +function! s:job_abort() + if (!s:nvim && !s:vim8) || !exists('s:jobs') + return + endif + + for [name, j] in items(s:jobs) + if s:nvim + silent! call jobstop(j.jobid) + elseif s:vim8 + silent! call job_stop(j.jobid) + endif + if j.new + call s:rm_rf(g:plugs[name].dir) + endif + endfor + let s:jobs = {} +endfunction + +function! s:last_non_empty_line(lines) + let len = len(a:lines) + for idx in range(len) + let line = a:lines[len-idx-1] + if !empty(line) + return line + endif + endfor + return '' +endfunction + +function! s:job_out_cb(self, data) abort + let self = a:self + let data = remove(self.lines, -1) . a:data + let lines = map(split(data, "\n", 1), 'split(v:val, "\r", 1)[-1]') + call extend(self.lines, lines) + " To reduce the number of buffer updates + let self.tick = get(self, 'tick', -1) + 1 + if !self.running || self.tick % len(s:jobs) == 0 + let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-') + let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines) + call s:log(bullet, self.name, result) + endif +endfunction + +function! s:job_exit_cb(self, data) abort + let a:self.running = 0 + let a:self.error = a:data != 0 + call s:reap(a:self.name) + call s:tick() +endfunction + +function! s:job_cb(fn, job, ch, data) + if !s:plug_window_exists() " plug window closed + return s:job_abort() + endif + call call(a:fn, [a:job, a:data]) +endfunction + +function! s:nvim_cb(job_id, data, event) dict abort + return (a:event == 'stdout' || a:event == 'stderr') ? + \ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) : + \ s:job_cb('s:job_exit_cb', self, 0, a:data) +endfunction + +function! s:spawn(name, cmd, opts) + let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''], + \ 'new': get(a:opts, 'new', 0) } + let s:jobs[a:name] = job + + if s:nvim + if has_key(a:opts, 'dir') + let job.cwd = a:opts.dir + endif + let argv = a:cmd + call extend(job, { + \ 'on_stdout': function('s:nvim_cb'), + \ 'on_stderr': function('s:nvim_cb'), + \ 'on_exit': function('s:nvim_cb'), + \ }) + let jid = s:plug_call('jobstart', argv, job) + if jid > 0 + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = [jid < 0 ? argv[0].' is not executable' : + \ 'Invalid arguments (or job table is full)'] + endif + elseif s:vim8 + let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"script": 0})')) + if has_key(a:opts, 'dir') + let cmd = s:with_cd(cmd, a:opts.dir, 0) + endif + let argv = s:is_win ? ['cmd', '/s', '/c', '"'.cmd.'"'] : ['sh', '-c', cmd] + let jid = job_start(s:is_win ? join(argv, ' ') : argv, { + \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'err_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]), + \ 'err_mode': 'raw', + \ 'out_mode': 'raw' + \}) + if job_status(jid) == 'run' + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = ['Failed to start job'] + endif + else + let job.lines = s:lines(call('s:system', has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd])) + let job.error = v:shell_error != 0 + let job.running = 0 + endif +endfunction + +function! s:reap(name) + let job = s:jobs[a:name] + if job.error + call add(s:update.errors, a:name) + elseif get(job, 'new', 0) + let s:update.new[a:name] = 1 + endif + let s:update.bar .= job.error ? 'x' : '=' + + let bullet = job.error ? 'x' : '-' + let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines) + call s:log(bullet, a:name, empty(result) ? 'OK' : result) + call s:bar() + + call remove(s:jobs, a:name) +endfunction + +function! s:bar() + if s:switch_in() + let total = len(s:update.all) + call setline(1, (s:update.pull ? 'Updating' : 'Installing'). + \ ' plugins ('.len(s:update.bar).'/'.total.')') + call s:progress_bar(2, s:update.bar, total) + call s:switch_out() + endif +endfunction + +function! s:logpos(name) + let max = line('$') + for i in range(4, max > 4 ? max : 4) + if getline(i) =~# '^[-+x*] '.a:name.':' + for j in range(i + 1, max > 5 ? max : 5) + if getline(j) !~ '^ ' + return [i, j - 1] + endif + endfor + return [i, i] + endif + endfor + return [0, 0] +endfunction + +function! s:log(bullet, name, lines) + if s:switch_in() + let [b, e] = s:logpos(a:name) + if b > 0 + silent execute printf('%d,%d d _', b, e) + if b > winheight('.') + let b = 4 + endif + else + let b = 4 + endif + " FIXME For some reason, nomodifiable is set after :d in vim8 + setlocal modifiable + call append(b - 1, s:format_message(a:bullet, a:name, a:lines)) + call s:switch_out() + endif +endfunction + +function! s:update_vim() + let s:jobs = {} + + call s:bar() + call s:tick() +endfunction + +function! s:tick() + let pull = s:update.pull + let prog = s:progress_opt(s:nvim || s:vim8) +while 1 " Without TCO, Vim stack is bound to explode + if empty(s:update.todo) + if empty(s:jobs) && !s:update.fin + call s:update_finish() + let s:update.fin = 1 + endif + return + endif + + let name = keys(s:update.todo)[0] + let spec = remove(s:update.todo, name) + let new = empty(globpath(spec.dir, '.git', 1)) + + call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...') + redraw + + let has_tag = has_key(spec, 'tag') + if !new + let [error, _] = s:git_validate(spec, 0) + if empty(error) + if pull + let cmd = s:git_version_requirement(2) ? ['git', '-c', 'credential.helper=', 'fetch'] : ['git', 'fetch'] + if has_tag && !empty(globpath(spec.dir, '.git/shallow')) + call extend(cmd, ['--depth', '99999999']) + endif + if !empty(prog) + call add(cmd, prog) + endif + call s:spawn(name, cmd, { 'dir': spec.dir }) + else + let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 } + endif + else + let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 } + endif + else + let cmd = ['git', 'clone'] + if !has_tag + call extend(cmd, s:clone_opt) + endif + if !empty(prog) + call add(cmd, prog) + endif + call s:spawn(name, extend(cmd, [spec.uri, s:trim(spec.dir)]), { 'new': 1 }) + endif + + if !s:jobs[name].running + call s:reap(name) + endif + if len(s:jobs) >= s:update.threads + break + endif +endwhile +endfunction + +function! s:update_python() +let py_exe = has('python') ? 'python' : 'python3' +execute py_exe "<< EOF" +import datetime +import functools +import os +try: + import queue +except ImportError: + import Queue as queue +import random +import re +import shutil +import signal +import subprocess +import tempfile +import threading as thr +import time +import traceback +import vim + +G_NVIM = vim.eval("has('nvim')") == '1' +G_PULL = vim.eval('s:update.pull') == '1' +G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1 +G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)')) +G_CLONE_OPT = ' '.join(vim.eval('s:clone_opt')) +G_PROGRESS = vim.eval('s:progress_opt(1)') +G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads')) +G_STOP = thr.Event() +G_IS_WIN = vim.eval('s:is_win') == '1' + +class PlugError(Exception): + def __init__(self, msg): + self.msg = msg +class CmdTimedOut(PlugError): + pass +class CmdFailed(PlugError): + pass +class InvalidURI(PlugError): + pass +class Action(object): + INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-'] + +class Buffer(object): + def __init__(self, lock, num_plugs, is_pull): + self.bar = '' + self.event = 'Updating' if is_pull else 'Installing' + self.lock = lock + self.maxy = int(vim.eval('winheight(".")')) + self.num_plugs = num_plugs + + def __where(self, name): + """ Find first line with name in current buffer. Return line num. """ + found, lnum = False, 0 + matcher = re.compile('^[-+x*] {0}:'.format(name)) + for line in vim.current.buffer: + if matcher.search(line) is not None: + found = True + break + lnum += 1 + + if not found: + lnum = -1 + return lnum + + def header(self): + curbuf = vim.current.buffer + curbuf[0] = self.event + ' plugins ({0}/{1})'.format(len(self.bar), self.num_plugs) + + num_spaces = self.num_plugs - len(self.bar) + curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ') + + with self.lock: + vim.command('normal! 2G') + vim.command('redraw') + + def write(self, action, name, lines): + first, rest = lines[0], lines[1:] + msg = ['{0} {1}{2}{3}'.format(action, name, ': ' if first else '', first)] + msg.extend([' ' + line for line in rest]) + + try: + if action == Action.ERROR: + self.bar += 'x' + vim.command("call add(s:update.errors, '{0}')".format(name)) + elif action == Action.DONE: + self.bar += '=' + + curbuf = vim.current.buffer + lnum = self.__where(name) + if lnum != -1: # Found matching line num + del curbuf[lnum] + if lnum > self.maxy and action in set([Action.INSTALL, Action.UPDATE]): + lnum = 3 + else: + lnum = 3 + curbuf.append(msg, lnum) + + self.header() + except vim.error: + pass + +class Command(object): + CD = 'cd /d' if G_IS_WIN else 'cd' + + def __init__(self, cmd, cmd_dir=None, timeout=60, cb=None, clean=None): + self.cmd = cmd + if cmd_dir: + self.cmd = '{0} {1} && {2}'.format(Command.CD, cmd_dir, self.cmd) + self.timeout = timeout + self.callback = cb if cb else (lambda msg: None) + self.clean = clean if clean else (lambda: None) + self.proc = None + + @property + def alive(self): + """ Returns true only if command still running. """ + return self.proc and self.proc.poll() is None + + def execute(self, ntries=3): + """ Execute the command with ntries if CmdTimedOut. + Returns the output of the command if no Exception. + """ + attempt, finished, limit = 0, False, self.timeout + + while not finished: + try: + attempt += 1 + result = self.try_command() + finished = True + return result + except CmdTimedOut: + if attempt != ntries: + self.notify_retry() + self.timeout += limit + else: + raise + + def notify_retry(self): + """ Retry required for command, notify user. """ + for count in range(3, 0, -1): + if G_STOP.is_set(): + raise KeyboardInterrupt + msg = 'Timeout. Will retry in {0} second{1} ...'.format( + count, 's' if count != 1 else '') + self.callback([msg]) + time.sleep(1) + self.callback(['Retrying ...']) + + def try_command(self): + """ Execute a cmd & poll for callback. Returns list of output. + Raises CmdFailed -> return code for Popen isn't 0 + Raises CmdTimedOut -> command exceeded timeout without new output + """ + first_line = True + + try: + tfile = tempfile.NamedTemporaryFile(mode='w+b') + preexec_fn = not G_IS_WIN and os.setsid or None + self.proc = subprocess.Popen(self.cmd, stdout=tfile, + stderr=subprocess.STDOUT, + stdin=subprocess.PIPE, shell=True, + preexec_fn=preexec_fn) + thrd = thr.Thread(target=(lambda proc: proc.wait()), args=(self.proc,)) + thrd.start() + + thread_not_started = True + while thread_not_started: + try: + thrd.join(0.1) + thread_not_started = False + except RuntimeError: + pass + + while self.alive: + if G_STOP.is_set(): + raise KeyboardInterrupt + + if first_line or random.random() < G_LOG_PROB: + first_line = False + line = '' if G_IS_WIN else nonblock_read(tfile.name) + if line: + self.callback([line]) + + time_diff = time.time() - os.path.getmtime(tfile.name) + if time_diff > self.timeout: + raise CmdTimedOut(['Timeout!']) + + thrd.join(0.5) + + tfile.seek(0) + result = [line.decode('utf-8', 'replace').rstrip() for line in tfile] + + if self.proc.returncode != 0: + raise CmdFailed([''] + result) + + return result + except: + self.terminate() + raise + + def terminate(self): + """ Terminate process and cleanup. """ + if self.alive: + if G_IS_WIN: + os.kill(self.proc.pid, signal.SIGINT) + else: + os.killpg(self.proc.pid, signal.SIGTERM) + self.clean() + +class Plugin(object): + def __init__(self, name, args, buf_q, lock): + self.name = name + self.args = args + self.buf_q = buf_q + self.lock = lock + self.tag = args.get('tag', 0) + + def manage(self): + try: + if os.path.exists(self.args['dir']): + self.update() + else: + self.install() + with self.lock: + thread_vim_command("let s:update.new['{0}'] = 1".format(self.name)) + except PlugError as exc: + self.write(Action.ERROR, self.name, exc.msg) + except KeyboardInterrupt: + G_STOP.set() + self.write(Action.ERROR, self.name, ['Interrupted!']) + except: + # Any exception except those above print stack trace + msg = 'Trace:\n{0}'.format(traceback.format_exc().rstrip()) + self.write(Action.ERROR, self.name, msg.split('\n')) + raise + + def install(self): + target = self.args['dir'] + if target[-1] == '\\': + target = target[0:-1] + + def clean(target): + def _clean(): + try: + shutil.rmtree(target) + except OSError: + pass + return _clean + + self.write(Action.INSTALL, self.name, ['Installing ...']) + callback = functools.partial(self.write, Action.INSTALL, self.name) + cmd = 'git clone {0} {1} {2} {3} 2>&1'.format( + '' if self.tag else G_CLONE_OPT, G_PROGRESS, self.args['uri'], + esc(target)) + com = Command(cmd, None, G_TIMEOUT, callback, clean(target)) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + + def repo_uri(self): + cmd = 'git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url' + command = Command(cmd, self.args['dir'], G_TIMEOUT,) + result = command.execute(G_RETRIES) + return result[-1] + + def update(self): + actual_uri = self.repo_uri() + expect_uri = self.args['uri'] + regex = re.compile(r'^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$') + ma = regex.match(actual_uri) + mb = regex.match(expect_uri) + if ma is None or mb is None or ma.groups() != mb.groups(): + msg = ['', + 'Invalid URI: {0}'.format(actual_uri), + 'Expected {0}'.format(expect_uri), + 'PlugClean required.'] + raise InvalidURI(msg) + + if G_PULL: + self.write(Action.UPDATE, self.name, ['Updating ...']) + callback = functools.partial(self.write, Action.UPDATE, self.name) + fetch_opt = '--depth 99999999' if self.tag and os.path.isfile(os.path.join(self.args['dir'], '.git/shallow')) else '' + cmd = 'git fetch {0} {1} 2>&1'.format(fetch_opt, G_PROGRESS) + com = Command(cmd, self.args['dir'], G_TIMEOUT, callback) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + else: + self.write(Action.DONE, self.name, ['Already installed']) + + def write(self, action, name, msg): + self.buf_q.put((action, name, msg)) + +class PlugThread(thr.Thread): + def __init__(self, tname, args): + super(PlugThread, self).__init__() + self.tname = tname + self.args = args + + def run(self): + thr.current_thread().name = self.tname + buf_q, work_q, lock = self.args + + try: + while not G_STOP.is_set(): + name, args = work_q.get_nowait() + plug = Plugin(name, args, buf_q, lock) + plug.manage() + work_q.task_done() + except queue.Empty: + pass + +class RefreshThread(thr.Thread): + def __init__(self, lock): + super(RefreshThread, self).__init__() + self.lock = lock + self.running = True + + def run(self): + while self.running: + with self.lock: + thread_vim_command('noautocmd normal! a') + time.sleep(0.33) + + def stop(self): + self.running = False + +if G_NVIM: + def thread_vim_command(cmd): + vim.session.threadsafe_call(lambda: vim.command(cmd)) +else: + def thread_vim_command(cmd): + vim.command(cmd) + +def esc(name): + return '"' + name.replace('"', '\"') + '"' + +def nonblock_read(fname): + """ Read a file with nonblock flag. Return the last line. """ + fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK) + buf = os.read(fread, 100000).decode('utf-8', 'replace') + os.close(fread) + + line = buf.rstrip('\r\n') + left = max(line.rfind('\r'), line.rfind('\n')) + if left != -1: + left += 1 + line = line[left:] + + return line + +def main(): + thr.current_thread().name = 'main' + nthreads = int(vim.eval('s:update.threads')) + plugs = vim.eval('s:update.todo') + mac_gui = vim.eval('s:mac_gui') == '1' + + lock = thr.Lock() + buf = Buffer(lock, len(plugs), G_PULL) + buf_q, work_q = queue.Queue(), queue.Queue() + for work in plugs.items(): + work_q.put(work) + + start_cnt = thr.active_count() + for num in range(nthreads): + tname = 'PlugT-{0:02}'.format(num) + thread = PlugThread(tname, (buf_q, work_q, lock)) + thread.start() + if mac_gui: + rthread = RefreshThread(lock) + rthread.start() + + while not buf_q.empty() or thr.active_count() != start_cnt: + try: + action, name, msg = buf_q.get(True, 0.25) + buf.write(action, name, ['OK'] if not msg else msg) + buf_q.task_done() + except queue.Empty: + pass + except KeyboardInterrupt: + G_STOP.set() + + if mac_gui: + rthread.stop() + rthread.join() + +main() +EOF +endfunction + +function! s:update_ruby() + ruby << EOF + module PlugStream + SEP = ["\r", "\n", nil] + def get_line + buffer = '' + loop do + char = readchar rescue return + if SEP.include? char.chr + buffer << $/ + break + else + buffer << char + end + end + buffer + end + end unless defined?(PlugStream) + + def esc arg + %["#{arg.gsub('"', '\"')}"] + end + + def killall pid + pids = [pid] + if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM + pids.each { |pid| Process.kill 'INT', pid.to_i rescue nil } + else + unless `which pgrep 2> /dev/null`.empty? + children = pids + until children.empty? + children = children.map { |pid| + `pgrep -P #{pid}`.lines.map { |l| l.chomp } + }.flatten + pids += children + end + end + pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil } + end + end + + def compare_git_uri a, b + regex = %r{^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$} + regex.match(a).to_a.drop(1) == regex.match(b).to_a.drop(1) + end + + require 'thread' + require 'fileutils' + require 'timeout' + running = true + iswin = VIM::evaluate('s:is_win').to_i == 1 + pull = VIM::evaluate('s:update.pull').to_i == 1 + base = VIM::evaluate('g:plug_home') + all = VIM::evaluate('s:update.todo') + limit = VIM::evaluate('get(g:, "plug_timeout", 60)') + tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1 + nthr = VIM::evaluate('s:update.threads').to_i + maxy = VIM::evaluate('winheight(".")').to_i + vim7 = VIM::evaluate('v:version').to_i <= 703 && RUBY_PLATFORM =~ /darwin/ + cd = iswin ? 'cd /d' : 'cd' + tot = VIM::evaluate('len(s:update.todo)') || 0 + bar = '' + skip = 'Already installed' + mtx = Mutex.new + take1 = proc { mtx.synchronize { running && all.shift } } + logh = proc { + cnt = bar.length + $curbuf[1] = "#{pull ? 'Updating' : 'Installing'} plugins (#{cnt}/#{tot})" + $curbuf[2] = '[' + bar.ljust(tot) + ']' + VIM::command('normal! 2G') + VIM::command('redraw') + } + where = proc { |name| (1..($curbuf.length)).find { |l| $curbuf[l] =~ /^[-+x*] #{name}:/ } } + log = proc { |name, result, type| + mtx.synchronize do + ing = ![true, false].include?(type) + bar += type ? '=' : 'x' unless ing + b = case type + when :install then '+' when :update then '*' + when true, nil then '-' else + VIM::command("call add(s:update.errors, '#{name}')") + 'x' + end + result = + if type || type.nil? + ["#{b} #{name}: #{result.lines.to_a.last || 'OK'}"] + elsif result =~ /^Interrupted|^Timeout/ + ["#{b} #{name}: #{result}"] + else + ["#{b} #{name}"] + result.lines.map { |l| " " << l } + end + if lnum = where.call(name) + $curbuf.delete lnum + lnum = 4 if ing && lnum > maxy + end + result.each_with_index do |line, offset| + $curbuf.append((lnum || 4) - 1 + offset, line.gsub(/\e\[./, '').chomp) + end + logh.call + end + } + bt = proc { |cmd, name, type, cleanup| + tried = timeout = 0 + begin + tried += 1 + timeout += limit + fd = nil + data = '' + if iswin + Timeout::timeout(timeout) do + tmp = VIM::evaluate('tempname()') + system("(#{cmd}) > #{tmp}") + data = File.read(tmp).chomp + File.unlink tmp rescue nil + end + else + fd = IO.popen(cmd).extend(PlugStream) + first_line = true + log_prob = 1.0 / nthr + while line = Timeout::timeout(timeout) { fd.get_line } + data << line + log.call name, line.chomp, type if name && (first_line || rand < log_prob) + first_line = false + end + fd.close + end + [$? == 0, data.chomp] + rescue Timeout::Error, Interrupt => e + if fd && !fd.closed? + killall fd.pid + fd.close + end + cleanup.call if cleanup + if e.is_a?(Timeout::Error) && tried < tries + 3.downto(1) do |countdown| + s = countdown > 1 ? 's' : '' + log.call name, "Timeout. Will retry in #{countdown} second#{s} ...", type + sleep 1 + end + log.call name, 'Retrying ...', type + retry + end + [false, e.is_a?(Interrupt) ? "Interrupted!" : "Timeout!"] + end + } + main = Thread.current + threads = [] + watcher = Thread.new { + if vim7 + while VIM::evaluate('getchar(1)') + sleep 0.1 + end + else + require 'io/console' # >= Ruby 1.9 + nil until IO.console.getch == 3.chr + end + mtx.synchronize do + running = false + threads.each { |t| t.raise Interrupt } unless vim7 + end + threads.each { |t| t.join rescue nil } + main.kill + } + refresh = Thread.new { + while true + mtx.synchronize do + break unless running + VIM::command('noautocmd normal! a') + end + sleep 0.2 + end + } if VIM::evaluate('s:mac_gui') == 1 + + clone_opt = VIM::evaluate('s:clone_opt').join(' ') + progress = VIM::evaluate('s:progress_opt(1)') + nthr.times do + mtx.synchronize do + threads << Thread.new { + while pair = take1.call + name = pair.first + dir, uri, tag = pair.last.values_at *%w[dir uri tag] + exists = File.directory? dir + ok, result = + if exists + chdir = "#{cd} #{iswin ? dir : esc(dir)}" + ret, data = bt.call "#{chdir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url", nil, nil, nil + current_uri = data.lines.to_a.last + if !ret + if data =~ /^Interrupted|^Timeout/ + [false, data] + else + [false, [data.chomp, "PlugClean required."].join($/)] + end + elsif !compare_git_uri(current_uri, uri) + [false, ["Invalid URI: #{current_uri}", + "Expected: #{uri}", + "PlugClean required."].join($/)] + else + if pull + log.call name, 'Updating ...', :update + fetch_opt = (tag && File.exist?(File.join(dir, '.git/shallow'))) ? '--depth 99999999' : '' + bt.call "#{chdir} && git fetch #{fetch_opt} #{progress} 2>&1", name, :update, nil + else + [true, skip] + end + end + else + d = esc dir.sub(%r{[\\/]+$}, '') + log.call name, 'Installing ...', :install + bt.call "git clone #{clone_opt unless tag} #{progress} #{uri} #{d} 2>&1", name, :install, proc { + FileUtils.rm_rf dir + } + end + mtx.synchronize { VIM::command("let s:update.new['#{name}'] = 1") } if !exists && ok + log.call name, result, ok + end + } if running + end + end + threads.each { |t| t.join rescue nil } + logh.call + refresh.kill if refresh + watcher.kill +EOF +endfunction + +function! s:shellesc_cmd(arg, script) + let escaped = substitute('"'.a:arg.'"', '[&|<>()@^!"]', '^&', 'g') + return substitute(escaped, '%', (a:script ? '%' : '^') . '&', 'g') +endfunction + +function! s:shellesc_ps1(arg) + return "'".substitute(escape(a:arg, '\"'), "'", "''", 'g')."'" +endfunction + +function! s:shellesc_sh(arg) + return "'".substitute(a:arg, "'", "'\\\\''", 'g')."'" +endfunction + +" Escape the shell argument based on the shell. +" Vim and Neovim's shellescape() are insufficient. +" 1. shellslash determines whether to use single/double quotes. +" Double-quote escaping is fragile for cmd.exe. +" 2. It does not work for powershell. +" 3. It does not work for *sh shells if the command is executed +" via cmd.exe (ie. cmd.exe /c sh -c command command_args) +" 4. It does not support batchfile syntax. +" +" Accepts an optional dictionary with the following keys: +" - shell: same as Vim/Neovim 'shell' option. +" If unset, fallback to 'cmd.exe' on Windows or 'sh'. +" - script: If truthy and shell is cmd.exe, escape for batchfile syntax. +function! plug#shellescape(arg, ...) + if a:arg =~# '^[A-Za-z0-9_/:.-]\+$' + return a:arg + endif + let opts = a:0 > 0 && type(a:1) == s:TYPE.dict ? a:1 : {} + let shell = get(opts, 'shell', s:is_win ? 'cmd.exe' : 'sh') + let script = get(opts, 'script', 1) + if shell =~# 'cmd\(\.exe\)\?$' + return s:shellesc_cmd(a:arg, script) + elseif s:is_powershell(shell) + return s:shellesc_ps1(a:arg) + endif + return s:shellesc_sh(a:arg) +endfunction + +function! s:glob_dir(path) + return map(filter(s:glob(a:path, '**'), 'isdirectory(v:val)'), 's:dirpath(v:val)') +endfunction + +function! s:progress_bar(line, bar, total) + call setline(a:line, '[' . s:lpad(a:bar, a:total) . ']') +endfunction + +function! s:compare_git_uri(a, b) + " See `git help clone' + " https:// [user@] github.com[:port] / junegunn/vim-plug [.git] + " [git@] github.com[:port] : junegunn/vim-plug [.git] + " file:// / junegunn/vim-plug [/] + " / junegunn/vim-plug [/] + let pat = '^\%(\w\+://\)\='.'\%([^@/]*@\)\='.'\([^:/]*\%(:[0-9]*\)\=\)'.'[:/]'.'\(.\{-}\)'.'\%(\.git\)\=/\?$' + let ma = matchlist(a:a, pat) + let mb = matchlist(a:b, pat) + return ma[1:2] ==# mb[1:2] +endfunction + +function! s:format_message(bullet, name, message) + if a:bullet != 'x' + return [printf('%s %s: %s', a:bullet, a:name, s:lastline(a:message))] + else + let lines = map(s:lines(a:message), '" ".v:val') + return extend([printf('x %s:', a:name)], lines) + endif +endfunction + +function! s:with_cd(cmd, dir, ...) + let script = a:0 > 0 ? a:1 : 1 + return printf('cd%s %s && %s', s:is_win ? ' /d' : '', plug#shellescape(a:dir, {'script': script}), a:cmd) +endfunction + +function! s:system(cmd, ...) + let batchfile = '' + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + if type(a:cmd) == s:TYPE.list + " Neovim's system() supports list argument to bypass the shell + " but it cannot set the working directory for the command. + " Assume that the command does not rely on the shell. + if has('nvim') && a:0 == 0 + return system(a:cmd) + endif + let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"shell": &shell, "script": 0})')) + if s:is_powershell(&shell) + let cmd = '& ' . cmd + endif + else + let cmd = a:cmd + endif + if a:0 > 0 + let cmd = s:with_cd(cmd, a:1, type(a:cmd) != s:TYPE.list) + endif + if s:is_win && type(a:cmd) != s:TYPE.list + let [batchfile, cmd] = s:batchfile(cmd) + endif + return system(cmd) + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win && filereadable(batchfile) + call delete(batchfile) + endif + endtry +endfunction + +function! s:system_chomp(...) + let ret = call('s:system', a:000) + return v:shell_error ? '' : substitute(ret, '\n$', '', '') +endfunction + +function! s:git_validate(spec, check_branch) + let err = '' + if isdirectory(a:spec.dir) + let result = [s:git_local_branch(a:spec.dir), s:git_origin_url(a:spec.dir)] + let remote = result[-1] + if empty(remote) + let err = join([remote, 'PlugClean required.'], "\n") + elseif !s:compare_git_uri(remote, a:spec.uri) + let err = join(['Invalid URI: '.remote, + \ 'Expected: '.a:spec.uri, + \ 'PlugClean required.'], "\n") + elseif a:check_branch && has_key(a:spec, 'commit') + let sha = s:git_revision(a:spec.dir) + if empty(sha) + let err = join(add(result, 'PlugClean required.'), "\n") + elseif !s:hash_match(sha, a:spec.commit) + let err = join([printf('Invalid HEAD (expected: %s, actual: %s)', + \ a:spec.commit[:6], sha[:6]), + \ 'PlugUpdate required.'], "\n") + endif + elseif a:check_branch + let current_branch = result[0] + " Check tag + let origin_branch = s:git_origin_branch(a:spec) + if has_key(a:spec, 'tag') + let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir) + if a:spec.tag !=# tag && a:spec.tag !~ '\*' + let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.', + \ (empty(tag) ? 'N/A' : tag), a:spec.tag) + endif + " Check branch + elseif origin_branch !=# current_branch + let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.', + \ current_branch, origin_branch) + endif + if empty(err) + let [ahead, behind] = split(s:lastline(s:system([ + \ 'git', 'rev-list', '--count', '--left-right', + \ printf('HEAD...origin/%s', origin_branch) + \ ], a:spec.dir)), '\t') + if !v:shell_error && ahead + if behind + " Only mention PlugClean if diverged, otherwise it's likely to be + " pushable (and probably not that messed up). + let err = printf( + \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n" + \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', origin_branch, ahead, behind) + else + let err = printf("Ahead of origin/%s by %d commit(s).\n" + \ .'Cannot update until local changes are pushed.', + \ origin_branch, ahead) + endif + endif + endif + endif + else + let err = 'Not found' + endif + return [err, err =~# 'PlugClean'] +endfunction + +function! s:rm_rf(dir) + if isdirectory(a:dir) + return s:system(s:is_win + \ ? 'rmdir /S /Q '.plug#shellescape(a:dir) + \ : ['rm', '-rf', a:dir]) + endif +endfunction + +function! s:clean(force) + call s:prepare() + call append(0, 'Searching for invalid plugins in '.g:plug_home) + call append(1, '') + + " List of valid directories + let dirs = [] + let errs = {} + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + if !s:is_managed(name) + call add(dirs, spec.dir) + else + let [err, clean] = s:git_validate(spec, 1) + if clean + let errs[spec.dir] = s:lines(err)[0] + else + call add(dirs, spec.dir) + endif + endif + let cnt += 1 + call s:progress_bar(2, repeat('=', cnt), total) + normal! 2G + redraw + endfor + + let allowed = {} + for dir in dirs + let allowed[s:dirpath(s:plug_fnamemodify(dir, ':h:h'))] = 1 + let allowed[dir] = 1 + for child in s:glob_dir(dir) + let allowed[child] = 1 + endfor + endfor + + let todo = [] + let found = sort(s:glob_dir(g:plug_home)) + while !empty(found) + let f = remove(found, 0) + if !has_key(allowed, f) && isdirectory(f) + call add(todo, f) + call append(line('$'), '- ' . f) + if has_key(errs, f) + call append(line('$'), ' ' . errs[f]) + endif + let found = filter(found, 'stridx(v:val, f) != 0') + end + endwhile + + 4 + redraw + if empty(todo) + call append(line('$'), 'Already clean.') + else + let s:clean_count = 0 + call append(3, ['Directories to delete:', '']) + redraw! + if a:force || s:ask_no_interrupt('Delete all directories?') + call s:delete([6, line('$')], 1) + else + call setline(4, 'Cancelled.') + nnoremap d :set opfunc=delete_opg@ + nmap dd d_ + xnoremap d :call delete_op(visualmode(), 1) + echo 'Delete the lines (d{motion}) to delete the corresponding directories' + endif + endif + 4 + setlocal nomodifiable +endfunction + +function! s:delete_op(type, ...) + call s:delete(a:0 ? [line("'<"), line("'>")] : [line("'["), line("']")], 0) +endfunction + +function! s:delete(range, force) + let [l1, l2] = a:range + let force = a:force + let err_count = 0 + while l1 <= l2 + let line = getline(l1) + if line =~ '^- ' && isdirectory(line[2:]) + execute l1 + redraw! + let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1) + let force = force || answer > 1 + if answer + let err = s:rm_rf(line[2:]) + setlocal modifiable + if empty(err) + call setline(l1, '~'.line[1:]) + let s:clean_count += 1 + else + delete _ + call append(l1 - 1, s:format_message('x', line[1:], err)) + let l2 += len(s:lines(err)) + let err_count += 1 + endif + let msg = printf('Removed %d directories.', s:clean_count) + if err_count > 0 + let msg .= printf(' Failed to remove %d directories.', err_count) + endif + call setline(4, msg) + setlocal nomodifiable + endif + endif + let l1 += 1 + endwhile +endfunction + +function! s:upgrade() + echo 'Downloading the latest version of vim-plug' + redraw + let tmp = s:plug_tempname() + let new = tmp . '/plug.vim' + + try + let out = s:system(['git', 'clone', '--depth', '1', s:plug_src, tmp]) + if v:shell_error + return s:err('Error upgrading vim-plug: '. out) + endif + + if readfile(s:me) ==# readfile(new) + echo 'vim-plug is already up-to-date' + return 0 + else + call rename(s:me, s:me . '.old') + call rename(new, s:me) + unlet g:loaded_plug + echo 'vim-plug has been upgraded' + return 1 + endif + finally + silent! call s:rm_rf(tmp) + endtry +endfunction + +function! s:upgrade_specs() + for spec in values(g:plugs) + let spec.frozen = get(spec, 'frozen', 0) + endfor +endfunction + +function! s:status() + call s:prepare() + call append(0, 'Checking plugins') + call append(1, '') + + let ecnt = 0 + let unloaded = 0 + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + let is_dir = isdirectory(spec.dir) + if has_key(spec, 'uri') + if is_dir + let [err, _] = s:git_validate(spec, 1) + let [valid, msg] = [empty(err), empty(err) ? 'OK' : err] + else + let [valid, msg] = [0, 'Not found. Try PlugInstall.'] + endif + else + if is_dir + let [valid, msg] = [1, 'OK'] + else + let [valid, msg] = [0, 'Not found.'] + endif + endif + let cnt += 1 + let ecnt += !valid + " `s:loaded` entry can be missing if PlugUpgraded + if is_dir && get(s:loaded, name, -1) == 0 + let unloaded = 1 + let msg .= ' (not loaded)' + endif + call s:progress_bar(2, repeat('=', cnt), total) + call append(3, s:format_message(valid ? '-' : 'x', name, msg)) + normal! 2G + redraw + endfor + call setline(1, 'Finished. '.ecnt.' error(s).') + normal! gg + setlocal nomodifiable + if unloaded + echo "Press 'L' on each line to load plugin, or 'U' to update" + nnoremap L :call status_load(line('.')) + xnoremap L :call status_load(line('.')) + end +endfunction + +function! s:extract_name(str, prefix, suffix) + return matchstr(a:str, '^'.a:prefix.' \zs[^:]\+\ze:.*'.a:suffix.'$') +endfunction + +function! s:status_load(lnum) + let line = getline(a:lnum) + let name = s:extract_name(line, '-', '(not loaded)') + if !empty(name) + call plug#load(name) + setlocal modifiable + call setline(a:lnum, substitute(line, ' (not loaded)$', '', '')) + setlocal nomodifiable + endif +endfunction + +function! s:status_update() range + let lines = getline(a:firstline, a:lastline) + let names = filter(map(lines, 's:extract_name(v:val, "[x-]", "")'), '!empty(v:val)') + if !empty(names) + echo + execute 'PlugUpdate' join(names) + endif +endfunction + +function! s:is_preview_window_open() + silent! wincmd P + if &previewwindow + wincmd p + return 1 + endif +endfunction + +function! s:find_name(lnum) + for lnum in reverse(range(1, a:lnum)) + let line = getline(lnum) + if empty(line) + return '' + endif + let name = s:extract_name(line, '-', '') + if !empty(name) + return name + endif + endfor + return '' +endfunction + +function! s:preview_commit() + if b:plug_preview < 0 + let b:plug_preview = !s:is_preview_window_open() + endif + + let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}') + if empty(sha) + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir) + return + endif + + if exists('g:plug_pwindow') && !s:is_preview_window_open() + execute g:plug_pwindow + execute 'e' sha + else + execute 'pedit' sha + wincmd P + endif + setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable + let batchfile = '' + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha + if s:is_win + let [batchfile, cmd] = s:batchfile(cmd) + endif + execute 'silent %!' cmd + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win && filereadable(batchfile) + call delete(batchfile) + endif + endtry + setlocal nomodifiable + nnoremap q :q + wincmd p +endfunction + +function! s:section(flags) + call search('\(^[x-] \)\@<=[^:]\+:', a:flags) +endfunction + +function! s:format_git_log(line) + let indent = ' ' + let tokens = split(a:line, nr2char(1)) + if len(tokens) != 5 + return indent.substitute(a:line, '\s*$', '', '') + endif + let [graph, sha, refs, subject, date] = tokens + let tag = matchstr(refs, 'tag: [^,)]\+') + let tag = empty(tag) ? ' ' : ' ('.tag.') ' + return printf('%s%s%s%s%s (%s)', indent, graph, sha, tag, subject, date) +endfunction + +function! s:append_ul(lnum, text) + call append(a:lnum, ['', a:text, repeat('-', len(a:text))]) +endfunction + +function! s:diff() + call s:prepare() + call append(0, ['Collecting changes ...', '']) + let cnts = [0, 0] + let bar = '' + let total = filter(copy(g:plugs), 's:is_managed(v:key) && isdirectory(v:val.dir)') + call s:progress_bar(2, bar, len(total)) + for origin in [1, 0] + let plugs = reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))')))) + if empty(plugs) + continue + endif + call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:') + for [k, v] in plugs + let branch = s:git_origin_branch(v) + if len(branch) + let range = origin ? '..origin/'.branch : 'HEAD@{1}..' + let cmd = ['git', 'log', '--graph', '--color=never'] + if s:git_version_requirement(2, 10, 0) + call add(cmd, '--no-show-signature') + endif + call extend(cmd, ['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range]) + if has_key(v, 'rtp') + call extend(cmd, ['--', v.rtp]) + endif + let diff = s:system_chomp(cmd, v.dir) + if !empty(diff) + let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : '' + call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)'))) + let cnts[origin] += 1 + endif + endif + let bar .= '=' + call s:progress_bar(2, bar, len(total)) + normal! 2G + redraw + endfor + if !cnts[origin] + call append(5, ['', 'N/A']) + endif + endfor + call setline(1, printf('%d plugin(s) updated.', cnts[0]) + \ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : '')) + + if cnts[0] || cnts[1] + nnoremap (plug-preview) :silent! call preview_commit() + if empty(maparg("\", 'n')) + nmap (plug-preview) + endif + if empty(maparg('o', 'n')) + nmap o (plug-preview) + endif + endif + if cnts[0] + nnoremap X :call revert() + echo "Press 'X' on each block to revert the update" + endif + normal! gg + setlocal nomodifiable +endfunction + +function! s:revert() + if search('^Pending updates', 'bnW') + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || + \ input(printf('Revert the update of %s? (y/N) ', name)) !~? '^y' + return + endif + + call s:system('git reset --hard HEAD@{1} && git checkout '.plug#shellescape(g:plugs[name].branch).' --', g:plugs[name].dir) + setlocal modifiable + normal! "_dap + setlocal nomodifiable + echo 'Reverted' +endfunction + +function! s:snapshot(force, ...) abort + call s:prepare() + setf vim + call append(0, ['" Generated by vim-plug', + \ '" '.strftime("%c"), + \ '" :source this file in vim to restore the snapshot', + \ '" or execute: vim -S snapshot.vim', + \ '', '', 'PlugUpdate!']) + 1 + let anchor = line('$') - 3 + let names = sort(keys(filter(copy(g:plugs), + \'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)'))) + for name in reverse(names) + let sha = s:git_revision(g:plugs[name].dir) + if !empty(sha) + call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha)) + redraw + endif + endfor + + if a:0 > 0 + let fn = s:plug_expand(a:1) + if filereadable(fn) && !(a:force || s:ask(a:1.' already exists. Overwrite?')) + return + endif + call writefile(getline(1, '$'), fn) + echo 'Saved as '.a:1 + silent execute 'e' s:esc(fn) + setf vim + endif +endfunction + +function! s:split_rtp() + return split(&rtp, '\\\@`-mappings | +"| `for` | On-demand loading: File types | +"| `frozen` | Do not update unless explicitly specified | +" +" More information: https://github.com/junegunn/vim-plug +" +" +" Copyright (c) 2017 Junegunn Choi +" +" MIT License +" +" Permission is hereby granted, free of charge, to any person obtaining +" a copy of this software and associated documentation files (the +" "Software"), to deal in the Software without restriction, including +" without limitation the rights to use, copy, modify, merge, publish, +" distribute, sublicense, and/or sell copies of the Software, and to +" permit persons to whom the Software is furnished to do so, subject to +" the following conditions: +" +" The above copyright notice and this permission notice shall be +" included in all copies or substantial portions of the Software. +" +" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +" NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +" LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +if exists('g:loaded_plug') + finish +endif +let g:loaded_plug = 1 + +let s:cpo_save = &cpo +set cpo&vim + +let s:plug_src = 'https://github.com/junegunn/vim-plug.git' +let s:plug_tab = get(s:, 'plug_tab', -1) +let s:plug_buf = get(s:, 'plug_buf', -1) +let s:mac_gui = has('gui_macvim') && has('gui_running') +let s:is_win = has('win32') +let s:nvim = has('nvim-0.2') || (has('nvim') && exists('*jobwait') && !s:is_win) +let s:vim8 = has('patch-8.0.0039') && exists('*job_start') +if s:is_win && &shellslash + set noshellslash + let s:me = resolve(expand(':p')) + set shellslash +else + let s:me = resolve(expand(':p')) +endif +let s:base_spec = { 'branch': '', 'frozen': 0 } +let s:TYPE = { +\ 'string': type(''), +\ 'list': type([]), +\ 'dict': type({}), +\ 'funcref': type(function('call')) +\ } +let s:loaded = get(s:, 'loaded', {}) +let s:triggers = get(s:, 'triggers', {}) + +function! s:isabsolute(dir) abort + return a:dir =~# '^/' || (has('win32') && a:dir =~? '^\%(\\\|[A-Z]:\)') +endfunction + +function! s:git_dir(dir) abort + let gitdir = s:trim(a:dir) . '/.git' + if isdirectory(gitdir) + return gitdir + endif + if !filereadable(gitdir) + return '' + endif + let gitdir = matchstr(get(readfile(gitdir), 0, ''), '^gitdir: \zs.*') + if len(gitdir) && !s:isabsolute(gitdir) + let gitdir = a:dir . '/' . gitdir + endif + return isdirectory(gitdir) ? gitdir : '' +endfunction + +function! s:git_origin_url(dir) abort + let gitdir = s:git_dir(a:dir) + let config = gitdir . '/config' + if empty(gitdir) || !filereadable(config) + return '' + endif + return matchstr(join(readfile(config)), '\[remote "origin"\].\{-}url\s*=\s*\zs\S*\ze') +endfunction + +function! s:git_revision(dir) abort + let gitdir = s:git_dir(a:dir) + let head = gitdir . '/HEAD' + if empty(gitdir) || !filereadable(head) + return '' + endif + + let line = get(readfile(head), 0, '') + let ref = matchstr(line, '^ref: \zs.*') + if empty(ref) + return line + endif + + if filereadable(gitdir . '/' . ref) + return get(readfile(gitdir . '/' . ref), 0, '') + endif + + if filereadable(gitdir . '/packed-refs') + for line in readfile(gitdir . '/packed-refs') + if line =~# ' ' . ref + return matchstr(line, '^[0-9a-f]*') + endif + endfor + endif + + return '' +endfunction + +function! s:git_local_branch(dir) abort + let gitdir = s:git_dir(a:dir) + let head = gitdir . '/HEAD' + if empty(gitdir) || !filereadable(head) + return '' + endif + let branch = matchstr(get(readfile(head), 0, ''), '^ref: refs/heads/\zs.*') + return len(branch) ? branch : 'HEAD' +endfunction + +function! s:git_origin_branch(spec) + if len(a:spec.branch) + return a:spec.branch + endif + + " The file may not be present if this is a local repository + let gitdir = s:git_dir(a:spec.dir) + let origin_head = gitdir.'/refs/remotes/origin/HEAD' + if len(gitdir) && filereadable(origin_head) + return matchstr(get(readfile(origin_head), 0, ''), + \ '^ref: refs/remotes/origin/\zs.*') + endif + + " The command may not return the name of a branch in detached HEAD state + let result = s:lines(s:system('git symbolic-ref --short HEAD', a:spec.dir)) + return v:shell_error ? '' : result[-1] +endfunction + +if s:is_win + function! s:plug_call(fn, ...) + let shellslash = &shellslash + try + set noshellslash + return call(a:fn, a:000) + finally + let &shellslash = shellslash + endtry + endfunction +else + function! s:plug_call(fn, ...) + return call(a:fn, a:000) + endfunction +endif + +function! s:plug_getcwd() + return s:plug_call('getcwd') +endfunction + +function! s:plug_fnamemodify(fname, mods) + return s:plug_call('fnamemodify', a:fname, a:mods) +endfunction + +function! s:plug_expand(fmt) + return s:plug_call('expand', a:fmt, 1) +endfunction + +function! s:plug_tempname() + return s:plug_call('tempname') +endfunction + +function! plug#begin(...) + if a:0 > 0 + let s:plug_home_org = a:1 + let home = s:path(s:plug_fnamemodify(s:plug_expand(a:1), ':p')) + elseif exists('g:plug_home') + let home = s:path(g:plug_home) + elseif !empty(&rtp) + let home = s:path(split(&rtp, ',')[0]) . '/plugged' + else + return s:err('Unable to determine plug home. Try calling plug#begin() with a path argument.') + endif + if s:plug_fnamemodify(home, ':t') ==# 'plugin' && s:plug_fnamemodify(home, ':h') ==# s:first_rtp + return s:err('Invalid plug home. '.home.' is a standard Vim runtime path and is not allowed.') + endif + + let g:plug_home = home + let g:plugs = {} + let g:plugs_order = [] + let s:triggers = {} + + call s:define_commands() + return 1 +endfunction + +function! s:define_commands() + command! -nargs=+ -bar Plug call plug#() + if !executable('git') + return s:err('`git` executable not found. Most commands will not be available. To suppress this message, prepend `silent!` to `call plug#begin(...)`.') + endif + if has('win32') + \ && &shellslash + \ && (&shell =~# 'cmd\(\.exe\)\?$' || &shell =~# 'powershell\(\.exe\)\?$') + return s:err('vim-plug does not support shell, ' . &shell . ', when shellslash is set.') + endif + if !has('nvim') + \ && (has('win32') || has('win32unix')) + \ && !has('multi_byte') + return s:err('Vim needs +multi_byte feature on Windows to run shell commands. Enable +iconv for best results.') + endif + command! -nargs=* -bar -bang -complete=customlist,s:names PlugInstall call s:install(0, []) + command! -nargs=* -bar -bang -complete=customlist,s:names PlugUpdate call s:update(0, []) + command! -nargs=0 -bar -bang PlugClean call s:clean(0) + command! -nargs=0 -bar PlugUpgrade if s:upgrade() | execute 'source' s:esc(s:me) | endif + command! -nargs=0 -bar PlugStatus call s:status() + command! -nargs=0 -bar PlugDiff call s:diff() + command! -nargs=? -bar -bang -complete=file PlugSnapshot call s:snapshot(0, ) +endfunction + +function! s:to_a(v) + return type(a:v) == s:TYPE.list ? a:v : [a:v] +endfunction + +function! s:to_s(v) + return type(a:v) == s:TYPE.string ? a:v : join(a:v, "\n") . "\n" +endfunction + +function! s:glob(from, pattern) + return s:lines(globpath(a:from, a:pattern)) +endfunction + +function! s:source(from, ...) + let found = 0 + for pattern in a:000 + for vim in s:glob(a:from, pattern) + execute 'source' s:esc(vim) + let found = 1 + endfor + endfor + return found +endfunction + +function! s:assoc(dict, key, val) + let a:dict[a:key] = add(get(a:dict, a:key, []), a:val) +endfunction + +function! s:ask(message, ...) + call inputsave() + echohl WarningMsg + let answer = input(a:message.(a:0 ? ' (y/N/a) ' : ' (y/N) ')) + echohl None + call inputrestore() + echo "\r" + return (a:0 && answer =~? '^a') ? 2 : (answer =~? '^y') ? 1 : 0 +endfunction + +function! s:ask_no_interrupt(...) + try + return call('s:ask', a:000) + catch + return 0 + endtry +endfunction + +function! s:lazy(plug, opt) + return has_key(a:plug, a:opt) && + \ (empty(s:to_a(a:plug[a:opt])) || + \ !isdirectory(a:plug.dir) || + \ len(s:glob(s:rtp(a:plug), 'plugin')) || + \ len(s:glob(s:rtp(a:plug), 'after/plugin'))) +endfunction + +function! plug#end() + if !exists('g:plugs') + return s:err('plug#end() called without calling plug#begin() first') + endif + + if exists('#PlugLOD') + augroup PlugLOD + autocmd! + augroup END + augroup! PlugLOD + endif + let lod = { 'ft': {}, 'map': {}, 'cmd': {} } + + if exists('g:did_load_filetypes') + filetype off + endif + for name in g:plugs_order + if !has_key(g:plugs, name) + continue + endif + let plug = g:plugs[name] + if get(s:loaded, name, 0) || !s:lazy(plug, 'on') && !s:lazy(plug, 'for') + let s:loaded[name] = 1 + continue + endif + + if has_key(plug, 'on') + let s:triggers[name] = { 'map': [], 'cmd': [] } + for cmd in s:to_a(plug.on) + if cmd =~? '^.\+' + if empty(mapcheck(cmd)) && empty(mapcheck(cmd, 'i')) + call s:assoc(lod.map, cmd, name) + endif + call add(s:triggers[name].map, cmd) + elseif cmd =~# '^[A-Z]' + let cmd = substitute(cmd, '!*$', '', '') + if exists(':'.cmd) != 2 + call s:assoc(lod.cmd, cmd, name) + endif + call add(s:triggers[name].cmd, cmd) + else + call s:err('Invalid `on` option: '.cmd. + \ '. Should start with an uppercase letter or ``.') + endif + endfor + endif + + if has_key(plug, 'for') + let types = s:to_a(plug.for) + if !empty(types) + augroup filetypedetect + call s:source(s:rtp(plug), 'ftdetect/**/*.vim', 'after/ftdetect/**/*.vim') + augroup END + endif + for type in types + call s:assoc(lod.ft, type, name) + endfor + endif + endfor + + for [cmd, names] in items(lod.cmd) + execute printf( + \ 'command! -nargs=* -range -bang -complete=file %s call s:lod_cmd(%s, "", , , , %s)', + \ cmd, string(cmd), string(names)) + endfor + + for [map, names] in items(lod.map) + for [mode, map_prefix, key_prefix] in + \ [['i', '', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']] + execute printf( + \ '%snoremap %s %s:call lod_map(%s, %s, %s, "%s")', + \ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix) + endfor + endfor + + for [ft, names] in items(lod.ft) + augroup PlugLOD + execute printf('autocmd FileType %s call lod_ft(%s, %s)', + \ ft, string(ft), string(names)) + augroup END + endfor + + call s:reorg_rtp() + filetype plugin indent on + if has('vim_starting') + if has('syntax') && !exists('g:syntax_on') + syntax enable + end + else + call s:reload_plugins() + endif +endfunction + +function! s:loaded_names() + return filter(copy(g:plugs_order), 'get(s:loaded, v:val, 0)') +endfunction + +function! s:load_plugin(spec) + call s:source(s:rtp(a:spec), 'plugin/**/*.vim', 'after/plugin/**/*.vim') +endfunction + +function! s:reload_plugins() + for name in s:loaded_names() + call s:load_plugin(g:plugs[name]) + endfor +endfunction + +function! s:trim(str) + return substitute(a:str, '[\/]\+$', '', '') +endfunction + +function! s:version_requirement(val, min) + for idx in range(0, len(a:min) - 1) + let v = get(a:val, idx, 0) + if v < a:min[idx] | return 0 + elseif v > a:min[idx] | return 1 + endif + endfor + return 1 +endfunction + +function! s:git_version_requirement(...) + if !exists('s:git_version') + let s:git_version = map(split(split(s:system(['git', '--version']))[2], '\.'), 'str2nr(v:val)') + endif + return s:version_requirement(s:git_version, a:000) +endfunction + +function! s:progress_opt(base) + return a:base && !s:is_win && + \ s:git_version_requirement(1, 7, 1) ? '--progress' : '' +endfunction + +function! s:rtp(spec) + return s:path(a:spec.dir . get(a:spec, 'rtp', '')) +endfunction + +if s:is_win + function! s:path(path) + return s:trim(substitute(a:path, '/', '\', 'g')) + endfunction + + function! s:dirpath(path) + return s:path(a:path) . '\' + endfunction + + function! s:is_local_plug(repo) + return a:repo =~? '^[a-z]:\|^[%~]' + endfunction + + " Copied from fzf + function! s:wrap_cmds(cmds) + let cmds = [ + \ '@echo off', + \ 'setlocal enabledelayedexpansion'] + \ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) + \ + ['endlocal'] + if has('iconv') + if !exists('s:codepage') + let s:codepage = libcallnr('kernel32.dll', 'GetACP', 0) + endif + return map(cmds, printf('iconv(v:val."\r", "%s", "cp%d")', &encoding, s:codepage)) + endif + return map(cmds, 'v:val."\r"') + endfunction + + function! s:batchfile(cmd) + let batchfile = s:plug_tempname().'.bat' + call writefile(s:wrap_cmds(a:cmd), batchfile) + let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 0}) + if &shell =~# 'powershell\(\.exe\)\?$' + let cmd = '& ' . cmd + endif + return [batchfile, cmd] + endfunction +else + function! s:path(path) + return s:trim(a:path) + endfunction + + function! s:dirpath(path) + return substitute(a:path, '[/\\]*$', '/', '') + endfunction + + function! s:is_local_plug(repo) + return a:repo[0] =~ '[/$~]' + endfunction +endif + +function! s:err(msg) + echohl ErrorMsg + echom '[vim-plug] '.a:msg + echohl None +endfunction + +function! s:warn(cmd, msg) + echohl WarningMsg + execute a:cmd 'a:msg' + echohl None +endfunction + +function! s:esc(path) + return escape(a:path, ' ') +endfunction + +function! s:escrtp(path) + return escape(a:path, ' ,') +endfunction + +function! s:remove_rtp() + for name in s:loaded_names() + let rtp = s:rtp(g:plugs[name]) + execute 'set rtp-='.s:escrtp(rtp) + let after = globpath(rtp, 'after') + if isdirectory(after) + execute 'set rtp-='.s:escrtp(after) + endif + endfor +endfunction + +function! s:reorg_rtp() + if !empty(s:first_rtp) + execute 'set rtp-='.s:first_rtp + execute 'set rtp-='.s:last_rtp + endif + + " &rtp is modified from outside + if exists('s:prtp') && s:prtp !=# &rtp + call s:remove_rtp() + unlet! s:middle + endif + + let s:middle = get(s:, 'middle', &rtp) + let rtps = map(s:loaded_names(), 's:rtp(g:plugs[v:val])') + let afters = filter(map(copy(rtps), 'globpath(v:val, "after")'), '!empty(v:val)') + let rtp = join(map(rtps, 'escape(v:val, ",")'), ',') + \ . ','.s:middle.',' + \ . join(map(afters, 'escape(v:val, ",")'), ',') + let &rtp = substitute(substitute(rtp, ',,*', ',', 'g'), '^,\|,$', '', 'g') + let s:prtp = &rtp + + if !empty(s:first_rtp) + execute 'set rtp^='.s:first_rtp + execute 'set rtp+='.s:last_rtp + endif +endfunction + +function! s:doautocmd(...) + if exists('#'.join(a:000, '#')) + execute 'doautocmd' ((v:version > 703 || has('patch442')) ? '' : '') join(a:000) + endif +endfunction + +function! s:dobufread(names) + for name in a:names + let path = s:rtp(g:plugs[name]) + for dir in ['ftdetect', 'ftplugin', 'after/ftdetect', 'after/ftplugin'] + if len(finddir(dir, path)) + if exists('#BufRead') + doautocmd BufRead + endif + return + endif + endfor + endfor +endfunction + +function! plug#load(...) + if a:0 == 0 + return s:err('Argument missing: plugin name(s) required') + endif + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + let names = a:0 == 1 && type(a:1) == s:TYPE.list ? a:1 : a:000 + let unknowns = filter(copy(names), '!has_key(g:plugs, v:val)') + if !empty(unknowns) + let s = len(unknowns) > 1 ? 's' : '' + return s:err(printf('Unknown plugin%s: %s', s, join(unknowns, ', '))) + end + let unloaded = filter(copy(names), '!get(s:loaded, v:val, 0)') + if !empty(unloaded) + for name in unloaded + call s:lod([name], ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + endfor + call s:dobufread(unloaded) + return 1 + end + return 0 +endfunction + +function! s:remove_triggers(name) + if !has_key(s:triggers, a:name) + return + endif + for cmd in s:triggers[a:name].cmd + execute 'silent! delc' cmd + endfor + for map in s:triggers[a:name].map + execute 'silent! unmap' map + execute 'silent! iunmap' map + endfor + call remove(s:triggers, a:name) +endfunction + +function! s:lod(names, types, ...) + for name in a:names + call s:remove_triggers(name) + let s:loaded[name] = 1 + endfor + call s:reorg_rtp() + + for name in a:names + let rtp = s:rtp(g:plugs[name]) + for dir in a:types + call s:source(rtp, dir.'/**/*.vim') + endfor + if a:0 + if !s:source(rtp, a:1) && !empty(s:glob(rtp, a:2)) + execute 'runtime' a:1 + endif + call s:source(rtp, a:2) + endif + call s:doautocmd('User', name) + endfor +endfunction + +function! s:lod_ft(pat, names) + let syn = 'syntax/'.a:pat.'.vim' + call s:lod(a:names, ['plugin', 'after/plugin'], syn, 'after/'.syn) + execute 'autocmd! PlugLOD FileType' a:pat + call s:doautocmd('filetypeplugin', 'FileType') + call s:doautocmd('filetypeindent', 'FileType') +endfunction + +function! s:lod_cmd(cmd, bang, l1, l2, args, names) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + execute printf('%s%s%s %s', (a:l1 == a:l2 ? '' : (a:l1.','.a:l2)), a:cmd, a:bang, a:args) +endfunction + +function! s:lod_map(map, names, with_prefix, prefix) + call s:lod(a:names, ['ftdetect', 'after/ftdetect', 'plugin', 'after/plugin']) + call s:dobufread(a:names) + let extra = '' + while 1 + let c = getchar(0) + if c == 0 + break + endif + let extra .= nr2char(c) + endwhile + + if a:with_prefix + let prefix = v:count ? v:count : '' + let prefix .= '"'.v:register.a:prefix + if mode(1) == 'no' + if v:operator == 'c' + let prefix = "\" . prefix + endif + let prefix .= v:operator + endif + call feedkeys(prefix, 'n') + endif + call feedkeys(substitute(a:map, '^', "\", '') . extra) +endfunction + +function! plug#(repo, ...) + if a:0 > 1 + return s:err('Invalid number of arguments (1..2)') + endif + + try + let repo = s:trim(a:repo) + let opts = a:0 == 1 ? s:parse_options(a:1) : s:base_spec + let name = get(opts, 'as', s:plug_fnamemodify(repo, ':t:s?\.git$??')) + let spec = extend(s:infer_properties(name, repo), opts) + if !has_key(g:plugs, name) + call add(g:plugs_order, name) + endif + let g:plugs[name] = spec + let s:loaded[name] = get(s:loaded, name, 0) + catch + return s:err(repo . ' ' . v:exception) + endtry +endfunction + +function! s:parse_options(arg) + let opts = copy(s:base_spec) + let type = type(a:arg) + let opt_errfmt = 'Invalid argument for "%s" option of :Plug (expected: %s)' + if type == s:TYPE.string + if empty(a:arg) + throw printf(opt_errfmt, 'tag', 'string') + endif + let opts.tag = a:arg + elseif type == s:TYPE.dict + for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as'] + if has_key(a:arg, opt) + \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt])) + throw printf(opt_errfmt, opt, 'string') + endif + endfor + for opt in ['on', 'for'] + if has_key(a:arg, opt) + \ && type(a:arg[opt]) != s:TYPE.list + \ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt])) + throw printf(opt_errfmt, opt, 'string or list') + endif + endfor + if has_key(a:arg, 'do') + \ && type(a:arg.do) != s:TYPE.funcref + \ && (type(a:arg.do) != s:TYPE.string || empty(a:arg.do)) + throw printf(opt_errfmt, 'do', 'string or funcref') + endif + call extend(opts, a:arg) + if has_key(opts, 'dir') + let opts.dir = s:dirpath(s:plug_expand(opts.dir)) + endif + else + throw 'Invalid argument type (expected: string or dictionary)' + endif + return opts +endfunction + +function! s:infer_properties(name, repo) + let repo = a:repo + if s:is_local_plug(repo) + return { 'dir': s:dirpath(s:plug_expand(repo)) } + else + if repo =~ ':' + let uri = repo + else + if repo !~ '/' + throw printf('Invalid argument: %s (implicit `vim-scripts'' expansion is deprecated)', repo) + endif + let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git') + let uri = printf(fmt, repo) + endif + return { 'dir': s:dirpath(g:plug_home.'/'.a:name), 'uri': uri } + endif +endfunction + +function! s:install(force, names) + call s:update_impl(0, a:force, a:names) +endfunction + +function! s:update(force, names) + call s:update_impl(1, a:force, a:names) +endfunction + +function! plug#helptags() + if !exists('g:plugs') + return s:err('plug#begin was not called') + endif + for spec in values(g:plugs) + let docd = join([s:rtp(spec), 'doc'], '/') + if isdirectory(docd) + silent! execute 'helptags' s:esc(docd) + endif + endfor + return 1 +endfunction + +function! s:syntax() + syntax clear + syntax region plug1 start=/\%1l/ end=/\%2l/ contains=plugNumber + syntax region plug2 start=/\%2l/ end=/\%3l/ contains=plugBracket,plugX + syn match plugNumber /[0-9]\+[0-9.]*/ contained + syn match plugBracket /[[\]]/ contained + syn match plugX /x/ contained + syn match plugDash /^-\{1}\ / + syn match plugPlus /^+/ + syn match plugStar /^*/ + syn match plugMessage /\(^- \)\@<=.*/ + syn match plugName /\(^- \)\@<=[^ ]*:/ + syn match plugSha /\%(: \)\@<=[0-9a-f]\{4,}$/ + syn match plugTag /(tag: [^)]\+)/ + syn match plugInstall /\(^+ \)\@<=[^:]*/ + syn match plugUpdate /\(^* \)\@<=[^:]*/ + syn match plugCommit /^ \X*[0-9a-f]\{7,9} .*/ contains=plugRelDate,plugEdge,plugTag + syn match plugEdge /^ \X\+$/ + syn match plugEdge /^ \X*/ contained nextgroup=plugSha + syn match plugSha /[0-9a-f]\{7,9}/ contained + syn match plugRelDate /([^)]*)$/ contained + syn match plugNotLoaded /(not loaded)$/ + syn match plugError /^x.*/ + syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/ + syn match plugH2 /^.*:\n-\+$/ + syn match plugH2 /^-\{2,}/ + syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean + hi def link plug1 Title + hi def link plug2 Repeat + hi def link plugH2 Type + hi def link plugX Exception + hi def link plugBracket Structure + hi def link plugNumber Number + + hi def link plugDash Special + hi def link plugPlus Constant + hi def link plugStar Boolean + + hi def link plugMessage Function + hi def link plugName Label + hi def link plugInstall Function + hi def link plugUpdate Type + + hi def link plugError Error + hi def link plugDeleted Ignore + hi def link plugRelDate Comment + hi def link plugEdge PreProc + hi def link plugSha Identifier + hi def link plugTag Constant + + hi def link plugNotLoaded Comment +endfunction + +function! s:lpad(str, len) + return a:str . repeat(' ', a:len - len(a:str)) +endfunction + +function! s:lines(msg) + return split(a:msg, "[\r\n]") +endfunction + +function! s:lastline(msg) + return get(s:lines(a:msg), -1, '') +endfunction + +function! s:new_window() + execute get(g:, 'plug_window', 'vertical topleft new') +endfunction + +function! s:plug_window_exists() + let buflist = tabpagebuflist(s:plug_tab) + return !empty(buflist) && index(buflist, s:plug_buf) >= 0 +endfunction + +function! s:switch_in() + if !s:plug_window_exists() + return 0 + endif + + if winbufnr(0) != s:plug_buf + let s:pos = [tabpagenr(), winnr(), winsaveview()] + execute 'normal!' s:plug_tab.'gt' + let winnr = bufwinnr(s:plug_buf) + execute winnr.'wincmd w' + call add(s:pos, winsaveview()) + else + let s:pos = [winsaveview()] + endif + + setlocal modifiable + return 1 +endfunction + +function! s:switch_out(...) + call winrestview(s:pos[-1]) + setlocal nomodifiable + if a:0 > 0 + execute a:1 + endif + + if len(s:pos) > 1 + execute 'normal!' s:pos[0].'gt' + execute s:pos[1] 'wincmd w' + call winrestview(s:pos[2]) + endif +endfunction + +function! s:finish_bindings() + nnoremap R :call retry() + nnoremap D :PlugDiff + nnoremap S :PlugStatus + nnoremap U :call status_update() + xnoremap U :call status_update() + nnoremap ]] :silent! call section('') + nnoremap [[ :silent! call section('b') +endfunction + +function! s:prepare(...) + if empty(s:plug_getcwd()) + throw 'Invalid current working directory. Cannot proceed.' + endif + + for evar in ['$GIT_DIR', '$GIT_WORK_TREE'] + if exists(evar) + throw evar.' detected. Cannot proceed.' + endif + endfor + + call s:job_abort() + if s:switch_in() + if b:plug_preview == 1 + pc + endif + enew + else + call s:new_window() + endif + + nnoremap q :call close_pane() + if a:0 == 0 + call s:finish_bindings() + endif + let b:plug_preview = -1 + let s:plug_tab = tabpagenr() + let s:plug_buf = winbufnr(0) + call s:assign_name() + + for k in ['', 'L', 'o', 'X', 'd', 'dd'] + execute 'silent! unmap ' k + endfor + setlocal buftype=nofile bufhidden=wipe nobuflisted nolist noswapfile nowrap cursorline modifiable nospell + if exists('+colorcolumn') + setlocal colorcolumn= + endif + setf vim-plug + if exists('g:syntax_on') + call s:syntax() + endif +endfunction + +function! s:close_pane() + if b:plug_preview == 1 + pc + let b:plug_preview = -1 + else + bd + endif +endfunction + +function! s:assign_name() + " Assign buffer name + let prefix = '[Plugins]' + let name = prefix + let idx = 2 + while bufexists(name) + let name = printf('%s (%s)', prefix, idx) + let idx = idx + 1 + endwhile + silent! execute 'f' fnameescape(name) +endfunction + +function! s:chsh(swap) + let prev = [&shell, &shellcmdflag, &shellredir] + if !s:is_win + set shell=sh + endif + if a:swap + if &shell =~# 'powershell\(\.exe\)\?$' || &shell =~# 'pwsh$' + let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s' + elseif &shell =~# 'sh' || &shell =~# 'cmd\(\.exe\)\?$' + set shellredir=>%s\ 2>&1 + endif + endif + return prev +endfunction + +function! s:bang(cmd, ...) + let batchfile = '' + try + let [sh, shellcmdflag, shrd] = s:chsh(a:0) + " FIXME: Escaping is incomplete. We could use shellescape with eval, + " but it won't work on Windows. + let cmd = a:0 ? s:with_cd(a:cmd, a:1) : a:cmd + if s:is_win + let [batchfile, cmd] = s:batchfile(cmd) + endif + let g:_plug_bang = (s:is_win && has('gui_running') ? 'silent ' : '').'!'.escape(cmd, '#!%') + execute "normal! :execute g:_plug_bang\\" + finally + unlet g:_plug_bang + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win && filereadable(batchfile) + call delete(batchfile) + endif + endtry + return v:shell_error ? 'Exit status: ' . v:shell_error : '' +endfunction + +function! s:regress_bar() + let bar = substitute(getline(2)[1:-2], '.*\zs=', 'x', '') + call s:progress_bar(2, bar, len(bar)) +endfunction + +function! s:is_updated(dir) + return !empty(s:system_chomp(['git', 'log', '--pretty=format:%h', 'HEAD...HEAD@{1}'], a:dir)) +endfunction + +function! s:do(pull, force, todo) + for [name, spec] in items(a:todo) + if !isdirectory(spec.dir) + continue + endif + let installed = has_key(s:update.new, name) + let updated = installed ? 0 : + \ (a:pull && index(s:update.errors, name) < 0 && s:is_updated(spec.dir)) + if a:force || installed || updated + execute 'cd' s:esc(spec.dir) + call append(3, '- Post-update hook for '. name .' ... ') + let error = '' + let type = type(spec.do) + if type == s:TYPE.string + if spec.do[0] == ':' + if !get(s:loaded, name, 0) + let s:loaded[name] = 1 + call s:reorg_rtp() + endif + call s:load_plugin(spec) + try + execute spec.do[1:] + catch + let error = v:exception + endtry + if !s:plug_window_exists() + cd - + throw 'Warning: vim-plug was terminated by the post-update hook of '.name + endif + else + let error = s:bang(spec.do) + endif + elseif type == s:TYPE.funcref + try + call s:load_plugin(spec) + let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged') + call spec.do({ 'name': name, 'status': status, 'force': a:force }) + catch + let error = v:exception + endtry + else + let error = 'Invalid hook type' + endif + call s:switch_in() + call setline(4, empty(error) ? (getline(4) . 'OK') + \ : ('x' . getline(4)[1:] . error)) + if !empty(error) + call add(s:update.errors, name) + call s:regress_bar() + endif + cd - + endif + endfor +endfunction + +function! s:hash_match(a, b) + return stridx(a:a, a:b) == 0 || stridx(a:b, a:a) == 0 +endfunction + +function! s:checkout(spec) + let sha = a:spec.commit + let output = s:git_revision(a:spec.dir) + if !empty(output) && !s:hash_match(sha, s:lines(output)[0]) + let credential_helper = s:git_version_requirement(2) ? '-c credential.helper= ' : '' + let output = s:system( + \ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir) + endif + return output +endfunction + +function! s:finish(pull) + let new_frozen = len(filter(keys(s:update.new), 'g:plugs[v:val].frozen')) + if new_frozen + let s = new_frozen > 1 ? 's' : '' + call append(3, printf('- Installed %d frozen plugin%s', new_frozen, s)) + endif + call append(3, '- Finishing ... ') | 4 + redraw + call plug#helptags() + call plug#end() + call setline(4, getline(4) . 'Done!') + redraw + let msgs = [] + if !empty(s:update.errors) + call add(msgs, "Press 'R' to retry.") + endif + if a:pull && len(s:update.new) < len(filter(getline(5, '$'), + \ "v:val =~ '^- ' && v:val !~# 'Already up.to.date'")) + call add(msgs, "Press 'D' to see the updated changes.") + endif + echo join(msgs, ' ') + call s:finish_bindings() +endfunction + +function! s:retry() + if empty(s:update.errors) + return + endif + echo + call s:update_impl(s:update.pull, s:update.force, + \ extend(copy(s:update.errors), [s:update.threads])) +endfunction + +function! s:is_managed(name) + return has_key(g:plugs[a:name], 'uri') +endfunction + +function! s:names(...) + return sort(filter(keys(g:plugs), 'stridx(v:val, a:1) == 0 && s:is_managed(v:val)')) +endfunction + +function! s:check_ruby() + silent! ruby require 'thread'; VIM::command("let g:plug_ruby = '#{RUBY_VERSION}'") + if !exists('g:plug_ruby') + redraw! + return s:warn('echom', 'Warning: Ruby interface is broken') + endif + let ruby_version = split(g:plug_ruby, '\.') + unlet g:plug_ruby + return s:version_requirement(ruby_version, [1, 8, 7]) +endfunction + +function! s:update_impl(pull, force, args) abort + let sync = index(a:args, '--sync') >= 0 || has('vim_starting') + let args = filter(copy(a:args), 'v:val != "--sync"') + let threads = (len(args) > 0 && args[-1] =~ '^[1-9][0-9]*$') ? + \ remove(args, -1) : get(g:, 'plug_threads', 16) + + let managed = filter(copy(g:plugs), 's:is_managed(v:key)') + let todo = empty(args) ? filter(managed, '!v:val.frozen || !isdirectory(v:val.dir)') : + \ filter(managed, 'index(args, v:key) >= 0') + + if empty(todo) + return s:warn('echo', 'No plugin to '. (a:pull ? 'update' : 'install')) + endif + + if !s:is_win && s:git_version_requirement(2, 3) + let s:git_terminal_prompt = exists('$GIT_TERMINAL_PROMPT') ? $GIT_TERMINAL_PROMPT : '' + let $GIT_TERMINAL_PROMPT = 0 + for plug in values(todo) + let plug.uri = substitute(plug.uri, + \ '^https://git::@github\.com', 'https://github.com', '') + endfor + endif + + if !isdirectory(g:plug_home) + try + call mkdir(g:plug_home, 'p') + catch + return s:err(printf('Invalid plug directory: %s. '. + \ 'Try to call plug#begin with a valid directory', g:plug_home)) + endtry + endif + + if has('nvim') && !exists('*jobwait') && threads > 1 + call s:warn('echom', '[vim-plug] Update Neovim for parallel installer') + endif + + let use_job = s:nvim || s:vim8 + let python = (has('python') || has('python3')) && !use_job + let ruby = has('ruby') && !use_job && (v:version >= 703 || v:version == 702 && has('patch374')) && !(s:is_win && has('gui_running')) && threads > 1 && s:check_ruby() + + let s:update = { + \ 'start': reltime(), + \ 'all': todo, + \ 'todo': copy(todo), + \ 'errors': [], + \ 'pull': a:pull, + \ 'force': a:force, + \ 'new': {}, + \ 'threads': (python || ruby || use_job) ? min([len(todo), threads]) : 1, + \ 'bar': '', + \ 'fin': 0 + \ } + + call s:prepare(1) + call append(0, ['', '']) + normal! 2G + silent! redraw + + let s:clone_opt = [] + if get(g:, 'plug_shallow', 1) + call extend(s:clone_opt, ['--depth', '1']) + if s:git_version_requirement(1, 7, 10) + call add(s:clone_opt, '--no-single-branch') + endif + endif + + if has('win32unix') || has('wsl') + call extend(s:clone_opt, ['-c', 'core.eol=lf', '-c', 'core.autocrlf=input']) + endif + + let s:submodule_opt = s:git_version_requirement(2, 8) ? ' --jobs='.threads : '' + + " Python version requirement (>= 2.7) + if python && !has('python3') && !ruby && !use_job && s:update.threads > 1 + redir => pyv + silent python import platform; print platform.python_version() + redir END + let python = s:version_requirement( + \ map(split(split(pyv)[0], '\.'), 'str2nr(v:val)'), [2, 6]) + endif + + if (python || ruby) && s:update.threads > 1 + try + let imd = &imd + if s:mac_gui + set noimd + endif + if ruby + call s:update_ruby() + else + call s:update_python() + endif + catch + let lines = getline(4, '$') + let printed = {} + silent! 4,$d _ + for line in lines + let name = s:extract_name(line, '.', '') + if empty(name) || !has_key(printed, name) + call append('$', line) + if !empty(name) + let printed[name] = 1 + if line[0] == 'x' && index(s:update.errors, name) < 0 + call add(s:update.errors, name) + end + endif + endif + endfor + finally + let &imd = imd + call s:update_finish() + endtry + else + call s:update_vim() + while use_job && sync + sleep 100m + if s:update.fin + break + endif + endwhile + endif +endfunction + +function! s:log4(name, msg) + call setline(4, printf('- %s (%s)', a:msg, a:name)) + redraw +endfunction + +function! s:update_finish() + if exists('s:git_terminal_prompt') + let $GIT_TERMINAL_PROMPT = s:git_terminal_prompt + endif + if s:switch_in() + call append(3, '- Updating ...') | 4 + for [name, spec] in items(filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && (s:update.force || s:update.pull || has_key(s:update.new, v:key))')) + let [pos, _] = s:logpos(name) + if !pos + continue + endif + if has_key(spec, 'commit') + call s:log4(name, 'Checking out '.spec.commit) + let out = s:checkout(spec) + elseif has_key(spec, 'tag') + let tag = spec.tag + if tag =~ '\*' + let tags = s:lines(s:system('git tag --list '.plug#shellescape(tag).' --sort -version:refname 2>&1', spec.dir)) + if !v:shell_error && !empty(tags) + let tag = tags[0] + call s:log4(name, printf('Latest tag for %s -> %s', spec.tag, tag)) + call append(3, '') + endif + endif + call s:log4(name, 'Checking out '.tag) + let out = s:system('git checkout -q '.plug#shellescape(tag).' -- 2>&1', spec.dir) + else + let branch = s:git_origin_branch(spec) + call s:log4(name, 'Merging origin/'.s:esc(branch)) + let out = s:system('git checkout -q '.plug#shellescape(branch).' -- 2>&1' + \. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only '.plug#shellescape('origin/'.branch).' 2>&1')), spec.dir) + endif + if !v:shell_error && filereadable(spec.dir.'/.gitmodules') && + \ (s:update.force || has_key(s:update.new, name) || s:is_updated(spec.dir)) + call s:log4(name, 'Updating submodules. This may take a while.') + let out .= s:bang('git submodule update --init --recursive'.s:submodule_opt.' 2>&1', spec.dir) + endif + let msg = s:format_message(v:shell_error ? 'x': '-', name, out) + if v:shell_error + call add(s:update.errors, name) + call s:regress_bar() + silent execute pos 'd _' + call append(4, msg) | 4 + elseif !empty(out) + call setline(pos, msg[0]) + endif + redraw + endfor + silent 4 d _ + try + call s:do(s:update.pull, s:update.force, filter(copy(s:update.all), 'index(s:update.errors, v:key) < 0 && has_key(v:val, "do")')) + catch + call s:warn('echom', v:exception) + call s:warn('echo', '') + return + endtry + call s:finish(s:update.pull) + call setline(1, 'Updated. Elapsed time: ' . split(reltimestr(reltime(s:update.start)))[0] . ' sec.') + call s:switch_out('normal! gg') + endif +endfunction + +function! s:job_abort() + if (!s:nvim && !s:vim8) || !exists('s:jobs') + return + endif + + for [name, j] in items(s:jobs) + if s:nvim + silent! call jobstop(j.jobid) + elseif s:vim8 + silent! call job_stop(j.jobid) + endif + if j.new + call s:rm_rf(g:plugs[name].dir) + endif + endfor + let s:jobs = {} +endfunction + +function! s:last_non_empty_line(lines) + let len = len(a:lines) + for idx in range(len) + let line = a:lines[len-idx-1] + if !empty(line) + return line + endif + endfor + return '' +endfunction + +function! s:job_out_cb(self, data) abort + let self = a:self + let data = remove(self.lines, -1) . a:data + let lines = map(split(data, "\n", 1), 'split(v:val, "\r", 1)[-1]') + call extend(self.lines, lines) + " To reduce the number of buffer updates + let self.tick = get(self, 'tick', -1) + 1 + if !self.running || self.tick % len(s:jobs) == 0 + let bullet = self.running ? (self.new ? '+' : '*') : (self.error ? 'x' : '-') + let result = self.error ? join(self.lines, "\n") : s:last_non_empty_line(self.lines) + call s:log(bullet, self.name, result) + endif +endfunction + +function! s:job_exit_cb(self, data) abort + let a:self.running = 0 + let a:self.error = a:data != 0 + call s:reap(a:self.name) + call s:tick() +endfunction + +function! s:job_cb(fn, job, ch, data) + if !s:plug_window_exists() " plug window closed + return s:job_abort() + endif + call call(a:fn, [a:job, a:data]) +endfunction + +function! s:nvim_cb(job_id, data, event) dict abort + return (a:event == 'stdout' || a:event == 'stderr') ? + \ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) : + \ s:job_cb('s:job_exit_cb', self, 0, a:data) +endfunction + +function! s:spawn(name, cmd, opts) + let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''], + \ 'new': get(a:opts, 'new', 0) } + let s:jobs[a:name] = job + + if s:nvim + if has_key(a:opts, 'dir') + let job.cwd = a:opts.dir + endif + let argv = a:cmd + call extend(job, { + \ 'on_stdout': function('s:nvim_cb'), + \ 'on_stderr': function('s:nvim_cb'), + \ 'on_exit': function('s:nvim_cb'), + \ }) + let jid = s:plug_call('jobstart', argv, job) + if jid > 0 + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = [jid < 0 ? argv[0].' is not executable' : + \ 'Invalid arguments (or job table is full)'] + endif + elseif s:vim8 + let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"script": 0})')) + if has_key(a:opts, 'dir') + let cmd = s:with_cd(cmd, a:opts.dir, 0) + endif + let argv = s:is_win ? ['cmd', '/s', '/c', '"'.cmd.'"'] : ['sh', '-c', cmd] + let jid = job_start(s:is_win ? join(argv, ' ') : argv, { + \ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'err_cb': function('s:job_cb', ['s:job_out_cb', job]), + \ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]), + \ 'err_mode': 'raw', + \ 'out_mode': 'raw' + \}) + if job_status(jid) == 'run' + let job.jobid = jid + else + let job.running = 0 + let job.error = 1 + let job.lines = ['Failed to start job'] + endif + else + let job.lines = s:lines(call('s:system', has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd])) + let job.error = v:shell_error != 0 + let job.running = 0 + endif +endfunction + +function! s:reap(name) + let job = s:jobs[a:name] + if job.error + call add(s:update.errors, a:name) + elseif get(job, 'new', 0) + let s:update.new[a:name] = 1 + endif + let s:update.bar .= job.error ? 'x' : '=' + + let bullet = job.error ? 'x' : '-' + let result = job.error ? join(job.lines, "\n") : s:last_non_empty_line(job.lines) + call s:log(bullet, a:name, empty(result) ? 'OK' : result) + call s:bar() + + call remove(s:jobs, a:name) +endfunction + +function! s:bar() + if s:switch_in() + let total = len(s:update.all) + call setline(1, (s:update.pull ? 'Updating' : 'Installing'). + \ ' plugins ('.len(s:update.bar).'/'.total.')') + call s:progress_bar(2, s:update.bar, total) + call s:switch_out() + endif +endfunction + +function! s:logpos(name) + let max = line('$') + for i in range(4, max > 4 ? max : 4) + if getline(i) =~# '^[-+x*] '.a:name.':' + for j in range(i + 1, max > 5 ? max : 5) + if getline(j) !~ '^ ' + return [i, j - 1] + endif + endfor + return [i, i] + endif + endfor + return [0, 0] +endfunction + +function! s:log(bullet, name, lines) + if s:switch_in() + let [b, e] = s:logpos(a:name) + if b > 0 + silent execute printf('%d,%d d _', b, e) + if b > winheight('.') + let b = 4 + endif + else + let b = 4 + endif + " FIXME For some reason, nomodifiable is set after :d in vim8 + setlocal modifiable + call append(b - 1, s:format_message(a:bullet, a:name, a:lines)) + call s:switch_out() + endif +endfunction + +function! s:update_vim() + let s:jobs = {} + + call s:bar() + call s:tick() +endfunction + +function! s:tick() + let pull = s:update.pull + let prog = s:progress_opt(s:nvim || s:vim8) +while 1 " Without TCO, Vim stack is bound to explode + if empty(s:update.todo) + if empty(s:jobs) && !s:update.fin + call s:update_finish() + let s:update.fin = 1 + endif + return + endif + + let name = keys(s:update.todo)[0] + let spec = remove(s:update.todo, name) + let new = empty(globpath(spec.dir, '.git', 1)) + + call s:log(new ? '+' : '*', name, pull ? 'Updating ...' : 'Installing ...') + redraw + + let has_tag = has_key(spec, 'tag') + if !new + let [error, _] = s:git_validate(spec, 0) + if empty(error) + if pull + let cmd = s:git_version_requirement(2) ? ['git', '-c', 'credential.helper=', 'fetch'] : ['git', 'fetch'] + if has_tag && !empty(globpath(spec.dir, '.git/shallow')) + call extend(cmd, ['--depth', '99999999']) + endif + if !empty(prog) + call add(cmd, prog) + endif + call s:spawn(name, cmd, { 'dir': spec.dir }) + else + let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 } + endif + else + let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 } + endif + else + let cmd = ['git', 'clone'] + if !has_tag + call extend(cmd, s:clone_opt) + endif + if !empty(prog) + call add(cmd, prog) + endif + call s:spawn(name, extend(cmd, [spec.uri, s:trim(spec.dir)]), { 'new': 1 }) + endif + + if !s:jobs[name].running + call s:reap(name) + endif + if len(s:jobs) >= s:update.threads + break + endif +endwhile +endfunction + +function! s:update_python() +let py_exe = has('python') ? 'python' : 'python3' +execute py_exe "<< EOF" +import datetime +import functools +import os +try: + import queue +except ImportError: + import Queue as queue +import random +import re +import shutil +import signal +import subprocess +import tempfile +import threading as thr +import time +import traceback +import vim + +G_NVIM = vim.eval("has('nvim')") == '1' +G_PULL = vim.eval('s:update.pull') == '1' +G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1 +G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)')) +G_CLONE_OPT = ' '.join(vim.eval('s:clone_opt')) +G_PROGRESS = vim.eval('s:progress_opt(1)') +G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads')) +G_STOP = thr.Event() +G_IS_WIN = vim.eval('s:is_win') == '1' + +class PlugError(Exception): + def __init__(self, msg): + self.msg = msg +class CmdTimedOut(PlugError): + pass +class CmdFailed(PlugError): + pass +class InvalidURI(PlugError): + pass +class Action(object): + INSTALL, UPDATE, ERROR, DONE = ['+', '*', 'x', '-'] + +class Buffer(object): + def __init__(self, lock, num_plugs, is_pull): + self.bar = '' + self.event = 'Updating' if is_pull else 'Installing' + self.lock = lock + self.maxy = int(vim.eval('winheight(".")')) + self.num_plugs = num_plugs + + def __where(self, name): + """ Find first line with name in current buffer. Return line num. """ + found, lnum = False, 0 + matcher = re.compile('^[-+x*] {0}:'.format(name)) + for line in vim.current.buffer: + if matcher.search(line) is not None: + found = True + break + lnum += 1 + + if not found: + lnum = -1 + return lnum + + def header(self): + curbuf = vim.current.buffer + curbuf[0] = self.event + ' plugins ({0}/{1})'.format(len(self.bar), self.num_plugs) + + num_spaces = self.num_plugs - len(self.bar) + curbuf[1] = '[{0}{1}]'.format(self.bar, num_spaces * ' ') + + with self.lock: + vim.command('normal! 2G') + vim.command('redraw') + + def write(self, action, name, lines): + first, rest = lines[0], lines[1:] + msg = ['{0} {1}{2}{3}'.format(action, name, ': ' if first else '', first)] + msg.extend([' ' + line for line in rest]) + + try: + if action == Action.ERROR: + self.bar += 'x' + vim.command("call add(s:update.errors, '{0}')".format(name)) + elif action == Action.DONE: + self.bar += '=' + + curbuf = vim.current.buffer + lnum = self.__where(name) + if lnum != -1: # Found matching line num + del curbuf[lnum] + if lnum > self.maxy and action in set([Action.INSTALL, Action.UPDATE]): + lnum = 3 + else: + lnum = 3 + curbuf.append(msg, lnum) + + self.header() + except vim.error: + pass + +class Command(object): + CD = 'cd /d' if G_IS_WIN else 'cd' + + def __init__(self, cmd, cmd_dir=None, timeout=60, cb=None, clean=None): + self.cmd = cmd + if cmd_dir: + self.cmd = '{0} {1} && {2}'.format(Command.CD, cmd_dir, self.cmd) + self.timeout = timeout + self.callback = cb if cb else (lambda msg: None) + self.clean = clean if clean else (lambda: None) + self.proc = None + + @property + def alive(self): + """ Returns true only if command still running. """ + return self.proc and self.proc.poll() is None + + def execute(self, ntries=3): + """ Execute the command with ntries if CmdTimedOut. + Returns the output of the command if no Exception. + """ + attempt, finished, limit = 0, False, self.timeout + + while not finished: + try: + attempt += 1 + result = self.try_command() + finished = True + return result + except CmdTimedOut: + if attempt != ntries: + self.notify_retry() + self.timeout += limit + else: + raise + + def notify_retry(self): + """ Retry required for command, notify user. """ + for count in range(3, 0, -1): + if G_STOP.is_set(): + raise KeyboardInterrupt + msg = 'Timeout. Will retry in {0} second{1} ...'.format( + count, 's' if count != 1 else '') + self.callback([msg]) + time.sleep(1) + self.callback(['Retrying ...']) + + def try_command(self): + """ Execute a cmd & poll for callback. Returns list of output. + Raises CmdFailed -> return code for Popen isn't 0 + Raises CmdTimedOut -> command exceeded timeout without new output + """ + first_line = True + + try: + tfile = tempfile.NamedTemporaryFile(mode='w+b') + preexec_fn = not G_IS_WIN and os.setsid or None + self.proc = subprocess.Popen(self.cmd, stdout=tfile, + stderr=subprocess.STDOUT, + stdin=subprocess.PIPE, shell=True, + preexec_fn=preexec_fn) + thrd = thr.Thread(target=(lambda proc: proc.wait()), args=(self.proc,)) + thrd.start() + + thread_not_started = True + while thread_not_started: + try: + thrd.join(0.1) + thread_not_started = False + except RuntimeError: + pass + + while self.alive: + if G_STOP.is_set(): + raise KeyboardInterrupt + + if first_line or random.random() < G_LOG_PROB: + first_line = False + line = '' if G_IS_WIN else nonblock_read(tfile.name) + if line: + self.callback([line]) + + time_diff = time.time() - os.path.getmtime(tfile.name) + if time_diff > self.timeout: + raise CmdTimedOut(['Timeout!']) + + thrd.join(0.5) + + tfile.seek(0) + result = [line.decode('utf-8', 'replace').rstrip() for line in tfile] + + if self.proc.returncode != 0: + raise CmdFailed([''] + result) + + return result + except: + self.terminate() + raise + + def terminate(self): + """ Terminate process and cleanup. """ + if self.alive: + if G_IS_WIN: + os.kill(self.proc.pid, signal.SIGINT) + else: + os.killpg(self.proc.pid, signal.SIGTERM) + self.clean() + +class Plugin(object): + def __init__(self, name, args, buf_q, lock): + self.name = name + self.args = args + self.buf_q = buf_q + self.lock = lock + self.tag = args.get('tag', 0) + + def manage(self): + try: + if os.path.exists(self.args['dir']): + self.update() + else: + self.install() + with self.lock: + thread_vim_command("let s:update.new['{0}'] = 1".format(self.name)) + except PlugError as exc: + self.write(Action.ERROR, self.name, exc.msg) + except KeyboardInterrupt: + G_STOP.set() + self.write(Action.ERROR, self.name, ['Interrupted!']) + except: + # Any exception except those above print stack trace + msg = 'Trace:\n{0}'.format(traceback.format_exc().rstrip()) + self.write(Action.ERROR, self.name, msg.split('\n')) + raise + + def install(self): + target = self.args['dir'] + if target[-1] == '\\': + target = target[0:-1] + + def clean(target): + def _clean(): + try: + shutil.rmtree(target) + except OSError: + pass + return _clean + + self.write(Action.INSTALL, self.name, ['Installing ...']) + callback = functools.partial(self.write, Action.INSTALL, self.name) + cmd = 'git clone {0} {1} {2} {3} 2>&1'.format( + '' if self.tag else G_CLONE_OPT, G_PROGRESS, self.args['uri'], + esc(target)) + com = Command(cmd, None, G_TIMEOUT, callback, clean(target)) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + + def repo_uri(self): + cmd = 'git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url' + command = Command(cmd, self.args['dir'], G_TIMEOUT,) + result = command.execute(G_RETRIES) + return result[-1] + + def update(self): + actual_uri = self.repo_uri() + expect_uri = self.args['uri'] + regex = re.compile(r'^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$') + ma = regex.match(actual_uri) + mb = regex.match(expect_uri) + if ma is None or mb is None or ma.groups() != mb.groups(): + msg = ['', + 'Invalid URI: {0}'.format(actual_uri), + 'Expected {0}'.format(expect_uri), + 'PlugClean required.'] + raise InvalidURI(msg) + + if G_PULL: + self.write(Action.UPDATE, self.name, ['Updating ...']) + callback = functools.partial(self.write, Action.UPDATE, self.name) + fetch_opt = '--depth 99999999' if self.tag and os.path.isfile(os.path.join(self.args['dir'], '.git/shallow')) else '' + cmd = 'git fetch {0} {1} 2>&1'.format(fetch_opt, G_PROGRESS) + com = Command(cmd, self.args['dir'], G_TIMEOUT, callback) + result = com.execute(G_RETRIES) + self.write(Action.DONE, self.name, result[-1:]) + else: + self.write(Action.DONE, self.name, ['Already installed']) + + def write(self, action, name, msg): + self.buf_q.put((action, name, msg)) + +class PlugThread(thr.Thread): + def __init__(self, tname, args): + super(PlugThread, self).__init__() + self.tname = tname + self.args = args + + def run(self): + thr.current_thread().name = self.tname + buf_q, work_q, lock = self.args + + try: + while not G_STOP.is_set(): + name, args = work_q.get_nowait() + plug = Plugin(name, args, buf_q, lock) + plug.manage() + work_q.task_done() + except queue.Empty: + pass + +class RefreshThread(thr.Thread): + def __init__(self, lock): + super(RefreshThread, self).__init__() + self.lock = lock + self.running = True + + def run(self): + while self.running: + with self.lock: + thread_vim_command('noautocmd normal! a') + time.sleep(0.33) + + def stop(self): + self.running = False + +if G_NVIM: + def thread_vim_command(cmd): + vim.session.threadsafe_call(lambda: vim.command(cmd)) +else: + def thread_vim_command(cmd): + vim.command(cmd) + +def esc(name): + return '"' + name.replace('"', '\"') + '"' + +def nonblock_read(fname): + """ Read a file with nonblock flag. Return the last line. """ + fread = os.open(fname, os.O_RDONLY | os.O_NONBLOCK) + buf = os.read(fread, 100000).decode('utf-8', 'replace') + os.close(fread) + + line = buf.rstrip('\r\n') + left = max(line.rfind('\r'), line.rfind('\n')) + if left != -1: + left += 1 + line = line[left:] + + return line + +def main(): + thr.current_thread().name = 'main' + nthreads = int(vim.eval('s:update.threads')) + plugs = vim.eval('s:update.todo') + mac_gui = vim.eval('s:mac_gui') == '1' + + lock = thr.Lock() + buf = Buffer(lock, len(plugs), G_PULL) + buf_q, work_q = queue.Queue(), queue.Queue() + for work in plugs.items(): + work_q.put(work) + + start_cnt = thr.active_count() + for num in range(nthreads): + tname = 'PlugT-{0:02}'.format(num) + thread = PlugThread(tname, (buf_q, work_q, lock)) + thread.start() + if mac_gui: + rthread = RefreshThread(lock) + rthread.start() + + while not buf_q.empty() or thr.active_count() != start_cnt: + try: + action, name, msg = buf_q.get(True, 0.25) + buf.write(action, name, ['OK'] if not msg else msg) + buf_q.task_done() + except queue.Empty: + pass + except KeyboardInterrupt: + G_STOP.set() + + if mac_gui: + rthread.stop() + rthread.join() + +main() +EOF +endfunction + +function! s:update_ruby() + ruby << EOF + module PlugStream + SEP = ["\r", "\n", nil] + def get_line + buffer = '' + loop do + char = readchar rescue return + if SEP.include? char.chr + buffer << $/ + break + else + buffer << char + end + end + buffer + end + end unless defined?(PlugStream) + + def esc arg + %["#{arg.gsub('"', '\"')}"] + end + + def killall pid + pids = [pid] + if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM + pids.each { |pid| Process.kill 'INT', pid.to_i rescue nil } + else + unless `which pgrep 2> /dev/null`.empty? + children = pids + until children.empty? + children = children.map { |pid| + `pgrep -P #{pid}`.lines.map { |l| l.chomp } + }.flatten + pids += children + end + end + pids.each { |pid| Process.kill 'TERM', pid.to_i rescue nil } + end + end + + def compare_git_uri a, b + regex = %r{^(?:\w+://)?(?:[^@/]*@)?([^:/]*(?::[0-9]*)?)[:/](.*?)(?:\.git)?/?$} + regex.match(a).to_a.drop(1) == regex.match(b).to_a.drop(1) + end + + require 'thread' + require 'fileutils' + require 'timeout' + running = true + iswin = VIM::evaluate('s:is_win').to_i == 1 + pull = VIM::evaluate('s:update.pull').to_i == 1 + base = VIM::evaluate('g:plug_home') + all = VIM::evaluate('s:update.todo') + limit = VIM::evaluate('get(g:, "plug_timeout", 60)') + tries = VIM::evaluate('get(g:, "plug_retries", 2)') + 1 + nthr = VIM::evaluate('s:update.threads').to_i + maxy = VIM::evaluate('winheight(".")').to_i + vim7 = VIM::evaluate('v:version').to_i <= 703 && RUBY_PLATFORM =~ /darwin/ + cd = iswin ? 'cd /d' : 'cd' + tot = VIM::evaluate('len(s:update.todo)') || 0 + bar = '' + skip = 'Already installed' + mtx = Mutex.new + take1 = proc { mtx.synchronize { running && all.shift } } + logh = proc { + cnt = bar.length + $curbuf[1] = "#{pull ? 'Updating' : 'Installing'} plugins (#{cnt}/#{tot})" + $curbuf[2] = '[' + bar.ljust(tot) + ']' + VIM::command('normal! 2G') + VIM::command('redraw') + } + where = proc { |name| (1..($curbuf.length)).find { |l| $curbuf[l] =~ /^[-+x*] #{name}:/ } } + log = proc { |name, result, type| + mtx.synchronize do + ing = ![true, false].include?(type) + bar += type ? '=' : 'x' unless ing + b = case type + when :install then '+' when :update then '*' + when true, nil then '-' else + VIM::command("call add(s:update.errors, '#{name}')") + 'x' + end + result = + if type || type.nil? + ["#{b} #{name}: #{result.lines.to_a.last || 'OK'}"] + elsif result =~ /^Interrupted|^Timeout/ + ["#{b} #{name}: #{result}"] + else + ["#{b} #{name}"] + result.lines.map { |l| " " << l } + end + if lnum = where.call(name) + $curbuf.delete lnum + lnum = 4 if ing && lnum > maxy + end + result.each_with_index do |line, offset| + $curbuf.append((lnum || 4) - 1 + offset, line.gsub(/\e\[./, '').chomp) + end + logh.call + end + } + bt = proc { |cmd, name, type, cleanup| + tried = timeout = 0 + begin + tried += 1 + timeout += limit + fd = nil + data = '' + if iswin + Timeout::timeout(timeout) do + tmp = VIM::evaluate('tempname()') + system("(#{cmd}) > #{tmp}") + data = File.read(tmp).chomp + File.unlink tmp rescue nil + end + else + fd = IO.popen(cmd).extend(PlugStream) + first_line = true + log_prob = 1.0 / nthr + while line = Timeout::timeout(timeout) { fd.get_line } + data << line + log.call name, line.chomp, type if name && (first_line || rand < log_prob) + first_line = false + end + fd.close + end + [$? == 0, data.chomp] + rescue Timeout::Error, Interrupt => e + if fd && !fd.closed? + killall fd.pid + fd.close + end + cleanup.call if cleanup + if e.is_a?(Timeout::Error) && tried < tries + 3.downto(1) do |countdown| + s = countdown > 1 ? 's' : '' + log.call name, "Timeout. Will retry in #{countdown} second#{s} ...", type + sleep 1 + end + log.call name, 'Retrying ...', type + retry + end + [false, e.is_a?(Interrupt) ? "Interrupted!" : "Timeout!"] + end + } + main = Thread.current + threads = [] + watcher = Thread.new { + if vim7 + while VIM::evaluate('getchar(1)') + sleep 0.1 + end + else + require 'io/console' # >= Ruby 1.9 + nil until IO.console.getch == 3.chr + end + mtx.synchronize do + running = false + threads.each { |t| t.raise Interrupt } unless vim7 + end + threads.each { |t| t.join rescue nil } + main.kill + } + refresh = Thread.new { + while true + mtx.synchronize do + break unless running + VIM::command('noautocmd normal! a') + end + sleep 0.2 + end + } if VIM::evaluate('s:mac_gui') == 1 + + clone_opt = VIM::evaluate('s:clone_opt').join(' ') + progress = VIM::evaluate('s:progress_opt(1)') + nthr.times do + mtx.synchronize do + threads << Thread.new { + while pair = take1.call + name = pair.first + dir, uri, tag = pair.last.values_at *%w[dir uri tag] + exists = File.directory? dir + ok, result = + if exists + chdir = "#{cd} #{iswin ? dir : esc(dir)}" + ret, data = bt.call "#{chdir} && git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url", nil, nil, nil + current_uri = data.lines.to_a.last + if !ret + if data =~ /^Interrupted|^Timeout/ + [false, data] + else + [false, [data.chomp, "PlugClean required."].join($/)] + end + elsif !compare_git_uri(current_uri, uri) + [false, ["Invalid URI: #{current_uri}", + "Expected: #{uri}", + "PlugClean required."].join($/)] + else + if pull + log.call name, 'Updating ...', :update + fetch_opt = (tag && File.exist?(File.join(dir, '.git/shallow'))) ? '--depth 99999999' : '' + bt.call "#{chdir} && git fetch #{fetch_opt} #{progress} 2>&1", name, :update, nil + else + [true, skip] + end + end + else + d = esc dir.sub(%r{[\\/]+$}, '') + log.call name, 'Installing ...', :install + bt.call "git clone #{clone_opt unless tag} #{progress} #{uri} #{d} 2>&1", name, :install, proc { + FileUtils.rm_rf dir + } + end + mtx.synchronize { VIM::command("let s:update.new['#{name}'] = 1") } if !exists && ok + log.call name, result, ok + end + } if running + end + end + threads.each { |t| t.join rescue nil } + logh.call + refresh.kill if refresh + watcher.kill +EOF +endfunction + +function! s:shellesc_cmd(arg, script) + let escaped = substitute('"'.a:arg.'"', '[&|<>()@^!"]', '^&', 'g') + return substitute(escaped, '%', (a:script ? '%' : '^') . '&', 'g') +endfunction + +function! s:shellesc_ps1(arg) + return "'".substitute(escape(a:arg, '\"'), "'", "''", 'g')."'" +endfunction + +function! s:shellesc_sh(arg) + return "'".substitute(a:arg, "'", "'\\\\''", 'g')."'" +endfunction + +" Escape the shell argument based on the shell. +" Vim and Neovim's shellescape() are insufficient. +" 1. shellslash determines whether to use single/double quotes. +" Double-quote escaping is fragile for cmd.exe. +" 2. It does not work for powershell. +" 3. It does not work for *sh shells if the command is executed +" via cmd.exe (ie. cmd.exe /c sh -c command command_args) +" 4. It does not support batchfile syntax. +" +" Accepts an optional dictionary with the following keys: +" - shell: same as Vim/Neovim 'shell' option. +" If unset, fallback to 'cmd.exe' on Windows or 'sh'. +" - script: If truthy and shell is cmd.exe, escape for batchfile syntax. +function! plug#shellescape(arg, ...) + if a:arg =~# '^[A-Za-z0-9_/:.-]\+$' + return a:arg + endif + let opts = a:0 > 0 && type(a:1) == s:TYPE.dict ? a:1 : {} + let shell = get(opts, 'shell', s:is_win ? 'cmd.exe' : 'sh') + let script = get(opts, 'script', 1) + if shell =~# 'cmd\(\.exe\)\?$' + return s:shellesc_cmd(a:arg, script) + elseif shell =~# 'powershell\(\.exe\)\?$' || shell =~# 'pwsh$' + return s:shellesc_ps1(a:arg) + endif + return s:shellesc_sh(a:arg) +endfunction + +function! s:glob_dir(path) + return map(filter(s:glob(a:path, '**'), 'isdirectory(v:val)'), 's:dirpath(v:val)') +endfunction + +function! s:progress_bar(line, bar, total) + call setline(a:line, '[' . s:lpad(a:bar, a:total) . ']') +endfunction + +function! s:compare_git_uri(a, b) + " See `git help clone' + " https:// [user@] github.com[:port] / junegunn/vim-plug [.git] + " [git@] github.com[:port] : junegunn/vim-plug [.git] + " file:// / junegunn/vim-plug [/] + " / junegunn/vim-plug [/] + let pat = '^\%(\w\+://\)\='.'\%([^@/]*@\)\='.'\([^:/]*\%(:[0-9]*\)\=\)'.'[:/]'.'\(.\{-}\)'.'\%(\.git\)\=/\?$' + let ma = matchlist(a:a, pat) + let mb = matchlist(a:b, pat) + return ma[1:2] ==# mb[1:2] +endfunction + +function! s:format_message(bullet, name, message) + if a:bullet != 'x' + return [printf('%s %s: %s', a:bullet, a:name, s:lastline(a:message))] + else + let lines = map(s:lines(a:message), '" ".v:val') + return extend([printf('x %s:', a:name)], lines) + endif +endfunction + +function! s:with_cd(cmd, dir, ...) + let script = a:0 > 0 ? a:1 : 1 + return printf('cd%s %s && %s', s:is_win ? ' /d' : '', plug#shellescape(a:dir, {'script': script}), a:cmd) +endfunction + +function! s:system(cmd, ...) + let batchfile = '' + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + if type(a:cmd) == s:TYPE.list + " Neovim's system() supports list argument to bypass the shell + " but it cannot set the working directory for the command. + " Assume that the command does not rely on the shell. + if has('nvim') && a:0 == 0 + return system(a:cmd) + endif + let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"shell": &shell, "script": 0})')) + if &shell =~# 'powershell\(\.exe\)\?$' + let cmd = '& ' . cmd + endif + else + let cmd = a:cmd + endif + if a:0 > 0 + let cmd = s:with_cd(cmd, a:1, type(a:cmd) != s:TYPE.list) + endif + if s:is_win && type(a:cmd) != s:TYPE.list + let [batchfile, cmd] = s:batchfile(cmd) + endif + return system(cmd) + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win && filereadable(batchfile) + call delete(batchfile) + endif + endtry +endfunction + +function! s:system_chomp(...) + let ret = call('s:system', a:000) + return v:shell_error ? '' : substitute(ret, '\n$', '', '') +endfunction + +function! s:git_validate(spec, check_branch) + let err = '' + if isdirectory(a:spec.dir) + let result = [s:git_local_branch(a:spec.dir), s:git_origin_url(a:spec.dir)] + let remote = result[-1] + if empty(remote) + let err = join([remote, 'PlugClean required.'], "\n") + elseif !s:compare_git_uri(remote, a:spec.uri) + let err = join(['Invalid URI: '.remote, + \ 'Expected: '.a:spec.uri, + \ 'PlugClean required.'], "\n") + elseif a:check_branch && has_key(a:spec, 'commit') + let sha = s:git_revision(a:spec.dir) + if empty(sha) + let err = join(add(result, 'PlugClean required.'), "\n") + elseif !s:hash_match(sha, a:spec.commit) + let err = join([printf('Invalid HEAD (expected: %s, actual: %s)', + \ a:spec.commit[:6], sha[:6]), + \ 'PlugUpdate required.'], "\n") + endif + elseif a:check_branch + let current_branch = result[0] + " Check tag + let origin_branch = s:git_origin_branch(a:spec) + if has_key(a:spec, 'tag') + let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir) + if a:spec.tag !=# tag && a:spec.tag !~ '\*' + let err = printf('Invalid tag: %s (expected: %s). Try PlugUpdate.', + \ (empty(tag) ? 'N/A' : tag), a:spec.tag) + endif + " Check branch + elseif origin_branch !=# current_branch + let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.', + \ current_branch, origin_branch) + endif + if empty(err) + let [ahead, behind] = split(s:lastline(s:system([ + \ 'git', 'rev-list', '--count', '--left-right', + \ printf('HEAD...origin/%s', origin_branch) + \ ], a:spec.dir)), '\t') + if !v:shell_error && ahead + if behind + " Only mention PlugClean if diverged, otherwise it's likely to be + " pushable (and probably not that messed up). + let err = printf( + \ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n" + \ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', origin_branch, ahead, behind) + else + let err = printf("Ahead of origin/%s by %d commit(s).\n" + \ .'Cannot update until local changes are pushed.', + \ origin_branch, ahead) + endif + endif + endif + endif + else + let err = 'Not found' + endif + return [err, err =~# 'PlugClean'] +endfunction + +function! s:rm_rf(dir) + if isdirectory(a:dir) + return s:system(s:is_win + \ ? 'rmdir /S /Q '.plug#shellescape(a:dir) + \ : ['rm', '-rf', a:dir]) + endif +endfunction + +function! s:clean(force) + call s:prepare() + call append(0, 'Searching for invalid plugins in '.g:plug_home) + call append(1, '') + + " List of valid directories + let dirs = [] + let errs = {} + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + if !s:is_managed(name) + call add(dirs, spec.dir) + else + let [err, clean] = s:git_validate(spec, 1) + if clean + let errs[spec.dir] = s:lines(err)[0] + else + call add(dirs, spec.dir) + endif + endif + let cnt += 1 + call s:progress_bar(2, repeat('=', cnt), total) + normal! 2G + redraw + endfor + + let allowed = {} + for dir in dirs + let allowed[s:dirpath(s:plug_fnamemodify(dir, ':h:h'))] = 1 + let allowed[dir] = 1 + for child in s:glob_dir(dir) + let allowed[child] = 1 + endfor + endfor + + let todo = [] + let found = sort(s:glob_dir(g:plug_home)) + while !empty(found) + let f = remove(found, 0) + if !has_key(allowed, f) && isdirectory(f) + call add(todo, f) + call append(line('$'), '- ' . f) + if has_key(errs, f) + call append(line('$'), ' ' . errs[f]) + endif + let found = filter(found, 'stridx(v:val, f) != 0') + end + endwhile + + 4 + redraw + if empty(todo) + call append(line('$'), 'Already clean.') + else + let s:clean_count = 0 + call append(3, ['Directories to delete:', '']) + redraw! + if a:force || s:ask_no_interrupt('Delete all directories?') + call s:delete([6, line('$')], 1) + else + call setline(4, 'Cancelled.') + nnoremap d :set opfunc=delete_opg@ + nmap dd d_ + xnoremap d :call delete_op(visualmode(), 1) + echo 'Delete the lines (d{motion}) to delete the corresponding directories' + endif + endif + 4 + setlocal nomodifiable +endfunction + +function! s:delete_op(type, ...) + call s:delete(a:0 ? [line("'<"), line("'>")] : [line("'["), line("']")], 0) +endfunction + +function! s:delete(range, force) + let [l1, l2] = a:range + let force = a:force + let err_count = 0 + while l1 <= l2 + let line = getline(l1) + if line =~ '^- ' && isdirectory(line[2:]) + execute l1 + redraw! + let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1) + let force = force || answer > 1 + if answer + let err = s:rm_rf(line[2:]) + setlocal modifiable + if empty(err) + call setline(l1, '~'.line[1:]) + let s:clean_count += 1 + else + delete _ + call append(l1 - 1, s:format_message('x', line[1:], err)) + let l2 += len(s:lines(err)) + let err_count += 1 + endif + let msg = printf('Removed %d directories.', s:clean_count) + if err_count > 0 + let msg .= printf(' Failed to remove %d directories.', err_count) + endif + call setline(4, msg) + setlocal nomodifiable + endif + endif + let l1 += 1 + endwhile +endfunction + +function! s:upgrade() + echo 'Downloading the latest version of vim-plug' + redraw + let tmp = s:plug_tempname() + let new = tmp . '/plug.vim' + + try + let out = s:system(['git', 'clone', '--depth', '1', s:plug_src, tmp]) + if v:shell_error + return s:err('Error upgrading vim-plug: '. out) + endif + + if readfile(s:me) ==# readfile(new) + echo 'vim-plug is already up-to-date' + return 0 + else + call rename(s:me, s:me . '.old') + call rename(new, s:me) + unlet g:loaded_plug + echo 'vim-plug has been upgraded' + return 1 + endif + finally + silent! call s:rm_rf(tmp) + endtry +endfunction + +function! s:upgrade_specs() + for spec in values(g:plugs) + let spec.frozen = get(spec, 'frozen', 0) + endfor +endfunction + +function! s:status() + call s:prepare() + call append(0, 'Checking plugins') + call append(1, '') + + let ecnt = 0 + let unloaded = 0 + let [cnt, total] = [0, len(g:plugs)] + for [name, spec] in items(g:plugs) + let is_dir = isdirectory(spec.dir) + if has_key(spec, 'uri') + if is_dir + let [err, _] = s:git_validate(spec, 1) + let [valid, msg] = [empty(err), empty(err) ? 'OK' : err] + else + let [valid, msg] = [0, 'Not found. Try PlugInstall.'] + endif + else + if is_dir + let [valid, msg] = [1, 'OK'] + else + let [valid, msg] = [0, 'Not found.'] + endif + endif + let cnt += 1 + let ecnt += !valid + " `s:loaded` entry can be missing if PlugUpgraded + if is_dir && get(s:loaded, name, -1) == 0 + let unloaded = 1 + let msg .= ' (not loaded)' + endif + call s:progress_bar(2, repeat('=', cnt), total) + call append(3, s:format_message(valid ? '-' : 'x', name, msg)) + normal! 2G + redraw + endfor + call setline(1, 'Finished. '.ecnt.' error(s).') + normal! gg + setlocal nomodifiable + if unloaded + echo "Press 'L' on each line to load plugin, or 'U' to update" + nnoremap L :call status_load(line('.')) + xnoremap L :call status_load(line('.')) + end +endfunction + +function! s:extract_name(str, prefix, suffix) + return matchstr(a:str, '^'.a:prefix.' \zs[^:]\+\ze:.*'.a:suffix.'$') +endfunction + +function! s:status_load(lnum) + let line = getline(a:lnum) + let name = s:extract_name(line, '-', '(not loaded)') + if !empty(name) + call plug#load(name) + setlocal modifiable + call setline(a:lnum, substitute(line, ' (not loaded)$', '', '')) + setlocal nomodifiable + endif +endfunction + +function! s:status_update() range + let lines = getline(a:firstline, a:lastline) + let names = filter(map(lines, 's:extract_name(v:val, "[x-]", "")'), '!empty(v:val)') + if !empty(names) + echo + execute 'PlugUpdate' join(names) + endif +endfunction + +function! s:is_preview_window_open() + silent! wincmd P + if &previewwindow + wincmd p + return 1 + endif +endfunction + +function! s:find_name(lnum) + for lnum in reverse(range(1, a:lnum)) + let line = getline(lnum) + if empty(line) + return '' + endif + let name = s:extract_name(line, '-', '') + if !empty(name) + return name + endif + endfor + return '' +endfunction + +function! s:preview_commit() + if b:plug_preview < 0 + let b:plug_preview = !s:is_preview_window_open() + endif + + let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}') + if empty(sha) + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir) + return + endif + + if exists('g:plug_pwindow') && !s:is_preview_window_open() + execute g:plug_pwindow + execute 'e' sha + else + execute 'pedit' sha + wincmd P + endif + setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable + let batchfile = '' + try + let [sh, shellcmdflag, shrd] = s:chsh(1) + let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha + if s:is_win + let [batchfile, cmd] = s:batchfile(cmd) + endif + execute 'silent %!' cmd + finally + let [&shell, &shellcmdflag, &shellredir] = [sh, shellcmdflag, shrd] + if s:is_win && filereadable(batchfile) + call delete(batchfile) + endif + endtry + setlocal nomodifiable + nnoremap q :q + wincmd p +endfunction + +function! s:section(flags) + call search('\(^[x-] \)\@<=[^:]\+:', a:flags) +endfunction + +function! s:format_git_log(line) + let indent = ' ' + let tokens = split(a:line, nr2char(1)) + if len(tokens) != 5 + return indent.substitute(a:line, '\s*$', '', '') + endif + let [graph, sha, refs, subject, date] = tokens + let tag = matchstr(refs, 'tag: [^,)]\+') + let tag = empty(tag) ? ' ' : ' ('.tag.') ' + return printf('%s%s%s%s%s (%s)', indent, graph, sha, tag, subject, date) +endfunction + +function! s:append_ul(lnum, text) + call append(a:lnum, ['', a:text, repeat('-', len(a:text))]) +endfunction + +function! s:diff() + call s:prepare() + call append(0, ['Collecting changes ...', '']) + let cnts = [0, 0] + let bar = '' + let total = filter(copy(g:plugs), 's:is_managed(v:key) && isdirectory(v:val.dir)') + call s:progress_bar(2, bar, len(total)) + for origin in [1, 0] + let plugs = reverse(sort(items(filter(copy(total), (origin ? '' : '!').'(has_key(v:val, "commit") || has_key(v:val, "tag"))')))) + if empty(plugs) + continue + endif + call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:') + for [k, v] in plugs + let branch = s:git_origin_branch(v) + if len(branch) + let range = origin ? '..origin/'.branch : 'HEAD@{1}..' + let cmd = ['git', 'log', '--graph', '--color=never'] + if s:git_version_requirement(2, 10, 0) + call add(cmd, '--no-show-signature') + endif + call extend(cmd, ['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range]) + if has_key(v, 'rtp') + call extend(cmd, ['--', v.rtp]) + endif + let diff = s:system_chomp(cmd, v.dir) + if !empty(diff) + let ref = has_key(v, 'tag') ? (' (tag: '.v.tag.')') : has_key(v, 'commit') ? (' '.v.commit) : '' + call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)'))) + let cnts[origin] += 1 + endif + endif + let bar .= '=' + call s:progress_bar(2, bar, len(total)) + normal! 2G + redraw + endfor + if !cnts[origin] + call append(5, ['', 'N/A']) + endif + endfor + call setline(1, printf('%d plugin(s) updated.', cnts[0]) + \ . (cnts[1] ? printf(' %d plugin(s) have pending updates.', cnts[1]) : '')) + + if cnts[0] || cnts[1] + nnoremap (plug-preview) :silent! call preview_commit() + if empty(maparg("\", 'n')) + nmap (plug-preview) + endif + if empty(maparg('o', 'n')) + nmap o (plug-preview) + endif + endif + if cnts[0] + nnoremap X :call revert() + echo "Press 'X' on each block to revert the update" + endif + normal! gg + setlocal nomodifiable +endfunction + +function! s:revert() + if search('^Pending updates', 'bnW') + return + endif + + let name = s:find_name(line('.')) + if empty(name) || !has_key(g:plugs, name) || + \ input(printf('Revert the update of %s? (y/N) ', name)) !~? '^y' + return + endif + + call s:system('git reset --hard HEAD@{1} && git checkout '.plug#shellescape(g:plugs[name].branch).' --', g:plugs[name].dir) + setlocal modifiable + normal! "_dap + setlocal nomodifiable + echo 'Reverted' +endfunction + +function! s:snapshot(force, ...) abort + call s:prepare() + setf vim + call append(0, ['" Generated by vim-plug', + \ '" '.strftime("%c"), + \ '" :source this file in vim to restore the snapshot', + \ '" or execute: vim -S snapshot.vim', + \ '', '', 'PlugUpdate!']) + 1 + let anchor = line('$') - 3 + let names = sort(keys(filter(copy(g:plugs), + \'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)'))) + for name in reverse(names) + let sha = s:git_revision(g:plugs[name].dir) + if !empty(sha) + call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha)) + redraw + endif + endfor + + if a:0 > 0 + let fn = s:plug_expand(a:1) + if filereadable(fn) && !(a:force || s:ask(a:1.' already exists. Overwrite?')) + return + endif + call writefile(getline(1, '$'), fn) + echo 'Saved as '.a:1 + silent execute 'e' s:esc(fn) + setf vim + endif +endfunction + +function! s:split_rtp() + return split(&rtp, '\\\@ :NERDTreeToggle +nmap :wrap +vmap NERDCommenterToggle +nmap NERDCommenterToggle +" Spellchecking and switch to spanish +map :setlocal spell! spelllang=es +map :set spelllang=es +" Turn on Goyo for readibility and writing +nmap :Goyo + +inoremap pumvisible() ? "\" : "\" +inoremap pumvisible() ? "\" : "\" +" Map control - backspace to delete work in insert mode +inoremap dB +inoremap db + +vnoremap "+y +map "+P + +"Markdown configuration +augroup MarkdownConfiguration + autocmd BufNewFile,BufRead *.md set linebreak breakindent wrap + autocmd BufNewFile,BufRead *.md nnoremap j gj + autocmd BufNewFile,BufRead *.md nnoremap k gk + "autocmd BufNewFile,BufRead *.md Goyo +augroup END + + +let g:lightline = { + \ 'colorscheme': 'nord', + \ } +nmap gh :diffget //3 +nmap gu :diffget //2 +nmap gs :G diff --git a/stow_home/nvim/.config/nvim/spell/en.utf-8.add b/stow_home/nvim/.config/nvim/spell/en.utf-8.add new file mode 100644 index 0000000..c04c131 --- /dev/null +++ b/stow_home/nvim/.config/nvim/spell/en.utf-8.add @@ -0,0 +1,2 @@ +#log +blog diff --git a/stow_home/nvim/.config/nvim/spell/en.utf-8.add.spl b/stow_home/nvim/.config/nvim/spell/en.utf-8.add.spl new file mode 100644 index 0000000..ec89f96 Binary files /dev/null and b/stow_home/nvim/.config/nvim/spell/en.utf-8.add.spl differ diff --git a/stow_home/nvim/.config/nvim/spell/es.utf-8.spl b/stow_home/nvim/.config/nvim/spell/es.utf-8.spl new file mode 100644 index 0000000..62d848d Binary files /dev/null and b/stow_home/nvim/.config/nvim/spell/es.utf-8.spl differ diff --git a/stow_home/nvim/.config/nvim/spell/es.utf-8.sug b/stow_home/nvim/.config/nvim/spell/es.utf-8.sug new file mode 100644 index 0000000..9064321 Binary files /dev/null and b/stow_home/nvim/.config/nvim/spell/es.utf-8.sug differ diff --git a/stow_home/nvim/.config/nvim/vim-plug/plugins.vim b/stow_home/nvim/.config/nvim/vim-plug/plugins.vim new file mode 100644 index 0000000..93d638d --- /dev/null +++ b/stow_home/nvim/.config/nvim/vim-plug/plugins.vim @@ -0,0 +1,43 @@ +" auto-install vim-plug +if empty(glob('~/.config/nvim/autoload/plug.vim')) + silent !curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs + \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + "autocmd VimEnter * PlugInstall + "autocmd VimEnter * PlugInstall | source $MYVIMRC +endif + +call plug#begin('~/.config/nvim/autoload/plugged') + + " Better Syntax Support + Plug 'sheerun/vim-polyglot' + " File Explorer + Plug 'scrooloose/NERDTree' + " Auto pairs for '(' '[' '{' + Plug 'jiangmiao/auto-pairs' + Plug 'rwxrob/vim-pandoc-syntax-simple' + Plug 'arcticicestudio/nord-vim' + "Plug 'itchyny/lightline.vim' + "Plug 'vifm/vifm.vim' + Plug 'tpope/vim-fugitive' + "Plug 'vim-scripts/AutoComplPop' + Plug 'junegunn/goyo.vim' + Plug 'junegunn/limelight.vim' + Plug 'godlygeek/tabular' + Plug 'joshdick/onedark.vim' + Plug 'romgrk/doom-one.vim' + Plug 'jremmen/vim-ripgrep' + Plug 'kien/ctrlp.vim' + Plug 'dhruvasagar/vim-table-mode' + "Plug 'ycm-core/YouCompleteMe' + Plug 'neoclide/coc.nvim', {'branch': 'release'} + + Plug 'gruvbox-community/gruvbox' + Plug 'sickill/vim-monokai' + Plug 'habamax/vim-godot' + Plug 'scrooloose/nerdcommenter' + "Starting to learn go + Plug 'fatih/vim-go' + Plug 'masukomi/vim-markdown-folding' + Plug 'vim-airline/vim-airline' + Plug 'vim-airline/vim-airline-themes' +call plug#end() diff --git a/stow_home/picom/.config/picom/picom.conf b/stow_home/picom/.config/picom/picom.conf new file mode 100644 index 0000000..86b1bd8 --- /dev/null +++ b/stow_home/picom/.config/picom/picom.conf @@ -0,0 +1,521 @@ +################################# +# Animations # +################################# +# requires https://github.com/jonaburg/picom +# (These are also the default values) + transition-length = 400 + transition-pow-x = 0.1 + transition-pow-y = 0.1 + transition-pow-w = 0.1 + transition-pow-h = 0.1 + size-transition = true + + +################################# +# Corners # +################################# +# requires: https://github.com/sdhand/compton or https://github.com/jonaburg/picom +corner-radius = 0; +rounded-corners-exclude = [ + #"window_type = 'normal'", + "class_g = 'awesome'", + "class_g = 'trayer'", + "class_g = 'URxvt'", + "class_g = 'Bar'", + "class_g = 'Panel'", + "class_g = 'XTerm'", + "class_g = 'spectrwm'", + "class_g = 'Polybar'", + "class_g = 'code-oss'", + "class_g = 'Thunderbird'" + #"class_g = 'TelegramDesktop'", + #"class_g = 'Alacritty'", + #"class_g = 'firefox'", +]; +round-borders = 0; +round-borders-exclude = [ + #"class_g = 'TelegramDesktop'", +]; + +################################# +# Shadows # +################################# + + +# Enabled client-side shadows on windows. Note desktop windows +# (windows with '_NET_WM_WINDOW_TYPE_DESKTOP') never get shadow, +# unless explicitly requested using the wintypes option. +# +shadow = false +## shadow = true; + +# The blur radius for shadows, in pixels. (defaults to 12) +# shadow-radius = 12 +shadow-radius = 12; + +# The opacity of shadows. (0.0 - 1.0, defaults to 0.75) +# shadow-opacity = .75 + +# The left offset for shadows, in pixels. (defaults to -15) +# shadow-offset-x = -15 +shadow-offset-x = -5; + +# The top offset for shadows, in pixels. (defaults to -15) +# shadow-offset-y = -15 +shadow-offset-y = -5; + +# Avoid drawing shadows on dock/panel windows. This option is deprecated, +# you should use the *wintypes* option in your config file instead. +# +# no-dock-shadow = false + +# Don't draw shadows on drag-and-drop windows. This option is deprecated, +# you should use the *wintypes* option in your config file instead. +# +# no-dnd-shadow = false + +# Red color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-red = 0 + +# Green color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-green = 0 + +# Blue color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-blue = 0 + +# Do not paint shadows on shaped windows. Note shaped windows +# here means windows setting its shape through X Shape extension. +# Those using ARGB background is beyond our control. +# Deprecated, use +# shadow-exclude = 'bounding_shaped' +# or +# shadow-exclude = 'bounding_shaped && !rounded_corners' +# instead. +# +# shadow-ignore-shaped = '' + +# Specify a list of conditions of windows that should have no shadow. +# +# examples: +# shadow-exclude = "n:e:Notification"; +# +shadow-exclude = [ + "name = 'Notification'", + "class_g = 'Conky'", + "class_g ?= 'Notify-osd'", + "class_g = 'Cairo-clock'", + "class_g = 'obs'", + "class_g = 'trayer'", + "_GTK_FRAME_EXTENTS@:c" +]; +# Specify a X geometry that describes the region in which shadow should not +# be painted in, such as a dock window region. Use +# shadow-exclude-reg = "x10+0+0" +# for example, if the 10 pixels on the bottom of the screen should not have shadows painted on. +# +# shadow-exclude-reg = "" + +# Crop shadow of a window fully on a particular Xinerama screen to the screen. +# xinerama-shadow-crop = false + + +################################# +# Fading # +################################# + + +# Fade windows in/out when opening/closing and when opacity changes, +# unless no-fading-openclose is used. +fading = true +#fading = true; + +# Opacity change between steps while fading in. (0.01 - 1.0, defaults to 0.028) +# fade-in-step = 0.028 +fade-in-step = 0.03; + +# Opacity change between steps while fading out. (0.01 - 1.0, defaults to 0.03) +# fade-out-step = 0.03 +fade-out-step = 0.03; + +# The time between steps in fade step, in milliseconds. (> 0, defaults to 10) +fade-delta = 4 + +# Specify a list of conditions of windows that should not be faded. +# don't need this, we disable fading for all normal windows with wintypes: {} +fade-exclude = [ + "class_g = 'slop'", # maim +] + +# Do not fade on window open/close. +# no-fading-openclose = false + +# Do not fade destroyed ARGB windows with WM frame. Workaround of bugs in Openbox, Fluxbox, etc. +# no-fading-destroyed-argb = false + + +################################# +# Transparency / Opacity # +################################# + + +# Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0) +# inactive-opacity = 1 +inactive-opacity = 0.7; + +# Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default) +# frame-opacity = 1.0 +#frame-opacity = 0.7; + +# Default opacity for dropdown menus and popup menus. (0.0 - 1.0, defaults to 1.0) +# menu-opacity = 1.0 +# menu-opacity is depreciated use dropdown-menu and popup-menu instead. + +#If using these 2 below change their values in line 510 & 511 aswell +popup_menu = { opacity = 0.8; } +dropdown_menu = { opacity = 0.8; } + + +# Let inactive opacity set by -i override the '_NET_WM_OPACITY' values of windows. +# inactive-opacity-override = true +inactive-opacity-override = false; + +# Default opacity for active windows. (0.0 - 1.0, defaults to 1.0) +active-opacity = 1.0; + +# Dim inactive windows. (0.0 - 1.0, defaults to 0.0) +# inactive-dim = 0.0 + +# Specify a list of conditions of windows that should always be considered focused. +# focus-exclude = [] +focus-exclude = [ + "class_g = 'Cairo-clock'", + "class_g = 'Bar'", # lemonbar + "class_g = 'slop'" # maim +]; + +# Use fixed inactive dim value, instead of adjusting according to window opacity. +# inactive-dim-fixed = 1.0 + +# Specify a list of opacity rules, in the format `PERCENT:PATTERN`, +# like `50:name *= "Firefox"`. picom-trans is recommended over this. +# Note we don't make any guarantee about possible conflicts with other +# programs that set '_NET_WM_WINDOW_OPACITY' on frame or client windows. +# example: +# opacity-rule = [ "80:class_g = 'URxvt'" ]; +# +# opacity-rule = [] +opacity-rule = [ + "100:class_g = 'Godot'", + "100:class_g = 'Emacs'", + "80:class_g = 'Bar'", # lemonbar + "100:class_g = 'libreoffice-writer'", + "100:class_g = 'slop'", # maim + "100:class_g = 'XTerm'", + "100:class_g = 'URxvt'", + "100:class_g = 'kitty'", + "100:class_g = 'Alacritty'", + "80:class_g = 'Polybar'", + "100:class_g = 'code-oss'", + "100:class_g = 'Meld'", + "90:class_g = 'Joplin'", + "100:class_g = 'firefox'", + "100:class_g = 'mpv'", + "100:class_g = 'vlc'", + "100:class_g = 'Thunderbird'", + "80:class_g = 'URxvt'", + "100:class_g = 'Firefox'", + "100:class_g = 'Gimp-2.10'", + "100:class_g = 'discord'", + "100:class_g = 'Brave-browser'", + "100:class_g = 'obs'", + "100:class_g = 'TelegramDesktop'", + "100:class_g = 'trayer'", +]; + + +################################# +# Background-Blurring # +################################# + + +# Parameters for background blurring, see the *BLUR* section for more information. +# blur-method = dual-kawase +# blur-size = 7 +# +# blur-deviation = false + +# Blur background of semi-transparent / ARGB windows. +# Bad in performance, with driver-dependent behavior. +# The name of the switch may change without prior notifications. +# +# blur-background = true; + +# Blur background of windows when the window frame is not opaque. +# Implies: +# blur-background +# Bad in performance, with driver-dependent behavior. The name may change. +# +# blur-background-frame = false; + + +# Use fixed blur strength rather than adjusting according to window opacity. +# blur-background-fixed = false; + + +# Specify the blur convolution kernel, with the following format: +# example: +# blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1"; +# +# blur-kern = '' +# blur-kern = "3x3box"; + +blur: { + # requires: https://github.com/ibhagwan/picom + method = "kawase"; + #method = "kernel"; + strength = 5; + # deviation = 1.0; + # kernel = "11x11gaussian"; + background = false; + background-frame = false; + background-fixed = false; + kern = "3x3box"; +} + +# Exclude conditions for background blur. +blur-background-exclude = [ + #"window_type = 'dock'", + #"window_type = 'desktop'", + #"class_g = 'URxvt'", + # + # prevents picom from blurring the background + # when taking selection screenshot with `main` + # https://github.com/naelstrof/maim/issues/130 + "class_g = 'slop'", + "_GTK_FRAME_EXTENTS@:c" +]; + + +################################# +# General Settings # +################################# + +# Daemonize process. Fork to background after initialization. Causes issues with certain (badly-written) drivers. +# daemon = false + +# Specify the backend to use: `xrender`, `glx`, or `xr_glx_hybrid`. +# `xrender` is the default one. +# +experimental-backends = true; +backend = "glx"; +#backend = "xrender"; + + +# Enable/disable VSync. +# vsync = false +vsync = true + +# Enable remote control via D-Bus. See the *D-BUS API* section below for more details. +# dbus = false + +# Try to detect WM windows (a non-override-redirect window with no +# child that has 'WM_STATE') and mark them as active. +# +# mark-wmwin-focused = false +mark-wmwin-focused = true; + +# Mark override-redirect windows that doesn't have a child window with 'WM_STATE' focused. +# mark-ovredir-focused = false +mark-ovredir-focused = true; + +# Try to detect windows with rounded corners and don't consider them +# shaped windows. The accuracy is not very high, unfortunately. +# +# detect-rounded-corners = false +detect-rounded-corners = true; + +# Detect '_NET_WM_OPACITY' on client windows, useful for window managers +# not passing '_NET_WM_OPACITY' of client windows to frame windows. +# +# detect-client-opacity = false +detect-client-opacity = true; + +# Specify refresh rate of the screen. If not specified or 0, picom will +# try detecting this with X RandR extension. +# +# refresh-rate = 60 +refresh-rate = 0 + +# Limit picom to repaint at most once every 1 / 'refresh_rate' second to +# boost performance. This should not be used with +# vsync drm/opengl/opengl-oml +# as they essentially does sw-opti's job already, +# unless you wish to specify a lower refresh rate than the actual value. +# +# sw-opti = + +# Use EWMH '_NET_ACTIVE_WINDOW' to determine currently focused window, +# rather than listening to 'FocusIn'/'FocusOut' event. Might have more accuracy, +# provided that the WM supports it. +# +# use-ewmh-active-win = false + +# Unredirect all windows if a full-screen opaque window is detected, +# to maximize performance for full-screen windows. Known to cause flickering +# when redirecting/unredirecting windows. paint-on-overlay may make the flickering less obvious. +# +# unredir-if-possible = false + +# Delay before unredirecting the window, in milliseconds. Defaults to 0. +# unredir-if-possible-delay = 0 + +# Conditions of windows that shouldn't be considered full-screen for unredirecting screen. +# unredir-if-possible-exclude = [] + +# Use 'WM_TRANSIENT_FOR' to group windows, and consider windows +# in the same group focused at the same time. +# +# detect-transient = false +detect-transient = true + +# Use 'WM_CLIENT_LEADER' to group windows, and consider windows in the same +# group focused at the same time. 'WM_TRANSIENT_FOR' has higher priority if +# detect-transient is enabled, too. +# +# detect-client-leader = false +detect-client-leader = true + +# Resize damaged region by a specific number of pixels. +# A positive value enlarges it while a negative one shrinks it. +# If the value is positive, those additional pixels will not be actually painted +# to screen, only used in blur calculation, and such. (Due to technical limitations, +# with use-damage, those pixels will still be incorrectly painted to screen.) +# Primarily used to fix the line corruption issues of blur, +# in which case you should use the blur radius value here +# (e.g. with a 3x3 kernel, you should use `--resize-damage 1`, +# with a 5x5 one you use `--resize-damage 2`, and so on). +# May or may not work with *--glx-no-stencil*. Shrinking doesn't function correctly. +# +# resize-damage = 1 + +# Specify a list of conditions of windows that should be painted with inverted color. +# Resource-hogging, and is not well tested. +# +# invert-color-include = [] + +# GLX backend: Avoid using stencil buffer, useful if you don't have a stencil buffer. +# Might cause incorrect opacity when rendering transparent content (but never +# practically happened) and may not work with blur-background. +# My tests show a 15% performance boost. Recommended. +# +# glx-no-stencil = false + +# GLX backend: Avoid rebinding pixmap on window damage. +# Probably could improve performance on rapid window content changes, +# but is known to break things on some drivers (LLVMpipe, xf86-video-intel, etc.). +# Recommended if it works. +# +# glx-no-rebind-pixmap = false + +# Disable the use of damage information. +# This cause the whole screen to be redrawn everytime, instead of the part of the screen +# has actually changed. Potentially degrades the performance, but might fix some artifacts. +# The opposing option is use-damage +# +# no-use-damage = false +#use-damage = true (Causing Weird Black semi opaque rectangles when terminal is opened) +#Changing use-damage to false fixes the problem +use-damage = false + +# Use X Sync fence to sync clients' draw calls, to make sure all draw +# calls are finished before picom starts drawing. Needed on nvidia-drivers +# with GLX backend for some users. +# +# xrender-sync-fence = false + +# GLX backend: Use specified GLSL fragment shader for rendering window contents. +# See `compton-default-fshader-win.glsl` and `compton-fake-transparency-fshader-win.glsl` +# in the source tree for examples. +# +# glx-fshader-win = '' + +# Force all windows to be painted with blending. Useful if you +# have a glx-fshader-win that could turn opaque pixels transparent. +# +# force-win-blend = false + +# Do not use EWMH to detect fullscreen windows. +# Reverts to checking if a window is fullscreen based only on its size and coordinates. +# +# no-ewmh-fullscreen = false + +# Dimming bright windows so their brightness doesn't exceed this set value. +# Brightness of a window is estimated by averaging all pixels in the window, +# so this could comes with a performance hit. +# Setting this to 1.0 disables this behaviour. Requires --use-damage to be disabled. (default: 1.0) +# +# max-brightness = 1.0 + +# Make transparent windows clip other windows like non-transparent windows do, +# instead of blending on top of them. +# +# transparent-clipping = false + +# Set the log level. Possible values are: +# "trace", "debug", "info", "warn", "error" +# in increasing level of importance. Case doesn't matter. +# If using the "TRACE" log level, it's better to log into a file +# using *--log-file*, since it can generate a huge stream of logs. +# +# log-level = "debug" +log-level = "info"; + +# Set the log file. +# If *--log-file* is never specified, logs will be written to stderr. +# Otherwise, logs will to written to the given file, though some of the early +# logs might still be written to the stderr. +# When setting this option from the config file, it is recommended to use an absolute path. +# +# log-file = '/path/to/your/log/file' + +# Show all X errors (for debugging) +# show-all-xerrors = false + +# Write process ID to a file. +# write-pid-path = '/path/to/your/log/file' + +# Window type settings +# +# 'WINDOW_TYPE' is one of the 15 window types defined in EWMH standard: +# "unknown", "desktop", "dock", "toolbar", "menu", "utility", +# "splash", "dialog", "normal", "dropdown_menu", "popup_menu", +# "tooltip", "notification", "combo", and "dnd". +# +# Following per window-type options are available: :: +# +# fade, shadow::: +# Controls window-type-specific shadow and fade settings. +# +# opacity::: +# Controls default opacity of the window type. +# +# focus::: +# Controls whether the window of this type is to be always considered focused. +# (By default, all window types except "normal" and "dialog" has this on.) +# +# full-shadow::: +# Controls whether shadow is drawn under the parts of the window that you +# normally won't be able to see. Useful when the window has parts of it +# transparent, and you want shadows in those areas. +# +# redir-ignore::: +# Controls whether this type of windows should cause screen to become +# redirected again after been unredirected. If you have unredir-if-possible +# set, and doesn't want certain window to cause unnecessary screen redirection, +# you can set this to `true`. +# +wintypes: +{ + dock = { shadow = false; } + dnd = { shadow = false; } +}; diff --git a/stow_home/picom/.config/picom/picom.conf.bak b/stow_home/picom/.config/picom/picom.conf.bak new file mode 100755 index 0000000..a5b20a2 --- /dev/null +++ b/stow_home/picom/.config/picom/picom.conf.bak @@ -0,0 +1,63 @@ +backend = "glx"; +glx-no-stencil = true; +vsync = true; +unredir-if-possible = true; + +# Shadow +shadow = true; # Enabled client-side shadows on windows. +shadow-radius = 7; # The blur radius for shadows. (default 12) +shadow-offset-x = -7; # The left offset for shadows. (default -15) +shadow-offset-y = -7; # The top offset for shadows. (default -15) +shadow-exclude = [ + "n:e:Notification", + "n:e:Docky", + "g:e:Synapse", + "g:e:Conky", + "n:w:*Chromium*", + "n:w:*dockbarx*", + "n:w:*panel*" + "n:w:*maim*" + "class_g ?= 'spectrwm'", + "class_g ?= 'Cairo-dock'", + "class_g ?= 'Xfce4-notifyd'", + "class_g ?= 'Xfce4-power-manager'", + "class_g ?= 'Notify-osd'", + "class_g ?= 'Firefox'", + "_GTK_FRAME_EXTENTS@:c" +]; + + +blur-background = true; +blur-background-frame = true; +blur-kern = "3x3box" +blur-background-fixed = true; +blur-background-exclude = [ + "window_type = 'dock'", + "window_type = 'desktop'" +]; + + +# Opacity +detect-client-opacity = true; +menu-opacity = 1.0; +active-opacity = 1.0; +inactive-opacity = 0.8; +inactive-opacity-override = false; +opacity-rule = [ +"90:class_g ?= 'pcmanfm'" , +"99:class_g ?= 'Firefox'" , +"99:class_g ?= 'Xfce4-terminal'" , +"99:class_g ?= 'konsole'" , +"100:class_g ?= 'rofi'" +] + + + + +# Window type settings +wintypes: +{ + dock = { shadow = false; }; + dnd = { shadow = false; }; + tooltip = { shadow = false; }; +}; diff --git a/stow_home/picom/.config/picom/picomvoiddefault.conf.bak b/stow_home/picom/.config/picom/picomvoiddefault.conf.bak new file mode 100755 index 0000000..31a30f5 --- /dev/null +++ b/stow_home/picom/.config/picom/picomvoiddefault.conf.bak @@ -0,0 +1,425 @@ +################################# +# Shadows # +################################# + + +# Enabled client-side shadows on windows. Note desktop windows +# (windows with '_NET_WM_WINDOW_TYPE_DESKTOP') never get shadow, +# unless explicitly requested using the wintypes option. +# +# shadow = false +shadow = true; + +# The blur radius for shadows, in pixels. (defaults to 12) +# shadow-radius = 12 +shadow-radius = 7; + +# The opacity of shadows. (0.0 - 1.0, defaults to 0.75) +# shadow-opacity = .75 + +# The left offset for shadows, in pixels. (defaults to -15) +# shadow-offset-x = -15 +shadow-offset-x = -7; + +# The top offset for shadows, in pixels. (defaults to -15) +# shadow-offset-y = -15 +shadow-offset-y = -7; + +# Red color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-red = 0 + +# Green color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-green = 0 + +# Blue color value of shadow (0.0 - 1.0, defaults to 0). +# shadow-blue = 0 + +# Hex string color value of shadow (#000000 - #FFFFFF, defaults to #000000). This option will override options set shadow-(red/green/blue) +# shadow-color = "#000000" + +# Specify a list of conditions of windows that should have no shadow. +# +# examples: +# shadow-exclude = "n:e:Notification"; +# +# shadow-exclude = [] +shadow-exclude = [ + "name = 'Notification'", + "class_g = 'Conky'", + "class_g ?= 'Notify-osd'", + "class_g = 'Cairo-clock'", + "class_g = 'Firefox'", + "class_g = 'LibreWolf'", + "class_g = 'Brave-browser'", + "class_g = 'obs'", + "class_g = 'trayer'", + "_GTK_FRAME_EXTENTS@:c" +]; + +# Specify a X geometry that describes the region in which shadow should not +# be painted in, such as a dock window region. Use +# shadow-exclude-reg = "x10+0+0" +# for example, if the 10 pixels on the bottom of the screen should not have shadows painted on. +# +# shadow-exclude-reg = "" + +# Crop shadow of a window fully on a particular Xinerama screen to the screen. +# xinerama-shadow-crop = false + + +################################# +# Fading # +################################# + + +# Fade windows in/out when opening/closing and when opacity changes, +# unless no-fading-openclose is used. +# fading = false +fading = true; + +# Opacity change between steps while fading in. (0.01 - 1.0, defaults to 0.028) +# fade-in-step = 0.028 +fade-in-step = 0.03; + +# Opacity change between steps while fading out. (0.01 - 1.0, defaults to 0.03) +# fade-out-step = 0.03 +fade-out-step = 0.03; + +# The time between steps in fade step, in milliseconds. (> 0, defaults to 10) +# fade-delta = 10 + +# Specify a list of conditions of windows that should not be faded. +# fade-exclude = [] + +# Do not fade on window open/close. +# no-fading-openclose = false + +# Do not fade destroyed ARGB windows with WM frame. Workaround of bugs in Openbox, Fluxbox, etc. +# no-fading-destroyed-argb = false + + +################################# +# Transparency / Opacity # +################################# + + +# Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0) +# inactive-opacity = 1 +inactive-opacity = 0.8; + +# Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default) +# frame-opacity = 1.0 +frame-opacity = 0.7; + +# Let inactive opacity set by -i override the '_NET_WM_OPACITY' values of windows. +# inactive-opacity-override = true +inactive-opacity-override = false; + +# Default opacity for active windows. (0.0 - 1.0, defaults to 1.0) +# active-opacity = 1.0 + +# Dim inactive windows. (0.0 - 1.0, defaults to 0.0) +# inactive-dim = 0.0 + +# Specify a list of conditions of windows that should always be considered focused. +# focus-exclude = [] +focus-exclude = [ "class_g = 'Cairo-clock'" ]; + +# Use fixed inactive dim value, instead of adjusting according to window opacity. +# inactive-dim-fixed = 1.0 + +# Specify a list of opacity rules, in the format `PERCENT:PATTERN`, +# like `50:name *= "Firefox"`. picom-trans is recommended over this. +# Note we don't make any guarantee about possible conflicts with other +# programs that set '_NET_WM_WINDOW_OPACITY' on frame or client windows. +# example: + opacity-rule = [ + "80:class_g = 'URxvt'", + "100:class_g = 'Firefox'", + "100:class_g = 'Gimp-2.10'", + "100:class_g = 'discord'", + "100:class_g = 'Brave-browser'", + "100:class_g = 'obs'", + "100:class_g = 'trayer'", + ]; +# +# opacity-rule = [] + + +################################# +# Corners # +################################# + +# Sets the radius of rounded window corners. When > 0, the compositor will +# round the corners of windows. Does not interact well with +# `transparent-clipping`. +corner-radius = 16 + +# Exclude conditions for rounded corners. +rounded-corners-exclude = [ + "window_type = 'dock'", + "window_type = 'desktop'", +]; + + +################################# +# Background-Blurring # +################################# + + +# Parameters for background blurring, see the *BLUR* section for more information. +blur-method ="gaussian" +# blur-size = 50 +# +# blur-deviation = false +# +blur-strength = 45 + +# Blur background of semi-transparent / ARGB windows. +# Bad in performance, with driver-dependent behavior. +# The name of the switch may change without prior notifications. +# +# blur-background = false + +# Blur background of windows when the window frame is not opaque. +# Implies: +# blur-background +# Bad in performance, with driver-dependent behavior. The name may change. +# +# blur-background-frame = false + + +# Use fixed blur strength rather than adjusting according to window opacity. +blur-background-fixed = true + + +# Specify the blur convolution kernel, with the following format: +# example: +# blur-kern = "5,5,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1"; +# +# blur-kern = "" +blur-kern = "3x3box"; + + +# Exclude conditions for background blur. +# blur-background-exclude = [] +blur-background-exclude = [ + "window_type = 'dock'", + "window_type = 'desktop'", + "_GTK_FRAME_EXTENTS@:c" +]; + +################################# +# General Settings # +################################# + +# Daemonize process. Fork to background after initialization. Causes issues with certain (badly-written) drivers. +# daemon = false + +# Specify the backend to use: `xrender`, `glx`, or `xr_glx_hybrid`. +# `xrender` is the default one. +# +# backend = "glx" +backend = "xrender"; + +# Enable/disable VSync. +# vsync = false +vsync = true; + +# Enable remote control via D-Bus. See the *D-BUS API* section below for more details. +# dbus = false + +# Try to detect WM windows (a non-override-redirect window with no +# child that has 'WM_STATE') and mark them as active. +# +# mark-wmwin-focused = false +mark-wmwin-focused = true; + +# Mark override-redirect windows that doesn't have a child window with 'WM_STATE' focused. +# mark-ovredir-focused = false +mark-ovredir-focused = true; + +# Try to detect windows with rounded corners and don't consider them +# shaped windows. The accuracy is not very high, unfortunately. +# +# detect-rounded-corners = false +detect-rounded-corners = true; + +# Detect '_NET_WM_OPACITY' on client windows, useful for window managers +# not passing '_NET_WM_OPACITY' of client windows to frame windows. +# +# detect-client-opacity = false +detect-client-opacity = true; + +# Specify refresh rate of the screen. If not specified or 0, picom will +# try detecting this with X RandR extension. +# +# refresh-rate = 60 +refresh-rate = 0; + +# Use EWMH '_NET_ACTIVE_WINDOW' to determine currently focused window, +# rather than listening to 'FocusIn'/'FocusOut' event. Might have more accuracy, +# provided that the WM supports it. +# +# use-ewmh-active-win = false + +# Unredirect all windows if a full-screen opaque window is detected, +# to maximize performance for full-screen windows. Known to cause flickering +# when redirecting/unredirecting windows. +# +# unredir-if-possible = false + +# Delay before unredirecting the window, in milliseconds. Defaults to 0. +# unredir-if-possible-delay = 0 + +# Conditions of windows that shouldn't be considered full-screen for unredirecting screen. +# unredir-if-possible-exclude = [] + +# Use 'WM_TRANSIENT_FOR' to group windows, and consider windows +# in the same group focused at the same time. +# +# detect-transient = false +detect-transient = true; + +# Use 'WM_CLIENT_LEADER' to group windows, and consider windows in the same +# group focused at the same time. 'WM_TRANSIENT_FOR' has higher priority if +# detect-transient is enabled, too. +# +# detect-client-leader = false +detect-client-leader = true; + +# Resize damaged region by a specific number of pixels. +# A positive value enlarges it while a negative one shrinks it. +# If the value is positive, those additional pixels will not be actually painted +# to screen, only used in blur calculation, and such. (Due to technical limitations, +# with use-damage, those pixels will still be incorrectly painted to screen.) +# Primarily used to fix the line corruption issues of blur, +# in which case you should use the blur radius value here +# (e.g. with a 3x3 kernel, you should use `--resize-damage 1`, +# with a 5x5 one you use `--resize-damage 2`, and so on). +# May or may not work with *--glx-no-stencil*. Shrinking doesn't function correctly. +# +# resize-damage = 1 + +# Specify a list of conditions of windows that should be painted with inverted color. +# Resource-hogging, and is not well tested. +# +# invert-color-include = [] + +# GLX backend: Avoid using stencil buffer, useful if you don't have a stencil buffer. +# Might cause incorrect opacity when rendering transparent content (but never +# practically happened) and may not work with blur-background. +# My tests show a 15% performance boost. Recommended. +# +# glx-no-stencil = false + +# GLX backend: Avoid rebinding pixmap on window damage. +# Probably could improve performance on rapid window content changes, +# but is known to break things on some drivers (LLVMpipe, xf86-video-intel, etc.). +# Recommended if it works. +# +# glx-no-rebind-pixmap = false + +# Disable the use of damage information. +# This cause the whole screen to be redrawn everytime, instead of the part of the screen +# has actually changed. Potentially degrades the performance, but might fix some artifacts. +# The opposing option is use-damage +# +# no-use-damage = false +use-damage = true; + +# Use X Sync fence to sync clients' draw calls, to make sure all draw +# calls are finished before picom starts drawing. Needed on nvidia-drivers +# with GLX backend for some users. +# +# xrender-sync-fence = false + +# GLX backend: Use specified GLSL fragment shader for rendering window contents. +# See `compton-default-fshader-win.glsl` and `compton-fake-transparency-fshader-win.glsl` +# in the source tree for examples. +# +# glx-fshader-win = "" + +# Force all windows to be painted with blending. Useful if you +# have a glx-fshader-win that could turn opaque pixels transparent. +# +# force-win-blend = false + +# Do not use EWMH to detect fullscreen windows. +# Reverts to checking if a window is fullscreen based only on its size and coordinates. +# +# no-ewmh-fullscreen = false + +# Dimming bright windows so their brightness doesn't exceed this set value. +# Brightness of a window is estimated by averaging all pixels in the window, +# so this could comes with a performance hit. +# Setting this to 1.0 disables this behaviour. Requires --use-damage to be disabled. (default: 1.0) +# +# max-brightness = 1.0 + +# Make transparent windows clip other windows like non-transparent windows do, +# instead of blending on top of them. +# +# transparent-clipping = false + +# Set the log level. Possible values are: +# "trace", "debug", "info", "warn", "error" +# in increasing level of importance. Case doesn't matter. +# If using the "TRACE" log level, it's better to log into a file +# using *--log-file*, since it can generate a huge stream of logs. +# +# log-level = "debug" +log-level = "warn"; + +# Set the log file. +# If *--log-file* is never specified, logs will be written to stderr. +# Otherwise, logs will to written to the given file, though some of the early +# logs might still be written to the stderr. +# When setting this option from the config file, it is recommended to use an absolute path. +# +# log-file = "/path/to/your/log/file" + +# Show all X errors (for debugging) +# show-all-xerrors = false + +# Write process ID to a file. +# write-pid-path = "/path/to/your/log/file" + +# Window type settings +# +# 'WINDOW_TYPE' is one of the 15 window types defined in EWMH standard: +# "unknown", "desktop", "dock", "toolbar", "menu", "utility", +# "splash", "dialog", "normal", "dropdown_menu", "popup_menu", +# "tooltip", "notification", "combo", and "dnd". +# +# Following per window-type options are available: :: +# +# fade, shadow::: +# Controls window-type-specific shadow and fade settings. +# +# opacity::: +# Controls default opacity of the window type. +# +# focus::: +# Controls whether the window of this type is to be always considered focused. +# (By default, all window types except "normal" and "dialog" has this on.) +# +# full-shadow::: +# Controls whether shadow is drawn under the parts of the window that you +# normally won't be able to see. Useful when the window has parts of it +# transparent, and you want shadows in those areas. +# +# redir-ignore::: +# Controls whether this type of windows should cause screen to become +# redirected again after been unredirected. If you have unredir-if-possible +# set, and doesn't want certain window to cause unnecessary screen redirection, +# you can set this to `true`. +# +wintypes: +{ + tooltip = { fade = true; shadow = true; opacity = 0.75; focus = true; full-shadow = false; }; + dock = { shadow = false; } + dnd = { shadow = false; } + popup_menu = { opacity = 0.8; } + dropdown_menu = { opacity = 0.8; } +}; diff --git a/stow_home/rofi/.config/rofi/config.rasi b/stow_home/rofi/.config/rofi/config.rasi new file mode 100644 index 0000000..3dee511 --- /dev/null +++ b/stow_home/rofi/.config/rofi/config.rasi @@ -0,0 +1,11 @@ +configuration { + columns: 1; + terminal: "alacritty"; + theme: "/home/joelchrono12/.config/rofi/themes/centered-nord.rasi"; + modi: "drun,calc:qalc,window,run,emoji"; + show-icons: true; + icon-theme: "Flatery-Blue-Dark"; + width: 30; + lines: 18; + fake-transparency: true; +} diff --git a/stow_home/rofi/.config/rofi/scripts/dmenu-edit-configs.sh b/stow_home/rofi/.config/rofi/scripts/dmenu-edit-configs.sh new file mode 100755 index 0000000..f80b05c --- /dev/null +++ b/stow_home/rofi/.config/rofi/scripts/dmenu-edit-configs.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# ____ _____ +# | _ \_ _| Derek Taylor (DistroTube) +# | | | || | http://www.youtube.com/c/DistroTube +# | |_| || | http://www.gitlab.com/dwt1/ +# |____/ |_| +# +# Dmenu script for editing some of my more frequently edited config files. + + +declare options=("alacritty +awesome +bash +doom/config.el +doom/init.el +neovim +picom +spectrwm +quit") + +choice=$(echo -e "${options[@]}" | rofi -dmenu -p 'Edit config file: ') + +case "$choice" in + quit) + echo "Program terminated." && exit 1 + ;; + alacritty) + choice="$HOME/.config/alacritty/alacritty.yml" + ;; + awesome) + choice="$HOME/.config/awesome/rc.lua" + ;; + bash) + choice="$HOME/.bashrc" + ;; + doom.d/config.el) + choice="$HOME/.config/doom/config.el" + ;; + doom.d/init.el) + choice="$HOME/.config/doom/init.el" + ;; + neovim) + choice="$HOME/.config/nvim/init.vim" + ;; + picom) + choice="$HOME/.config/picom/picom.conf" + ;; + spectrwm) + choice="$HOME/.config/spectrwm/README.org" + ;; + *) + exit 1 + ;; +esac +#alacritty -e nvim "$choice" & +emacsclient -c -a emacs "$choice" diff --git a/stow_home/rofi/.config/rofi/scripts/power-menu.sh b/stow_home/rofi/.config/rofi/scripts/power-menu.sh new file mode 100755 index 0000000..d532521 --- /dev/null +++ b/stow_home/rofi/.config/rofi/scripts/power-menu.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Simple script to handle a DIY shutdown menu. When run you should see a bunch of options (shutdown, reboot etc.) +# +# Requirements: +# - rofi +# - systemd, but you can replace the commands for OpenRC or anything else +# +# Instructions: +current=$(wmctrl -m | grep Name | awk {'print $2'}) +# - Save this file as power.sh or anything +# - Give it exec priviledge, or chmod +x /path/to/power.sh +# - Run it +chosen=$(echo -e "[Cancel]\nLogout\nShutdown\nReboot System\nEdit config\nEdit dotfiles\nEdit power menu" | rofi -dmenu -width 10 -lines 7 -i -p "Power Menu:") +# Info about some states are available here: +# https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html#Description + +if [[ $chosen = "Logout" ]]; then + pkill $current +elif [[ $chosen = "Shutdown" ]]; then + systemctl poweroff +elif [[ $chosen = "Reboot System" ]]; then + systemctl reboot +elif [[ $chosen = "Edit config" ]]; then + if [[ $current = "spectrwm" ]]; then + alacritty -e nvim ~/.spectrwm.conf + elif [[ $current = "awesome" ]]; then + alacritty -e nvim ~/.config/awesome/rc.lua + elif [[ $current = "leftwm" ]]; then + alacritty -e nvim ~/.config/leftwm/config.toml + fi +elif [[ $chosen = "Edit dotfiles" ]]; then + ~/.config/rofi/scripts/dmenu-edit-configs.sh +elif [[ $chosen = "Edit power menu" ]]; then + alacritty -e nvim $HOME/.config/rofi/scripts/power-menu.sh +fi diff --git a/stow_home/rofi/.config/rofi/scripts/qpost.sh b/stow_home/rofi/.config/rofi/scripts/qpost.sh new file mode 100755 index 0000000..eb4a9f3 --- /dev/null +++ b/stow_home/rofi/.config/rofi/scripts/qpost.sh @@ -0,0 +1,32 @@ +#! /bin/bash +path=/home/joelchrono12/git/joelchrono12.ml/_posts/ +title=$(rofi -l 0 -width 50 -p "Title:" -dmenu) +filen=$(echo $title | tr " ,.!" "-"| awk '{print tolower($0)}') +if [ -z $title ]; then + exit +fi +today=$(date +"%Y-%m-%d") +filename=($today-$filen) +description=$(rofi -l 0 -width 60 -height 20 -p "Description:" -dmenu) +tags=$(rofi -l 0 -width 45 -p "Tags:" -dmenu) +num=0 +while [ $num = 0 ]; do + choice=$(echo -e "Edit file\nEdit title\nEdit description\nEdit tags\nCancel" | rofi -width 15 -l 5-p "Now?:" -dmenu) + + if [[ $choice = "Edit file" ]]; then + touch $path/$filename.md + echo -e "---\ntitle: $title\nheader: $title\ndescription: $description\ntags: $tags\npermalink: /blog/$filen/\nlayout: post\ndate: $today $(date +"%T") -0500\nhost: fosstodon.org\nusername: joeligj12\ncom_id: idcomments\n---">> $path/$filename.md + num=1 + alacritty -e nvim $path/$filename.md & disown + #cp $path/$filename.md ~/Documents + elif [[ $choice = "Edit title" ]]; then + title=$(rofi -l 0 -width 50 -p "Title:" -dmenu) + elif [[ $choice = "Edit description" ]]; then + description=$(rofi -l 0 -width 60 -height 20 -p "Description:" -dmenu) + elif [[ $choice = "Edit tags" ]]; then + tags=$(rofi -l 0 -width 45 -p "Tags:" -dmenu) + else + num=1 + fi +done + diff --git a/stow_home/rofi/.config/rofi/themes/centered-nord.rasi b/stow_home/rofi/.config/rofi/themes/centered-nord.rasi new file mode 100755 index 0000000..1787106 --- /dev/null +++ b/stow_home/rofi/.config/rofi/themes/centered-nord.rasi @@ -0,0 +1,84 @@ +/** + * Based on: dt-center.rasi by Derek Taylor (DT) + * Customized by JoelChrono12 + * Nord Theme Rofi + */ + +* { + background-color: #2e3440; + border-color: #2e3440; + text-color: #eceff4; + font: "Source Code Pro 12"; + prompt-font: "Source Code Pro 13"; + prompt-background: #b48ead; + prompt-foreground: #2e3440; + prompt-padding: 4px; + alternate-normal-background: #3b4252; + alternate-normal-foreground: @text-color; + selected-normal-background: #a3be8c; + selected-normal-foreground: #2e3440; + border-radius: 8px; + spacing: 3; +} +#window { + border: 1; + padding: 5; +} +#mainbox { + border: 0; + padding: 0; +} +#message { + border: 1px dash 0px 0px ; + padding: 1px ; +} +#listview { + fixed-height: 0; + border: 2px dash 0px 0px ; + spacing: 2px ; + scrollbar: true; + padding: 2px 0px 0px ; +} +#element { + border: 0; + padding: 1px ; +} +#element.selected.normal { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} +#element.alternate.normal { + background-color: @alternate-normal-background; + text-color: @alternate-normal-foreground; +} +#scrollbar { + width: 0px ; + border: 0; + handle-width: 0px ; + padding: 0; +} +#sidebar { + border: 2px dash 0px 0px ; +} +#button.selected { + background-color: @selected-normal-background; + text-color: @selected-normal-foreground; +} +#inputbar { + spacing: 0; + padding: 1px ; +} +#case-indicator { + spacing: 0; +} +#entry { + padding: 4px 4px; + expand: false; + width: 100%; +} +#prompt { + padding: @prompt-padding; + background-color: @prompt-background; + text-color: @prompt-foreground; + font: @prompt-font; +} diff --git a/stow_home/spectrwm/.config/spectrwm/README.org b/stow_home/spectrwm/.config/spectrwm/README.org new file mode 100644 index 0000000..81d8854 --- /dev/null +++ b/stow_home/spectrwm/.config/spectrwm/README.org @@ -0,0 +1,291 @@ +#+TITLE: My custom Spectrwm configuration +#+PROPERTY: header-args :tangle spectrwm.conf +#+author: Joelchrono12 +* My config +:PROPERTIES: +:DIR: ~/.config/spectrwm/org-assets/ +:END: +This is my personal config for the Spectrwm window manager. Spectrwm its a really minimal program to manage windows, not as simple as DWM, while still being fairly customizable. +You can see how it looks here! + +[[./org-assets/spectrwm.png][My config]] + +* Initial setup +These first lines are pretty easy to understand. The variables in spectrwm describe their functionality quite well. These first lines are just setting up the minimal, simple configuration. +#+begin_src conf + # Initial setup config +workspace_limit = 9 +focus_mode = manual +focus_close = previous +focus_close_wrap = 0 +focus_default = last +spawn_position = next +workspace_clamp = 1 +warp_focus = 0 +warp_pointer = 0 + +#+end_src +* Window decoration & boundaries +This is a fairly customizable section of the config, we configure the borders of the windows, the colors when focused or not, as well as the gaps and padding. + +I like to have quite a big amount of gaps. The focus color is the blue from the [[https://www.nordtheme.com/][Nord]] color scheme, and the unfocused is dark gray + +#+begin_src conf + # Window decorations & boundaries +border_width = 2 +color_focus = rgb:d0/87/70 +color_unfocus = rgb:5e/81/ac +region_padding = 0 +tile_gap = 0 +boundary_width = 50 + +#+end_src + +* The bar +My bar is the most important aspect of this config, since its the one that will appear in all of my workspaces. It is a top bar and it shows all of the +available workspaces, marking the current one with an asterisk The bar borders are useless to me since I only have one screen + +#+begin_src conf + # Bar configuration +bar_enabled = 1 +bar_border_width = 1 +bar_border[1] = rgb:18/18/18 +bar_border_unfocus[1] = rgb:18/18/18 +bar_color[1] = rgb:2e/34/40,rgb:eb/cb/8b,rgb:a3/be/8c,rgb:bf/61/6a,rgb:b4/8e/ad,rgb:88/c0/d0,rgb:d0/87/70,rgb:3b/42/52,rgb:4c/56/6a +bar_color_selected[1] = rgb:88/c0/d0 +bar_font_color[1] = rgb:ec/ef/f4,rgb:2e/34/40,rgb:2e/34/40,rgb:eb/cb/8b,rgb:a3/be/8c,rgb:bf/61/6a,rgb:b4/8e/ad,rgb:88/c0/d0,rgb:d0/87/70,rgb:3b/42/52,rgb:4c/56/6a +bar_font = Blex Mono Nerd Font:pixelsize=15:antialias=true +bar_action = ~/.config/spectrwm/baraction.sh +bar_action_expand = 1 +bar_justify = right +bar_format = +|L +@bg=0;+S +L +@bg=0; +@bg=8; +C +@fg=0; +|2R +A +@bg=0;+@fg=0; %a, %b %d %R +< +bar_at_bottom = 0 +workspace_indicator = listall,markcurrent +stack_enabled = 1 +clock_enabled = 1 +clock_format = %a, %b %d %R +iconic_enabled = 1 +maximize_hide_bar = 0 +window_class_enabled = 1 +window_instance_enabled = 1 +window_name_enabled = 0 +verbose_layout = 0 +urgent_enabled = 1 +urgent_collapse = 0 + +#+end_src + +* Starting up and applications +No need to talk about these, I use these programs to set up stuff as soon as my session starts, maybe I should put some in another file, like ~.initrc~, but I've not done it yet. + +#+begin_src conf + # Autorunning applications +autorun = ws[1]:nitrogen --set-auto ~/Pictures/walls/paranoid.jpg & +autorun = ws[1]:setxkbmap -layout latam & +autorun = ws[1]:alacritty +autorun = ws[1]:volumeicon +autorun = ws[1]:xfce4-power-manager +autorun = ws[1]:syncthing +autorun = ws[1]:nm-applet & +autorun = ws[1]:lxpolkit & +autorun = ws[1]:picom --experimental-backends --backend glx --blur-method 'dual_kawase' --blur-strength 6 + +#+end_src + +Other important details are setup here, like workspace names and defining a Modifier key, I could use glyphs as workspace names, but honestly, they don't really describe that well what I want to do in them. + +#+begin_src conf + # Workspace names and modkey +layout = ws[1]:4:0:0:0:vertical +name = ws[1]:WEB +name = ws[2]:DEV +name = ws[3]:MAIL +name = ws[4]:FILE +name = ws[5]:CHAT +name = ws[6]:SSH +name = ws[7]:EMACS +name = ws[8]:TERM +name = ws[9]:ETC +# ", " ", " ", " ", " ", " ", " ", " ", " ", " " +modkey = Mod4 + +#+end_src +* Quirks +These are different ways to treat the windows of specific programs, making them float, or appear in a certain workspace all the time. These are really powerful settings, but are still being set up, since some apps don't behave as I expect them to do so. + +#+begin_src conf + # Quirks and custom per program behavior +quirk[firefox:Dialog] = FLOAT + MINIMALBORDER + TRANSSZ +quirk[Image Lounge] = FLOAT +quirk[firefox] = IGNOREPID + TRANSSZ + ANYWHERE +quirk[Thunderbird] = ANYWHERE + IGNORESPAWNWS + IGNOREPID + TRANSSZ +quirk[Claws-mail] = ANYWHERE + IGNORESPAWNWS + IGNOREPID + TRANSSZ +quirk[Xarchiver] = ANYWHERE + IGNORESPAWNWS + IGNOREPID + TRANSSZ +quirk[Lxappearance] = FLOAT +quirk[Pavucontrol] = FLOAT +quirk[Volumeicon] = FLOAT + ANYWHERE + IGNORESPAWNWS + IGNOREPID +quirk[discord:Discord Updater] = FLOAT + IGNOREPID +quirk[stalonetray] = FLOAT + ANYWHERE +quirk[trayer] = FLOAT + ANYWHERE + NOFOCUSCYCLE + MINIMALBORDER + NOFOCUSONMAP +quirk[Lxpolkit] = FLOAT + IGNOREPID +FOCUSPREV + IGNORESPAWNWS +quirk[Xfce4-power-manager-settings] = FLOAT + ANYWHERE +quirk[Nm-connection-editor] = ANYWHERE + IGNORESPAWNWS + FLOAT +quirk[Pcmanfm] = ANYWHERE + IGNORESPAWNWS +quirk[Thunar] = ANYWHERE + IGNORESPAWNWS + +#+end_src + +* General Keybindings +This is the defining factor of any window manager, how good and optimized are your keybindings. As you can assume, these are made to fit my needs, so your mileage may vary, but a lot of them are just the default one, in case you are wondering. + +It is important to remember that default kebindings are not unbinded unless you add ~bind[] = ~, so that's why you'll seee a few of them here and there. +#+begin_src conf + # General keybindings +bind[] = MOD+x +bind[] = MOD+v +bind[bar_toggle] = MOD+b +bind[bar_toggle_ws] = MOD+Shift+b +bind[cycle_layout] = MOD+space +bind[flip_layout] = MOD+Shift+backslash +bind[float_toggle] = MOD+t +bind[focus_main] = MOD+m +bind[focus_next] = MOD+j +bind[focus_next] = MOD+Tab +bind[focus_prev] = MOD+k +bind[focus_prev] = MOD+Shift+Tab +bind[focus_urgent] = MOD+u +bind[height_grow] = MOD+Shift+equal +bind[height_shrink] = MOD+Shift+minus +bind[iconify] = MOD+w +bind[initscr] = MOD+Shift+i +bind[lock] = MOD+Shift+Delete +bind[master_add] = MOD+Shift+comma +bind[master_del] = MOD+Shift+period +bind[master_grow] = MOD+l +bind[master_shrink] = MOD+h +bind[maximize_toggle] = MOD+e +bind[move_down] = MOD+Shift+bracketright +bind[move_left] = MOD+bracketleft +bind[move_right] = MOD+bracketright +bind[move_up] = MOD+Shift+bracketleft +bind[mvrg_1] = MOD+Shift+KP_End +bind[mvrg_2] = MOD+Shift+KP_Down +bind[mvrg_3] = MOD+Shift+KP_Next +bind[mvrg_4] = MOD+Shift+KP_Left +bind[mvrg_5] = MOD+Shift+KP_Begin +bind[mvrg_6] = MOD+Shift+KP_Right +bind[mvrg_7] = MOD+Shift+KP_Home +bind[mvrg_8] = MOD+Shift+KP_Up +bind[mvrg_9] = MOD+Shift+KP_Prior +bind[mvws_1] = MOD+Shift+1 +bind[mvws_2] = MOD+Shift+2 +bind[mvws_3] = MOD+Shift+3 +bind[mvws_4] = MOD+Shift+4 +bind[mvws_5] = MOD+Shift+5 +bind[mvws_6] = MOD+Shift+6 +bind[mvws_7] = MOD+Shift+7 +bind[mvws_8] = MOD+Shift+8 +bind[mvws_9] = MOD+Shift+9 +bind[mvws_10] = MOD+Shift+0 +bind[mvws_11] = MOD+Shift+F1 +bind[mvws_12] = MOD+Shift+F2 +bind[mvws_13] = MOD+Shift+F3 +bind[mvws_14] = MOD+Shift+F4 +bind[mvws_15] = MOD+Shift+F5 +bind[mvws_16] = MOD+Shift+F6 +bind[mvws_17] = MOD+Shift+F7 +bind[mvws_18] = MOD+Shift+F8 +bind[mvws_19] = MOD+Shift+F9 +bind[mvws_20] = MOD+Shift+F10 +bind[mvws_21] = MOD+Shift+F11 +bind[mvws_22] = MOD+Shift+F12 +bind[name_workspace] = MOD+Shift+slash +bind[quit] = MOD+Control+q +bind[raise_toggle] = MOD+Control+r +bind[restart] = MOD+Shift+r +bind[rg_1] = MOD+KP_End +bind[rg_2] = MOD+KP_Down +bind[rg_3] = MOD+KP_Next +bind[rg_4] = MOD+KP_Left +bind[rg_5] = MOD+KP_Begin +bind[rg_6] = MOD+KP_Right +bind[rg_7] = MOD+KP_Home +bind[rg_8] = MOD+KP_Up +bind[rg_9] = MOD+KP_Prior +bind[rg_next] = MOD+period +bind[rg_prev] = MOD+comma +bind[screenshot_all] = MOD+s +bind[screenshot_wind] = MOD+Shift+s +bind[search_win] = MOD+f +bind[search_workspace] = MOD+slash +bind[stack_dec] = MOD+Shift+period +bind[stack_inc] = MOD+Shift+comma +bind[stack_reset] = MOD+Shift+space +bind[swap_next] = MOD+Shift+j +bind[swap_prev] = MOD+Shift+k +bind[uniconify] = MOD+Shift+w +bind[version] = MOD+Shift+v +bind[width_grow] = MOD+equal +bind[width_shrink] = MOD+minus +bind[wind_del] = MOD+q +bind[ws_1] = MOD+1 +bind[ws_2] = MOD+2 +bind[ws_3] = MOD+3 +bind[ws_4] = MOD+4 +bind[ws_5] = MOD+5 +bind[ws_6] = MOD+6 +bind[ws_7] = MOD+7 +bind[ws_8] = MOD+8 +bind[ws_9] = MOD+9 +bind[ws_10] = MOD+0 +bind[ws_11] = MOD+F1 +bind[ws_12] = MOD+F2 +bind[ws_13] = MOD+F3 +bind[ws_14] = MOD+F4 +bind[ws_15] = MOD+F5 +bind[ws_16] = MOD+F6 +bind[ws_17] = MOD+F7 +bind[ws_18] = MOD+F8 +bind[ws_19] = MOD+F9 +bind[ws_20] = MOD+F10 +bind[ws_21] = MOD+F11 +bind[ws_22] = MOD+F12 +bind[ws_next_all] = MOD+Right +bind[ws_next] = MOD+Up +bind[ws_next_move] = MOD+Shift+Right +bind[ws_prev_all] = MOD+Left +bind[ws_prev] = MOD+Down +bind[ws_prev_move] = MOD+Shift+Left +bind[ws_prior] = MOD+a + +#+end_src + +* Program Keybindings +These are the keybindings I setup myself, in order to open programs and execute any command I configure, they don't change much, but I add some new one from time to time. +#+begin_src conf + # Custom program keybindings +program[Discord] = discord +bind[Discord] = MOD+mod1+d +program[term] = alacritty +bind[term] = MOD+Return +program[rofi_run] = rofi -show run +bind[rofi_run] = MOD+r +program[post] = ~/.config/rofi/scripts/qpost.sh +bind[post] = MOD+mod1+p +program[rofi_pass] = rofi-pass +bind[rofi_pass] = MOD+mod1+k +program[tab_switch] = rofi -show window +bind[tab_switch] = Mod1+Tab +program[rofi] = rofi -show drun +bind[rofi] = MOD+p +program[power_menu] = ~/.config/rofi/scripts/power-menu.sh +bind[power_menu] = MOD+Shift+q +program[screenshot] = flameshot gui +bind[screenshot] = MOD+Shift+s +program[firefox] = firefox +bind[firefox] = MOD+Mod1+b +program[pcmanfm] = pcmanfm +bind[pcmanfm] = MOD+Mod1+f +program[pulsemixer] = alacritty -e pulsemixer +bind[pulsemixer] = MOD+mod1+v +#+end_src diff --git a/stow_home/spectrwm/.config/spectrwm/bar-config.org b/stow_home/spectrwm/.config/spectrwm/bar-config.org new file mode 100644 index 0000000..761d6c5 --- /dev/null +++ b/stow_home/spectrwm/.config/spectrwm/bar-config.org @@ -0,0 +1,187 @@ +#+TITLE: My Spectrwm bar config +#+property: header-args :tangle baraction.sh +#+author: joelchrono12 + +* Contents :toc: +- [[#my-bar-action-configuration][My bar action configuration]] + - [[#dependencies][Dependencies]] + - [[#disclaimer][Disclaimer]] +- [[#network-status][Network status]] +- [[#battery-status][Battery status]] +- [[#volume-levels][Volume levels]] +- [[#storage-and-ram][Storage and RAM]] +- [[#cpu-status][CPU status]] +- [[#bar-process][Bar process]] +- [[#extras][Extras]] + - [[#mpd-status][MPD status]] + - [[#packages-and-updates][Packages and updates]] + - [[#weather-report][Weather report]] + +* My bar action configuration +This is my bar script for Spectrwm. Which can be found [[./README.org][here]]. +This script displays some of the information I actually care about, as well as some things I don't. +** Dependencies +You are going to need a few programs in order to properly display the bar output +- awk +- mpc +- pamixer +- sed +- mpd +** Disclaimer +Keep in mind that some of my scripts might not work on your specific linux distro, I am running Endeavour OS which is Arch based and uses pacman as package manager. So some of the package related scripts might not work + +* Network status +This one will probably be fine for most setups. +#+begin_src bash +# network status +network() { +wifi="$(ip a | grep wlan0 | grep inet | wc -l)" +wire="$(ip a | grep enp1s0 | grep inet | wc -l)" +if [ $wire = 1 ]; then + echo " " +elif [ $wifi = 1 ]; then + echo " " +else + echo "睊" +fi +} + +#+end_src +* Battery status +This one comes from using cat on a system file. There might be some other utilites, like ~acpi~ that could work here, but this is fine. +#+begin_src bash +# battery status +bat() { + batstat="$(cat /sys/class/power_supply/BAT0/status)" + battery="$(cat /sys/class/power_supply/BAT0/capacity)" + + if [ $batstat = 'Unknown' ]; then + batstat="" + elif [[ $battery -ge 5 ]] && [[ $battery -le 19 ]]; then + batstat="" + elif [[ $battery -ge 20 ]] && [[ $battery -le 39 ]]; then + batstat="" + elif [[ $battery -ge 40 ]] && [[ $battery -le 59 ]]; then + batstat="" + elif [[ $battery -ge 60 ]] && [[ $battery -le 79 ]]; then + batstat="" + elif [[ $battery -ge 80 ]] && [[ $battery -le 95 ]]; then + batstat="" + elif [[ $battery -ge 96 ]] && [[ $battery -le 100 ]]; then + batstat="" + fi + + echo "$batstat $battery" +} + +#+end_src +* Volume levels +In this case I decided to go with ~pamixer~ just because its easier to use and write. I can probably do something like what happens with the [[Battery status][battery section]], but its fine as is, I got this from the internet too, what do you expect? + +#+begin_src bash +# volume status +vol() { + volstat=$(pamixer --get-volume-human) + vol=$(echo "$volstat") + volicon="墳" + echo -e "$volicon $vol" +} + +#+end_src + +* Storage and RAM +This section just displays how much storage I've used in my ssd, might require some configuration on your part, I don't know. It also shows the available system memory. + +#+begin_src bash +# used storage +hdd() { + hdd="$(df -h /home | grep /dev | awk '{print $3 " / " $2}')" + echo -e " $hdd" +} + +# available ram +mem() { + used="$(free -h | grep Mem: | awk '{print $3}')" + #total="$(free | grep Mem: | awk '{print $2}')" + #totalh="$(free -h | grep Mem: | awk '{print $2}' | sed 's/Gi/G/')" + ram="$used" + echo $ram +} + +#+end_src + +* CPU status +Yep, I have no idea of what this does, but it works and I use it, ok? +#+begin_src bash +# Cpu things +cpu() { + read cpu a b c previdle rest < /proc/stat + prevtotal=$((a+b+c+previdle)) + sleep 0.5 + read cpu a b c idle rest < /proc/stat + total=$((a+b+c+idle)) + cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) )) + echo -e " $cpu%" +} + +#+end_src +* Bar process +The bar is going to be constantly running, updating every once in a while, this section echoes the output of all of the used functions, and its what spectrwm will show as the bar + +Notice the different sections such as ~+fg@1~, these are the colors that are shown in my ~spectrwm.conf~ file, and that's how spectrwm knows it needs to change the color of things. Like foreground and background + +#+begin_src bash +# Loop to update bar output +update(){ + echo " $(mpd) $(cpu)+@fg=3; +@bg=1;+@fg=1;  $(mem) +@fg=4;+@bg=2;+@fg=1;  $(hdd) +@fg=5;+@bg=3;+@fg=1; $(vol) +@fg=7;+@bg=5;+@fg=1; $(bat) +@fg=8;+@bg=6;+@fg=1; $(network) +@fg=1;+@bg=0;" + wait +} +while :; do + update + ~/.config/spectrwm/scripts/trayer_follows_ws.sh + sleep 2 & + wait +done + +#+end_src +* Extras +I have used and removed a few things from my script, but I added them here just in case anyone cares about them or is looking for stuff to put into their own config files. +** MPD status +Displays the current song playing with mpd, and if its paused +#+begin_src bash +mpd(){ + song="$(mpc current)" + status="$(mpc status | grep paused | awk '{print $1}')" + echo -e "$song" +} + +#+end_src + +** Packages and updates +These were made for [[https://voidlinux.org][Void Linux]], and I stil don't adapt them for Endeavor OS. Therefore, I don't call them, since they would not work +#+begin_src bash +# Installed packages +pkgs() { + pkgs="$(xbps-query -l | wc -l)" + echo -e " $pkgs" +} + +# Available updates +upgrades() { + upgrades="$(xbps-install -Sun | wc -l)" + echo -e " $upgrades" +} + +#+end_src + +** Weather report +I guess you can tell what this does from reading the title. I don't really know if it still works, to be honest. +#+begin_src bash +# weather using curl wttr.in +temp() { + tmp="$(curl -s wttr.in | grep -m 1 °C | awk '{print $5 $6}')" + ##tmp="$(grep temp_F ~/.config/weather.txt | awk '{print $2}' | sed 's/"//g' | sed 's/,/ F/g')" + echo " $tmp" +} + +#+end_src diff --git a/stow_home/spectrwm/.config/spectrwm/baraction.sh b/stow_home/spectrwm/.config/spectrwm/baraction.sh new file mode 100755 index 0000000..630fb2d --- /dev/null +++ b/stow_home/spectrwm/.config/spectrwm/baraction.sh @@ -0,0 +1,107 @@ +# network status +network() { +wifi="$(ip a | grep wlan0 | grep inet | wc -l)" +wire="$(ip a | grep enp1s0 | grep inet | wc -l)" +if [ $wire = 1 ]; then + echo " " +elif [ $wifi = 1 ]; then + echo " " +else + echo "睊" +fi +} + +# battery status +bat() { + batstat="$(cat /sys/class/power_supply/BAT0/status)" + battery="$(cat /sys/class/power_supply/BAT0/capacity)" + + if [ $batstat = 'Unknown' ]; then + batstat="" + elif [[ $battery -ge 5 ]] && [[ $battery -le 19 ]]; then + batstat="" + elif [[ $battery -ge 20 ]] && [[ $battery -le 39 ]]; then + batstat="" + elif [[ $battery -ge 40 ]] && [[ $battery -le 59 ]]; then + batstat="" + elif [[ $battery -ge 60 ]] && [[ $battery -le 79 ]]; then + batstat="" + elif [[ $battery -ge 80 ]] && [[ $battery -le 95 ]]; then + batstat="" + elif [[ $battery -ge 96 ]] && [[ $battery -le 100 ]]; then + batstat="" + fi + + echo "$batstat $battery" +} + +# volume status +vol() { + volstat=$(pamixer --get-volume-human) + vol=$(echo "$volstat") + volicon="墳" + echo -e "$volicon $vol" +} + +# used storage +hdd() { + hdd="$(df -h /home | grep /dev | awk '{print $3 " / " $2}')" + echo -e " $hdd" +} + +# available ram +mem() { + used="$(free -h | grep Mem: | awk '{print $3}')" + #total="$(free | grep Mem: | awk '{print $2}')" + #totalh="$(free -h | grep Mem: | awk '{print $2}' | sed 's/Gi/G/')" + ram="$used" + echo $ram +} + +# Cpu things +cpu() { + read cpu a b c previdle rest < /proc/stat + prevtotal=$((a+b+c+previdle)) + sleep 0.5 + read cpu a b c idle rest < /proc/stat + total=$((a+b+c+idle)) + cpu=$((100*( (total-prevtotal) - (idle-previdle) ) / (total-prevtotal) )) + echo -e " $cpu%" +} + +# Loop to update bar output +update(){ + echo " $(mpd) $(cpu)+@fg=3; +@bg=1;+@fg=1;  $(mem) +@fg=4;+@bg=2;+@fg=1;  $(hdd) +@fg=5;+@bg=3;+@fg=1; $(vol) +@fg=7;+@bg=5;+@fg=1; $(bat) +@fg=8;+@bg=6;+@fg=1; $(network) +@fg=1;+@bg=0;" + wait +} +while :; do + update + ~/.config/spectrwm/scripts/trayer_follows_ws.sh + sleep 2 & + wait +done + +mpd(){ + song="$(mpc current)" + status="$(mpc status | grep paused | awk '{print $1}')" + echo -e "$song" +} + +# Installed packages +pkgs() { + pkgs="$(xbps-query -l | wc -l)" + echo -e " $pkgs" +} + +# Available updates +upgrades() { + upgrades="$(xbps-install -Sun | wc -l)" + echo -e " $upgrades" +} + +# weather using curl wttr.in +temp() { + tmp="$(curl -s wttr.in | grep -m 1 °C | awk '{print $5 $6}')" + ##tmp="$(grep temp_F ~/.config/weather.txt | awk '{print $2}' | sed 's/"//g' | sed 's/,/ F/g')" + echo " $tmp" +} diff --git a/stow_home/spectrwm/.config/spectrwm/org-assets/spectrwm.png b/stow_home/spectrwm/.config/spectrwm/org-assets/spectrwm.png new file mode 100644 index 0000000..213f11e Binary files /dev/null and b/stow_home/spectrwm/.config/spectrwm/org-assets/spectrwm.png differ diff --git a/stow_home/spectrwm/.config/spectrwm/scripts/README.org b/stow_home/spectrwm/.config/spectrwm/scripts/README.org new file mode 100644 index 0000000..14dc186 --- /dev/null +++ b/stow_home/spectrwm/.config/spectrwm/scripts/README.org @@ -0,0 +1,57 @@ +#+TITLE: Other useful Spectrwm scripts +#+author: joelchrono12 header-args :tangle yes +* My spectrwm scripts +These are other kinds of scripts that you can use alongside my main [[./bar.org][baraction.sh]] script. They make use of ~wmctrl~ to add some level of functionality to Spectrwm. Here are the scripts! +Once generated, make sure to do the following command to make them executable! +#+begin_example +chmod +x file.sh +#+end_example +* Keep trayer on workspace +This script makes sure that trayer or any system tray or application stays in your current workspace. Spectrwm does not work very well with these kinda programs, and this solution is still kinda hacky, which is why its not part of my main script. If it does not work, sorry. +#+begin_src bash :tangle keep-trayer-ws.sh +#!/bin/bash +current_ws="$(wmctrl -d | grep '*' | awk '{print $1}')" +wmctrl -r panel -t $current_ws + +#+end_src +* Number of windows in workspace +A simple script that shows how many windows are open inside of current workspace +#+begin_src bash :tangle workspace-windows.sh +#!/bin/bash +ws_icon="$(wmctrl -d | grep "*" | awk '{print $9}')" +windows_number="$(wmctrl -l | grep -v panel | awk '{print $2}'))" +current_ws="$(wmctrl -d | grep '*' | awk '{print $1}')" +windows_in_ws="$(echo -e "$windows_number" | grep $current_ws | wc -l)" +echo -e "[$ws_icon ] [$windows_in_ws]" + +#+end_src +* Volume control +I normally use the ~volumeicon~ to take care of this, or ~pamixer~ on a terminal, but this script can do it too!, kinda... +Make sure to add this line to beginning or the main bar script +#+begin_example +trap 'update' 5 +#+end_example + +And this is the script itself. +#+begin_src bash :tangle volume-spectrwm.sh +#!/bin/bash +volumecontrol() { + pkill -SIGTRAP baraction.sh + case $1 in + increase) + amixer set Master 5%+ + ;; + ecrease) + amixer set Master 5%- + ;; + toggle) + amixer set Master toggle + ;; + ,*) + ;; + esac; +} + +volumecontrol $1 + +#+end_src diff --git a/stow_home/spectrwm/.config/spectrwm/scripts/keep-trayer-ws.sh b/stow_home/spectrwm/.config/spectrwm/scripts/keep-trayer-ws.sh new file mode 100755 index 0000000..5215016 --- /dev/null +++ b/stow_home/spectrwm/.config/spectrwm/scripts/keep-trayer-ws.sh @@ -0,0 +1,3 @@ +#!/bin/bash +current_ws="$(wmctrl -d | grep '*' | awk '{print $1}')" +wmctrl -r panel -t $current_ws diff --git a/stow_home/spectrwm/.config/spectrwm/scripts/volume-spectrwm.sh b/stow_home/spectrwm/.config/spectrwm/scripts/volume-spectrwm.sh new file mode 100755 index 0000000..e38ce60 --- /dev/null +++ b/stow_home/spectrwm/.config/spectrwm/scripts/volume-spectrwm.sh @@ -0,0 +1,19 @@ +#!/bin/bash +volumecontrol() { + pkill -SIGTRAP baraction.sh + case $1 in + increase) + amixer set Master 5%+ + ;; + ecrease) + amixer set Master 5%- + ;; + toggle) + amixer set Master toggle + ;; + *) + ;; + esac; +} + +volumecontrol $1 diff --git a/stow_home/spectrwm/.config/spectrwm/scripts/workspace-windows.sh b/stow_home/spectrwm/.config/spectrwm/scripts/workspace-windows.sh new file mode 100755 index 0000000..40b2978 --- /dev/null +++ b/stow_home/spectrwm/.config/spectrwm/scripts/workspace-windows.sh @@ -0,0 +1,6 @@ +#!/bin/bash +ws_icon="$(wmctrl -d | grep "*" | awk '{print $9}')" +windows_number="$(wmctrl -l | grep -v panel | awk '{print $2}'))" +current_ws="$(wmctrl -d | grep '*' | awk '{print $1}')" +windows_in_ws="$(echo -e "$windows_number" | grep $current_ws | wc -l)" +echo -e "[$ws_icon ] [$windows_in_ws]" diff --git a/stow_home/spectrwm/.config/spectrwm/spectrwm.conf b/stow_home/spectrwm/.config/spectrwm/spectrwm.conf new file mode 100644 index 0000000..5e96c46 --- /dev/null +++ b/stow_home/spectrwm/.config/spectrwm/spectrwm.conf @@ -0,0 +1,233 @@ + # Initial setup config +workspace_limit = 9 +focus_mode = manual +focus_close = previous +focus_close_wrap = 0 +focus_default = last +spawn_position = next +workspace_clamp = 1 +warp_focus = 0 +warp_pointer = 0 + + # Window decorations & boundaries +border_width = 2 +color_focus = rgb:d0/87/70 +color_unfocus = rgb:5e/81/ac +region_padding = 0 +tile_gap = 0 +boundary_width = 50 + + # Bar configuration +bar_enabled = 1 +bar_border_width = 1 +bar_border[1] = rgb:18/18/18 +bar_border_unfocus[1] = rgb:18/18/18 +bar_color[1] = rgb:2e/34/40,rgb:eb/cb/8b,rgb:a3/be/8c,rgb:bf/61/6a,rgb:b4/8e/ad,rgb:88/c0/d0,rgb:d0/87/70,rgb:3b/42/52,rgb:4c/56/6a +bar_color_selected[1] = rgb:88/c0/d0 +bar_font_color[1] = rgb:ec/ef/f4,rgb:2e/34/40,rgb:2e/34/40,rgb:eb/cb/8b,rgb:a3/be/8c,rgb:bf/61/6a,rgb:b4/8e/ad,rgb:88/c0/d0,rgb:d0/87/70,rgb:3b/42/52,rgb:4c/56/6a +bar_font = Blex Mono Nerd Font:pixelsize=15:antialias=true +bar_action = ~/.config/spectrwm/baraction.sh +bar_action_expand = 1 +bar_justify = right +bar_format = +|L +@bg=0;+S +L +@bg=0; +@bg=8; +C +@fg=0; +|2R +A +@bg=0;+@fg=0; %a, %b %d %R +< +bar_at_bottom = 0 +workspace_indicator = listall,markcurrent +stack_enabled = 1 +clock_enabled = 1 +clock_format = %a, %b %d %R +iconic_enabled = 1 +maximize_hide_bar = 0 +window_class_enabled = 1 +window_instance_enabled = 1 +window_name_enabled = 0 +verbose_layout = 0 +urgent_enabled = 1 +urgent_collapse = 0 + + # Autorunning applications +autorun = ws[1]:nitrogen --set-auto ~/Pictures/walls/paranoid.jpg & +autorun = ws[1]:setxkbmap -layout latam & +autorun = ws[1]:alacritty +autorun = ws[1]:volumeicon +autorun = ws[1]:xfce4-power-manager +autorun = ws[1]:syncthing +autorun = ws[1]:nm-applet & +autorun = ws[1]:lxpolkit & +autorun = ws[1]:picom --experimental-backends --backend glx --blur-method 'dual_kawase' --blur-strength 6 + + # Workspace names and modkey +layout = ws[1]:4:0:0:0:vertical +name = ws[1]:WEB +name = ws[2]:DEV +name = ws[3]:MAIL +name = ws[4]:FILE +name = ws[5]:CHAT +name = ws[6]:SSH +name = ws[7]:EMACS +name = ws[8]:TERM +name = ws[9]:ETC +# ", " ", " ", " ", " ", " ", " ", " ", " ", " " +modkey = Mod4 + + # Quirks and custom per program behavior +quirk[firefox:Dialog] = FLOAT + MINIMALBORDER + TRANSSZ +quirk[Image Lounge] = FLOAT +quirk[firefox] = IGNOREPID + TRANSSZ + ANYWHERE +quirk[Thunderbird] = ANYWHERE + IGNORESPAWNWS + IGNOREPID + TRANSSZ +quirk[Claws-mail] = ANYWHERE + IGNORESPAWNWS + IGNOREPID + TRANSSZ +quirk[Xarchiver] = ANYWHERE + IGNORESPAWNWS + IGNOREPID + TRANSSZ +quirk[Lxappearance] = FLOAT +quirk[Pavucontrol] = FLOAT +quirk[Volumeicon] = FLOAT + ANYWHERE + IGNORESPAWNWS + IGNOREPID +quirk[discord:Discord Updater] = FLOAT + IGNOREPID +quirk[stalonetray] = FLOAT + ANYWHERE +quirk[trayer] = FLOAT + ANYWHERE + NOFOCUSCYCLE + MINIMALBORDER + NOFOCUSONMAP +quirk[Lxpolkit] = FLOAT + IGNOREPID +FOCUSPREV + IGNORESPAWNWS +quirk[Xfce4-power-manager-settings] = FLOAT + ANYWHERE +quirk[Nm-connection-editor] = ANYWHERE + IGNORESPAWNWS + FLOAT +quirk[Pcmanfm] = ANYWHERE + IGNORESPAWNWS +quirk[Thunar] = ANYWHERE + IGNORESPAWNWS + + # General keybindings +bind[] = MOD+x +bind[] = MOD+v +bind[bar_toggle] = MOD+b +bind[bar_toggle_ws] = MOD+Shift+b +bind[cycle_layout] = MOD+space +bind[flip_layout] = MOD+Shift+backslash +bind[float_toggle] = MOD+t +bind[focus_main] = MOD+m +bind[focus_next] = MOD+j +bind[focus_next] = MOD+Tab +bind[focus_prev] = MOD+k +bind[focus_prev] = MOD+Shift+Tab +bind[focus_urgent] = MOD+u +bind[height_grow] = MOD+Shift+equal +bind[height_shrink] = MOD+Shift+minus +bind[iconify] = MOD+w +bind[initscr] = MOD+Shift+i +bind[lock] = MOD+Shift+Delete +bind[master_add] = MOD+Shift+comma +bind[master_del] = MOD+Shift+period +bind[master_grow] = MOD+l +bind[master_shrink] = MOD+h +bind[maximize_toggle] = MOD+e +bind[move_down] = MOD+Shift+bracketright +bind[move_left] = MOD+bracketleft +bind[move_right] = MOD+bracketright +bind[move_up] = MOD+Shift+bracketleft +bind[mvrg_1] = MOD+Shift+KP_End +bind[mvrg_2] = MOD+Shift+KP_Down +bind[mvrg_3] = MOD+Shift+KP_Next +bind[mvrg_4] = MOD+Shift+KP_Left +bind[mvrg_5] = MOD+Shift+KP_Begin +bind[mvrg_6] = MOD+Shift+KP_Right +bind[mvrg_7] = MOD+Shift+KP_Home +bind[mvrg_8] = MOD+Shift+KP_Up +bind[mvrg_9] = MOD+Shift+KP_Prior +bind[mvws_1] = MOD+Shift+1 +bind[mvws_2] = MOD+Shift+2 +bind[mvws_3] = MOD+Shift+3 +bind[mvws_4] = MOD+Shift+4 +bind[mvws_5] = MOD+Shift+5 +bind[mvws_6] = MOD+Shift+6 +bind[mvws_7] = MOD+Shift+7 +bind[mvws_8] = MOD+Shift+8 +bind[mvws_9] = MOD+Shift+9 +bind[mvws_10] = MOD+Shift+0 +bind[mvws_11] = MOD+Shift+F1 +bind[mvws_12] = MOD+Shift+F2 +bind[mvws_13] = MOD+Shift+F3 +bind[mvws_14] = MOD+Shift+F4 +bind[mvws_15] = MOD+Shift+F5 +bind[mvws_16] = MOD+Shift+F6 +bind[mvws_17] = MOD+Shift+F7 +bind[mvws_18] = MOD+Shift+F8 +bind[mvws_19] = MOD+Shift+F9 +bind[mvws_20] = MOD+Shift+F10 +bind[mvws_21] = MOD+Shift+F11 +bind[mvws_22] = MOD+Shift+F12 +bind[name_workspace] = MOD+Shift+slash +bind[quit] = MOD+Control+q +bind[raise_toggle] = MOD+Control+r +bind[restart] = MOD+Shift+r +bind[rg_1] = MOD+KP_End +bind[rg_2] = MOD+KP_Down +bind[rg_3] = MOD+KP_Next +bind[rg_4] = MOD+KP_Left +bind[rg_5] = MOD+KP_Begin +bind[rg_6] = MOD+KP_Right +bind[rg_7] = MOD+KP_Home +bind[rg_8] = MOD+KP_Up +bind[rg_9] = MOD+KP_Prior +bind[rg_next] = MOD+period +bind[rg_prev] = MOD+comma +bind[screenshot_all] = MOD+s +bind[screenshot_wind] = MOD+Shift+s +bind[search_win] = MOD+f +bind[search_workspace] = MOD+slash +bind[stack_dec] = MOD+Shift+period +bind[stack_inc] = MOD+Shift+comma +bind[stack_reset] = MOD+Shift+space +bind[swap_next] = MOD+Shift+j +bind[swap_prev] = MOD+Shift+k +bind[uniconify] = MOD+Shift+w +bind[version] = MOD+Shift+v +bind[width_grow] = MOD+equal +bind[width_shrink] = MOD+minus +bind[wind_del] = MOD+q +bind[ws_1] = MOD+1 +bind[ws_2] = MOD+2 +bind[ws_3] = MOD+3 +bind[ws_4] = MOD+4 +bind[ws_5] = MOD+5 +bind[ws_6] = MOD+6 +bind[ws_7] = MOD+7 +bind[ws_8] = MOD+8 +bind[ws_9] = MOD+9 +bind[ws_10] = MOD+0 +bind[ws_11] = MOD+F1 +bind[ws_12] = MOD+F2 +bind[ws_13] = MOD+F3 +bind[ws_14] = MOD+F4 +bind[ws_15] = MOD+F5 +bind[ws_16] = MOD+F6 +bind[ws_17] = MOD+F7 +bind[ws_18] = MOD+F8 +bind[ws_19] = MOD+F9 +bind[ws_20] = MOD+F10 +bind[ws_21] = MOD+F11 +bind[ws_22] = MOD+F12 +bind[ws_next_all] = MOD+Right +bind[ws_next] = MOD+Up +bind[ws_next_move] = MOD+Shift+Right +bind[ws_prev_all] = MOD+Left +bind[ws_prev] = MOD+Down +bind[ws_prev_move] = MOD+Shift+Left +bind[ws_prior] = MOD+a + + # Custom program keybindings +program[Discord] = discord +bind[Discord] = MOD+mod1+d +program[term] = alacritty +bind[term] = MOD+Return +program[rofi_run] = rofi -show run +bind[rofi_run] = MOD+r +program[post] = ~/.config/rofi/scripts/qpost.sh +bind[post] = MOD+mod1+p +program[rofi_pass] = rofi-pass +bind[rofi_pass] = MOD+mod1+k +program[tab_switch] = rofi -show window +bind[tab_switch] = Mod1+Tab +program[rofi] = rofi -show drun +bind[rofi] = MOD+p +program[power_menu] = ~/.config/rofi/scripts/power-menu.sh +bind[power_menu] = MOD+Shift+q +program[screenshot] = flameshot gui +bind[screenshot] = MOD+Shift+s +program[firefox] = firefox +bind[firefox] = MOD+Mod1+b +program[pcmanfm] = pcmanfm +bind[pcmanfm] = MOD+Mod1+f +program[pulsemixer] = alacritty -e pulsemixer +bind[pulsemixer] = MOD+mod1+v