diff --git a/LICENSE b/LICENSE index be03f88..c128092 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 purhan +Copyright (c) 2021 purhan Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/src/.bash_profile b/src/.bash_profile new file mode 120000 index 0000000..aa7da3a --- /dev/null +++ b/src/.bash_profile @@ -0,0 +1 @@ +.profile \ No newline at end of file diff --git a/src/.bashrc b/src/.bashrc index ad7153d..9f6800d 100644 --- a/src/.bashrc +++ b/src/.bashrc @@ -102,8 +102,13 @@ alias more=less alias ll='ls -alF' alias la='ls -A' alias l='ls -CF' +alias nv='nvim' # switch between shells alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'" alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'" alias tofish="sudo chsh $USER -s /bin/fish && echo 'Now log out.'" +source "$HOME/.cargo/env" + +[ -f ~/.fzf.bash ] && source ~/.fzf.bash + diff --git a/src/.config/awesome/configuration/apps.lua b/src/.config/awesome/configuration/apps.lua index fd51585..4e28785 100644 --- a/src/.config/awesome/configuration/apps.lua +++ b/src/.config/awesome/configuration/apps.lua @@ -4,10 +4,7 @@ local beautiful = require('beautiful') -- Thanks to jo148 on github for making rofi dpi aware! local with_dpi = require('beautiful').xresources.apply_dpi local get_dpi = require('beautiful').xresources.get_dpi -local rofi_command = 'env /usr/bin/rofi -dpi ' .. get_dpi() .. ' -width ' .. with_dpi(100) .. - ' -show drun -display-drun -theme ' .. filesystem.get_configuration_dir() .. - '/configuration/rofi.rasi -icon-theme ' .. beautiful.icon_theme .. - ' -run-command "/bin/bash -c -i \'shopt -s expand_aliases; {cmd}\'"' +local rofi_command = 'env /usr/bin/rofi -show drun -display-drun -run-command "/bin/bash -c -i \'shopt -s expand_aliases; {cmd}\'"' return { -- List of apps to start by default on some actions @@ -15,7 +12,7 @@ return { terminal = 'kitty', rofi = rofi_command, lock = 'i3lock-fancy', - quake = 'kitty', + splash = 'kitty -T SplashTerminal -o background_opacity=0.95', power_command = '~/.config/awesome/configuration/utils/rofi-power', screenshot = '~/.config/awesome/configuration/utils/screenshot -m', region_screenshot = '~/.config/awesome/configuration/utils/screenshot -r', @@ -26,13 +23,17 @@ return { files = 'nautilus', power_manager = 'gnome-power-statistics' }, - -- List of apps to start once on start-up - run_on_start_up = {'~/.config/awesome/configuration/awspawn', - 'compton --config ' .. filesystem.get_configuration_dir() .. '/configuration/compton.conf', - 'nm-applet --indicator', 'ibus-daemon --xim --daemonize', 'scream-start', 'numlockx on', - '/usr/lib/xfce-polkit/xfce-polkit & eval $(gnome-keyring-daemon -s --components=pkcs11,secrets,ssh,gpg)', -- credential manager - 'blueman-tray', - 'xinput set-prop "ETPS/2 Elantech Touchpad" "libinput Natural Scrolling Enabled" 1', - 'xinput set-prop "ETPS/2 Elantech Touchpad" "libinput Tapping Enabled" 1'} + -- List of commands to start once on start-up + run_on_start_up = { + '~/.config/awesome/configuration/awspawn', + 'compton', + 'nm-applet --indicator', + 'nitrogen --restore', + 'ibus-daemon --xim --daemonize', + 'scream-start', + 'numlockx on', + '/usr/lib/xfce-polkit/xfce-polkit & eval $(gnome-keyring-daemon -s --components=pkcs11,secrets,ssh,gpg)', -- credential manager + 'blueman-tray' + } } diff --git a/src/.config/awesome/configuration/client/rules.lua b/src/.config/awesome/configuration/client/rules.lua index d09de97..fa85474 100644 --- a/src/.config/awesome/configuration/client/rules.lua +++ b/src/.config/awesome/configuration/client/rules.lua @@ -22,13 +22,6 @@ awful.rules.rules = {{ maximized_horizontal = false, maximized_vertical = false } -}, { - rule_any = { - instance = {"QuakeTerminal"} - }, - properties = { - skip_decoration = true - } }, { rule_any = { type = {'dialog'}, diff --git a/src/.config/awesome/configuration/keys/global.lua b/src/.config/awesome/configuration/keys/global.lua index 2127f02..5d9dccc 100644 --- a/src/.config/awesome/configuration/keys/global.lua +++ b/src/.config/awesome/configuration/keys/global.lua @@ -17,19 +17,22 @@ awful.key({modkey}, 'h', hotkeys_popup.show_help, { description = 'show help', group = 'awesome' }), -- Tag browsing -awful.key({modkey}, 'w', awful.tag.viewprev, { - description = 'view previous', +awful.key({modkey}, 'Left', function() + awful.tag.viewprev() + _G._splash_to_current_tag() +end, { + description = 'go to previous workspace', group = 'tag' -}), awful.key({modkey}, 's', awful.tag.viewnext, { - description = 'view next', +}), awful.key({modkey}, 'Right', function() + awful.tag.viewnext() + _G._splash_to_current_tag() +end, { + description = 'go to next workspace', group = 'tag' -}), awful.key({altkey, 'Control'}, 'Left', awful.tag.viewprev, { - description = 'view previous', - group = 'tag' -}), awful.key({altkey, 'Control'}, 'Right', awful.tag.viewnext, { - description = 'view next', - group = 'tag' -}), awful.key({modkey}, 'Escape', awful.tag.history.restore, { +}), awful.key({modkey}, 'Escape', function() + awful.tag.history.restore() + _G._splash_to_current_tag() +end, { description = 'go back', group = 'tag' }), -- Default client focus @@ -48,27 +51,13 @@ end, { end, { description = 'show rofi menu', group = 'awesome' -}), awful.key({modkey}, 'd', function() - local flag = false - for _, c in ipairs(mouse.screen.selected_tag:clients()) do - if c.minimized == true then - flag = true - end - c.minimized = true - end - for _, c in ipairs(mouse.screen.selected_tag:clients()) do - if flag == true then - c.minimized = false - end - end +}), awful.key({modkey}, 'u', function() + awful.client.urgent.jumpto() + _G._splash_to_current_tag() end, { - description = 'minimize all clients', - group = 'awesome' -}), awful.key({modkey}, 'u', awful.client.urgent.jumpto, { description = 'jump to urgent client', group = 'client' }), awful.key({altkey}, 'Tab', function() - -- awful.client.focus.history.previous() awful.client.focus.byidx(1) if _G.client.focus then _G.client.focus:raise() @@ -76,8 +65,19 @@ end, { end, { description = 'switch to next window', group = 'client' +}), awful.key({modkey}, 'm', function() + focus = not _G.client.focus + if not focus then + _G.client.focus.minimized = true + else + for _, c in ipairs(mouse.screen.selected_tag:clients()) do + c.minimized = false + end + end +end, { + description = 'minimize window in focus / unminimize all', + group = 'client' }), awful.key({altkey, 'Shift'}, 'Tab', function() - -- awful.client.focus.history.previous() awful.client.focus.byidx(-1) if _G.client.focus then _G.client.focus:raise() @@ -115,7 +115,7 @@ end, { end, { description = 'open a browser', group = 'launcher' -}), awful.key({modkey}, 't', function() +}), awful.key({modkey}, 'Return', function() awful.util.spawn_with_shell(apps.default.terminal) end, { description = 'open a terminal', @@ -139,7 +139,7 @@ end, { end, { description = 'toggle gaps', group = 'awesome' -}), awful.key({modkey, 'Shift'}, 'p', function() +}), awful.key({modkey}, 'p', function() awful.util.spawn_with_shell(apps.default.power_command) end, { description = 'end session menu', @@ -244,10 +244,15 @@ end, { end, { description = 'restore minimized', group = 'client' -}), awful.key({altkey, 'Control'}, 'k', function() - _G.toggle_quake() +}), awful.key({modkey}, 'k', function() + _G.toggle_splash() end, { - description = 'dropdown application', + description = 'toggle splash terminal', + group = 'launcher' +}), awful.key({modkey}, 'j', function() + _G.toggle_splash_height() +end, { + description = 'toggle splash terminal height', group = 'launcher' }), awful.key({}, 'XF86MonBrightnessUp', function() awful.spawn('xbacklight -inc 10') @@ -345,6 +350,7 @@ for i = 1, 9 do local tag = screen.tags[i] if tag then tag:view_only() + _G._splash_to_current_tag() end end, descr_view), -- Toggle tag display. awful.key({modkey, 'Control'}, '#' .. i + 9, function() diff --git a/src/.config/awesome/configuration/rofi.rasi b/src/.config/awesome/configuration/rofi.rasi index 4833f14..e158e40 100644 --- a/src/.config/awesome/configuration/rofi.rasi +++ b/src/.config/awesome/configuration/rofi.rasi @@ -118,7 +118,7 @@ element selected.normal { background-color: @selected-normal-background; text-color: @selected-normal-foreground; padding: 16px; - border: 0 0 0 5px solid; + border: 0 0 0 0 solid; border-color: @active-background; } @@ -145,4 +145,4 @@ element alternate.urgent { element alternate.active { background-color: @active-background; text-color: @active-foreground; -} \ No newline at end of file +} diff --git a/src/.config/awesome/configuration/tags.lua b/src/.config/awesome/configuration/tags.lua new file mode 100644 index 0000000..0d700f6 --- /dev/null +++ b/src/.config/awesome/configuration/tags.lua @@ -0,0 +1,37 @@ +local awful = require('awful') +local beautiful = require('beautiful') +local gears = require('gears') +local apps = require('configuration.apps') +local dpi = require('beautiful').xresources.apply_dpi + +local tags = { + {text = 'web', type = 'web', defaultApp = apps.default.browser, screen = 1}, + {text = 'dev', type = 'dev', defaultApp = apps.default.editor, screen = 1}, + { + text = 'term', + type = 'term', + defaultApp = apps.default.terminal, + screen = 1 + }, + {text = 'file', type = 'file', defaultApp = apps.default.files, screen = 1}, + {text = 'chat', type = 'chat', defaultApp = apps.default.social, screen = 1}, + {text = 'misc', type = 'misc', defaultApp = apps.default.rofi, screen = 1} +} + +awful.layout.layouts = { + awful.layout.suit.tile, awful.layout.suit.max, awful.layout.suit.floating +} + +awful.screen.connect_for_each_screen(function(s) + for i, tag in pairs(tags) do + awful.tag.add(tag.text, { + icon = tag.icon, + icon_only = false, + layout = awful.layout.suit.tile, + gap = beautiful.gaps, + screen = s, + defaultApp = tag.defaultApp, + selected = i == 1 + }) + end +end) diff --git a/src/.config/awesome/configuration/awspawn b/src/.config/awesome/configuration/utils/autostart similarity index 84% rename from src/.config/awesome/configuration/awspawn rename to src/.config/awesome/configuration/utils/autostart index be2130f..eb626fb 100755 --- a/src/.config/awesome/configuration/awspawn +++ b/src/.config/awesome/configuration/utils/autostart @@ -6,15 +6,11 @@ # Only add applications/scripts without parameters here # (if you want to apply parameters then use a script file!) -# List of applications to run -# the script $HOME/.config/awesomestart -# is intended to be a copy of this file -# to allow out of tree autostart programs APPS=( # keepassxc # kdeconnect-indicator radeon-profile - $HOME/.config/awesomestart + $HOME/.config/utils/awesomestart ) # Some applications start child applications that need to be killed on reload KILL=( diff --git a/src/.config/awesome/configuration/utils/rofi-power b/src/.config/awesome/configuration/utils/rofi-power index 8674f38..b626d30 100755 --- a/src/.config/awesome/configuration/utils/rofi-power +++ b/src/.config/awesome/configuration/utils/rofi-power @@ -5,11 +5,11 @@ # 2016 Oliver Kraitschy - http://okraits.de -OPTIONS="Power-off\nExit\nReboot\nSuspend\nHibernate" +OPTIONS="Poweroff\nExit\nReboot\nSuspend\nHibernate" config_path=$(dirname "$0") -LAUNCHER="rofi -dmenu -show-icons -icon-theme papirus -theme $config_path/../rofi.rasi" +LAUNCHER="rofi -dmenu -i" USE_LOCKER="false" LOCKER="i3lock-fancy" @@ -21,7 +21,7 @@ case $option in Reboot) systemctl reboot ;; - Power-off) + Poweroff) systemctl poweroff ;; Suspend) diff --git a/src/.config/awesome/layout/bottom-bar.lua b/src/.config/awesome/layout/bottom-bar.lua new file mode 100644 index 0000000..e42731e --- /dev/null +++ b/src/.config/awesome/layout/bottom-bar.lua @@ -0,0 +1,37 @@ +local beautiful = require('beautiful') +local wibox = require('wibox') +local TaskList = require('widget.task-list') +local dpi = require('beautiful').xresources.apply_dpi + +local BottomBar = function(s, offset) + + -- BOTTOM BAR + -- ======= + local panel_height = dpi(16) + local panel = wibox({ + ontop = false, + screen = s, + height = panel_height, + width = s.geometry.width, + x = s.geometry.x, + y = s.geometry.height - panel_height, + stretch = false, + bg = beautiful.primary.hue_100, + fg = beautiful.fg_normal, + }) + + panel:struts({ + bottom = panel.height + }) + + panel:setup{ + layout = wibox.layout.align.horizontal, + nil, + TaskList(s), + nil, + } + + return panel +end + +return BottomBar diff --git a/src/.config/awesome/layout/init.lua b/src/.config/awesome/layout/init.lua index 5111828..34386d5 100644 --- a/src/.config/awesome/layout/init.lua +++ b/src/.config/awesome/layout/init.lua @@ -1,5 +1,6 @@ local awful = require('awful') local top_bar = require('layout.top-bar') +local bottom_bar = require('layout.bottom-bar') local key_grabber @@ -7,8 +8,10 @@ local key_grabber awful.screen.connect_for_each_screen(function(s) if s.index == 1 then s.top_bar = top_bar(s, true) + s.bottom_bar = bottom_bar(s, true) else s.top_bar = top_bar(s, false) + s.bottom_bar = bottom_bar(s, false) end end) @@ -18,6 +21,7 @@ function updateBarsVisibility() if s.selected_tag then local fullscreen = s.selected_tag.fullscreenMode s.top_bar.visible = not fullscreen + s.bottom_bar.visible = not fullscreen end end end diff --git a/src/.config/awesome/layout/top-bar.lua b/src/.config/awesome/layout/top-bar.lua index 3fd5a36..180b0ff 100644 --- a/src/.config/awesome/layout/top-bar.lua +++ b/src/.config/awesome/layout/top-bar.lua @@ -2,86 +2,167 @@ local awful = require('awful') local beautiful = require('beautiful') local clickable_container = require('widget.material.clickable-container') local mat_icon_button = require('widget.material.icon-button') +local separators = require('widget.material.separator') +local markup = require('widget.material.markup') local wibox = require('wibox') local TagList = require('widget.tag-list') -local TaskList = require('widget.task-list') local gears = require('gears') -local icons = require('theme.icons') local dpi = require('beautiful').xresources.apply_dpi +local table = awful.util.table or gears.table -local separator = wibox.widget { - orientation = 'vertical', - forced_width = dpi(2), - opacity = 0.5, - widget = wibox.widget.separator -} +-- Separators +local arrow = separators.arrow_left +local function create_arrow(mywidget, bgcolor, fgcolor) + return (wibox.container.background( + wibox.widget { + arrow(fgcolor, bgcolor), + mywidget, + arrow(bgcolor, fgcolor), + spacing = dpi(4), + layout = wibox.layout.fixed.horizontal + }, + bgcolor + ) +) +end + +-- Create Icons +local function create_icon(label, icon_color) + return (wibox.widget { + wibox.widget{ + text = label, + font = beautiful.icon_font, + widget = wibox.widget.textbox + }, + fg = icon_color, + widget = wibox.container.background + }) +end local TopBar = function(s, offset) -- LAYOUT BOX -- ========== - local LayoutBox = require('widget.layoutbox') + local function update_txt_layoutbox(s) + -- Writes a string representation of the current layout in a textbox widget + local txt_l = beautiful["layout_txt_" .. awful.layout.getname(awful.layout.get(s))] or "" + s.layoutbox:set_text(txt_l) + end - -- BATTERY - -- ======= - local battery_widget = require('widget.battery') + s.layoutbox = wibox.widget.textbox(beautiful["layout_txt_" .. awful.layout.getname(awful.layout.get(s))]) + s.layoutbox.font = beautiful.icon_font + awful.tag.attached_connect_signal(s, "property::selected", function () update_txt_layoutbox(s) end) + awful.tag.attached_connect_signal(s, "property::layout", function () update_txt_layoutbox(s) end) + s.layoutbox:buttons(table.join( + awful.button({}, 1, function() awful.layout.inc(1) end), + awful.button({}, 2, function () awful.layout.set( awful.layout.layouts[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))) -- SYSTEM TRAY -- =========== local systray = wibox.widget.systray() systray:set_horizontal(true) - -- TASK LIST - -- ========= - local task_list = wibox.widget { - nil, - wibox.container.margin(TaskList(s), dpi(2), dpi(2), dpi(3), dpi(3)), - nil, - layout = wibox.layout.align.horizontal - } - -- SYSTEM DETAILS -- ============== - local volume_widget = require('widget.volume.volume-percentage') - local date_widget = require('widget.date') + local volume_widget = require('widget.volume') + local battery_widget = require('widget.battery') local clock_widget = require('widget.clock') local mem_widget = require('widget.memory') local cpu_widget = require('widget.cpu') + local temprature_widget = require('widget.temprature') + local storage_widget = require('widget.storage') + local net = require('widget.net') + local net_sent = net({ + settings = function() + widget:set_markup(markup.font(beautiful.font, net_now.sent)) + end + }) + local net_recieved = net({ + settings = function() + widget:set_markup(markup.font(beautiful.font, net_now.received)) + end + }) local system_details = wibox.widget { - wibox.widget { - wibox.container.background(systray, beautiful.primary.hue_800), - wibox.container.background(battery_widget, beautiful.primary.hue_800), - separator, - wibox.container.background(mem_widget, beautiful.primary.hue_800), - separator, - wibox.container.background(cpu_widget, beautiful.primary.hue_800), - separator, - wibox.container.background(volume_widget, beautiful.primary.hue_800), - separator, - wibox.container.background(date_widget, beautiful.primary.hue_800), - separator, - wibox.container.background(clock_widget, beautiful.primary.hue_800), + -- Systray + systray, + create_arrow(nil, beautiful.primary.hue_200, beautiful.primary.hue_100), + -- Internet Speed + wibox.widget{ + create_icon('', beautiful.accent.hue_200), + net_sent.widget, + create_icon('', beautiful.accent.hue_300), + net_recieved.widget, + spacing = dpi(4), + layout = wibox.layout.fixed.horizontal + }, + -- Battery + create_arrow (battery_widget, beautiful.primary.hue_200, beautiful.primary.hue_100), + -- Memory + create_icon('', beautiful.accent.hue_500), + mem_widget, + -- CPU + create_arrow(wibox.widget{ + create_icon('﬙', beautiful.accent.hue_600), + cpu_widget, + spacing = dpi(4), + layout = wibox.layout.fixed.horizontal + }, beautiful.primary.hue_200, beautiful.primary.hue_100), + -- Temprature + wibox.widget{ + create_icon('﨎', beautiful.accent.hue_400), + temprature_widget, + spacing = dpi(4), + layout = wibox.layout.fixed.horizontal + }, + -- Volume + create_arrow(volume_widget, beautiful.primary.hue_200, beautiful.primary.hue_100), + -- Storage + wibox.widget{ + create_icon('', beautiful.accent.hue_200), + storage_widget, + spacing = dpi(4), + layout = wibox.layout.fixed.horizontal + }, + wibox.widget{ + -- Calendar / Clock + create_arrow(wibox.widget{ + create_icon('', beautiful.accent.hue_400), + clock_widget, + spacing = dpi(4), + layout = wibox.layout.fixed.horizontal + }, beautiful.primary.hue_200, beautiful.primary.hue_100), + -- Layout + wibox.widget { + arrow(beautiful.primary.hue_100, beautiful.accent.hue_200), + wibox.widget{ + wibox.container.margin(s.layoutbox, dpi(4), dpi(4), dpi(0), dpi(0)), + fg = beautiful.primary.hue_100, + bg = beautiful.accent.hue_200, + widget = wibox.container.background + }, + layout = wibox.layout.fixed.horizontal + }, + layout = wibox.layout.fixed.horizontal, + }, + spacing = dpi(4), layout = wibox.layout.fixed.horizontal - }, - bg = beautiful.primary.hue_900, - widget = wibox.container.background - } - - local calendar = require('widget.calendar') - calendar:attach(date_widget) + } -- TOP BAR -- ======= local panel = wibox({ ontop = false, screen = s, - height = dpi(24), + height = dpi(20), width = s.geometry.width, x = s.geometry.x, y = s.geometry.y, stretch = false, - bg = beautiful.primary.hue_900, - fg = beautiful.fg_normal + bg = beautiful.primary.hue_100, + fg = beautiful.fg_normal, }) panel:struts({ @@ -90,14 +171,9 @@ local TopBar = function(s, offset) panel:setup{ layout = wibox.layout.align.horizontal, - spacing = dpi(0), TagList(s), - task_list, - wibox.widget { - wibox.container.margin(system_details, dpi(2), dpi(2), dpi(3), dpi(3)), - LayoutBox(s), - layout = wibox.layout.fixed.horizontal - } + nil, + system_details, } return panel diff --git a/src/.config/awesome/module/quake-terminal.lua b/src/.config/awesome/module/splash-terminal.lua similarity index 50% rename from src/.config/awesome/module/quake-terminal.lua rename to src/.config/awesome/module/splash-terminal.lua index 90ce5f3..b522970 100644 --- a/src/.config/awesome/module/quake-terminal.lua +++ b/src/.config/awesome/module/splash-terminal.lua @@ -1,5 +1,5 @@ local awful = require('awful') -local app = require('configuration.apps').default.quake +local app = require('configuration.apps').default.splash local dpi = require('beautiful').xresources.apply_dpi local beautiful = require('beautiful') local screen = awful.screen.focused() @@ -7,42 +7,56 @@ local screen = awful.screen.focused() -- Theme beautiful.init(require('theme')) -local quake_id = 'notnil' -local quake_client +local splash_id = 'notnil' +local splash_client local opened = false + function create_shell() - quake_id = awful.spawn.with_shell("exec -a QuakeTerminal " .. app) + splash_id = awful.spawn.with_shell(app) end -function open_quake() - quake_client.hidden = false +-- Dirty hack to prevent splash from showing up in occupied tags +function _splash_to_current_tag() + if splash_client then + splash_client:move_to_tag(screen.selected_tag) + end end -function close_quake() - quake_client.hidden = true +function open_splash() + splash_client.hidden = false end -toggle_quake = function() +function close_splash() + splash_client.hidden = true +end + +toggle_splash_height = function() + if splash_client and opened then + splash_client.maximized_vertical = not splash_client.maximized_vertical + end +end + +toggle_splash = function() opened = not opened - if not quake_client then + if not splash_client then create_shell() else if opened then - open_quake() - client.focus = quake_client - quake_client:raise() + open_splash() + client.focus = splash_client + splash_client:raise() else - close_quake() + close_splash() end end end _G.client.connect_signal('manage', function(c) - if (c.pid == quake_id) then - quake_client = c + if (c.pid == splash_id) then + splash_client = c c.x = c.screen.geometry.x c.height = (c.screen.geometry.height / 5) * 3 - c.y = c.screen.geometry.height - c.height - beautiful.border_width + c.y = c.screen.geometry.height - c.height - beautiful.border_width - dpi(16) c.floating = true c.skip_taskbar = true c.skip_decoration = true @@ -50,17 +64,16 @@ _G.client.connect_signal('manage', function(c) c.floating = true c.above = true c.sticky = true - c.type = 'dock' + c.type = 'splash' c.hidden = not opened - c.maximized_horizontal = true c.border_width = beautiful.border_width - c:move_to_tag(screen.tags[3]) + c.maximized_horizontal = true end end) _G.client.connect_signal('unmanage', function(c) - if (c.pid == quake_id) then + if (c.pid == splash_id) then opened = false - quake_client = nil + splash_client = nil end end) diff --git a/src/.config/awesome/rc.lua b/src/.config/awesome/rc.lua index d2ba9d7..5f333e8 100644 --- a/src/.config/awesome/rc.lua +++ b/src/.config/awesome/rc.lua @@ -14,29 +14,13 @@ require('layout') require('module.notifications') require('module.auto-start') require('module.decorate-client') -require('module.quake-terminal') +require('module.splash-terminal') -- Setup all configurations require('configuration.client') require('configuration.tags') _G.root.keys(require('configuration.keys.global')) --- Create a wibox for each screen and add it -awful.screen.connect_for_each_screen(function(s) - -- If wallpaper is a function, call it with the screen - if beautiful.wallpaper then - if type(beautiful.wallpaper) == "string" then - if beautiful.wallpaper:sub(1, #"#") == "#" then - gears.wallpaper.set(beautiful.wallpaper) - elseif beautiful.wallpaper:sub(1, #"/") == "/" then - gears.wallpaper.maximized(beautiful.wallpaper, s) - end - else - beautiful.wallpaper(s) - end - end -end) - -- Signal function to execute when a new client appears. _G.client.connect_signal('manage', function(c) -- Set the windows at the slave, @@ -52,9 +36,9 @@ _G.client.connect_signal('manage', function(c) end) -- Enable sloppy focus, so that focus follows mouse. --- _G.client.connect_signal('mouse::enter', function(c) --- c:emit_signal('request::activate', 'mouse_enter', {raise = true}) --- end) +_G.client.connect_signal('mouse::enter', function(c) + c:emit_signal('request::activate', 'mouse_enter', {raise = true}) +end) -- Make the focused window have a glowing border _G.client.connect_signal('focus', function(c) @@ -63,3 +47,4 @@ end) _G.client.connect_signal('unfocus', function(c) c.border_color = beautiful.border_normal end) + diff --git a/src/.config/awesome/requirements/fonts/Fira Code Bold Nerd Font Complete Mono.ttf b/src/.config/awesome/requirements/fonts/Fira Code Bold Nerd Font Complete Mono.ttf deleted file mode 100644 index 6ad2054..0000000 Binary files a/src/.config/awesome/requirements/fonts/Fira Code Bold Nerd Font Complete Mono.ttf and /dev/null differ diff --git a/src/.config/awesome/requirements/fonts/Fira Code Light Nerd Font Complete Mono.ttf b/src/.config/awesome/requirements/fonts/Fira Code Light Nerd Font Complete Mono.ttf deleted file mode 100644 index 29beae2..0000000 Binary files a/src/.config/awesome/requirements/fonts/Fira Code Light Nerd Font Complete Mono.ttf and /dev/null differ diff --git a/src/.config/awesome/requirements/fonts/Fira Code Medium Nerd Font Complete Mono.ttf b/src/.config/awesome/requirements/fonts/Fira Code Medium Nerd Font Complete Mono.ttf deleted file mode 100644 index bcbb90e..0000000 Binary files a/src/.config/awesome/requirements/fonts/Fira Code Medium Nerd Font Complete Mono.ttf and /dev/null differ diff --git a/src/.config/awesome/requirements/fonts/Fira Code Regular Nerd Font Complete Mono.ttf b/src/.config/awesome/requirements/fonts/Fira Code Regular Nerd Font Complete Mono.ttf deleted file mode 100644 index c1073e3..0000000 Binary files a/src/.config/awesome/requirements/fonts/Fira Code Regular Nerd Font Complete Mono.ttf and /dev/null differ diff --git a/src/.config/awesome/theme/color-schemes.lua b/src/.config/awesome/theme/color-schemes.lua index 256038d..0fb7617 100644 --- a/src/.config/awesome/theme/color-schemes.lua +++ b/src/.config/awesome/theme/color-schemes.lua @@ -1,15 +1,50 @@ return { - -- Dracula dracula = { - hue_50 = '#f8f8f2', - hue_100 = '#f1fa8c', - hue_200 = '#50fa7b', - hue_300 = '#8be9fd', - hue_400 = '#ff5555', - hue_500 = '#6272a4', - hue_600 = '#ff79c6', - hue_700 = '#ffb86c', - hue_800 = '#44475a', - hue_900 = '#282a36' + primary = { + hue_100 = '#282a36', + hue_200 = '#44475a' + }, + accent = { + hue_100 = '#f1fa8c', + hue_200 = '#50fa7b', + hue_300 = '#8be9fd', + hue_400 = '#ff5555', + hue_500 = '#6272a4', + hue_600 = '#ff79c6', + hue_700 = '#ffb86c', + hue_800 = '#f8f8f2', + } + }, + gruvbox = { + primary = { + hue_100 = '#282828', + hue_200 = '#3c3c3c' + }, + accent = { + hue_100 = '#fe8019', + hue_200 = '#fabd2f', + hue_300 = '#8ec07c', + hue_400 = '#fb4934', + hue_500 = '#d3869b', + hue_600 = '#b8bb26', + hue_700 = '#458588', + hue_800 = '#fbf1c7', + } + }, + gruvbox_material = { + primary = { + hue_100 = '#212121', + hue_200 = '#3c3c3c' + }, + accent = { + hue_100 = '#e1be7f', + hue_200 = '#92c96a', + hue_300 = '#66aeea', + hue_400 = '#f35a5a', + hue_500 = '#4083bc', + hue_600 = '#c57cda', + hue_700 = '#cd996a', + hue_800 = '#d6d6d6', + } } } diff --git a/src/.config/awesome/theme/theme.lua b/src/.config/awesome/theme/theme.lua index 65411b0..ab60b40 100644 --- a/src/.config/awesome/theme/theme.lua +++ b/src/.config/awesome/theme/theme.lua @@ -4,53 +4,54 @@ local theme_dir = filesystem.get_configuration_dir() .. '/theme' local gears = require('gears') local dpi = require('beautiful').xresources.apply_dpi local theme = {} -theme.icons = theme_dir .. '/icons/' --- Primary Color Scheme -theme.primary = color_schemes.dracula +-- Color Scheme +theme.primary = color_schemes.gruvbox.primary +theme.accent = color_schemes.gruvbox.accent local awesome_overrides = function(theme) theme.dir = os.getenv('HOME') .. '/.config/awesome/theme' theme.icons = theme.dir .. '/icons/' - theme.wallpaper = theme.dir .. '/wallpapers/4.png' -- Can be replaced with a color (eg: '#e0e0e0') - theme.font = 'FiraCode Nerd Font Mono bold 9' + theme.font = 'Robotomono nerd font bold 9' -- Glyphs don't work properly with this (#442) + theme.icon_font = 'furamono nerd font 11' -- Fira mono patched version - -- Layout - theme.layout_max = theme.icons .. 'layouts/arrow-expand-all.png' - theme.layout_tile = theme.icons .. 'layouts/view-quilt.png' - theme.layout_floating = theme.icons .. 'layouts/floating.png' + -- Layout icons + theme.layout_txt_tile = "舘" + theme.layout_txt_max = "" + theme.layout_txt_floating = "" -- Taglist theme.taglist_font = theme.font - theme.taglist_bg_empty = theme.primary.hue_900 - theme.taglist_bg_occupied = 'linear:0,0:0,' .. dpi(32) .. ':0,' .. theme.primary.hue_800 .. ':0.1,' .. - theme.primary.hue_800 .. ':0.1,' .. theme.primary.hue_900 .. ':0.9,' .. - theme.primary.hue_900 - theme.taglist_bg_urgent = 'linear:0,0:0,' .. dpi(48) .. ':0,' .. theme.primary.hue_700 .. ':0.07,' .. - theme.primary.hue_700 .. ':0.07,' .. theme.primary.hue_900 .. ':1,' .. - theme.primary.hue_900 - theme.taglist_bg_focus = theme.primary.hue_200 - theme.taglist_fg_focus = theme.primary.hue_900 + theme.taglist_bg_empty = theme.primary.hue_100 + theme.taglist_bg_occupied = 'linear:0,0:0,' .. dpi(32) .. ':0,' .. + theme.primary.hue_200 .. ':0.1,' .. + theme.primary.hue_200 .. ':0.1,' .. + theme.primary.hue_100 .. ':0.9,' .. + theme.primary.hue_100 + theme.taglist_bg_urgent = 'linear:0,0:0,' .. dpi(48) .. ':0,' .. + theme.accent.hue_700 .. ':0.07,' .. + theme.accent.hue_700 .. ':0.07,' .. + theme.primary.hue_100 .. ':1,' .. + theme.primary.hue_100 + theme.taglist_bg_focus = theme.accent.hue_200 + theme.taglist_fg_focus = theme.primary.hue_100 -- Tasklist theme.tasklist_font = theme.font - theme.tasklist_bg_normal = theme.primary.hue_900 - theme.tasklist_bg_focus = theme.primary.hue_800 - theme.tasklist_bg_urgent = theme.primary.hue_900 + theme.tasklist_bg_normal = theme.primary.hue_200 + theme.tasklist_bg_focus = theme.primary.hue_100 + theme.tasklist_bg_urgent = theme.primary.hue_200 -- Icons theme.icon_theme = 'Papirus' -- Client - theme.gaps = dpi(4) + theme.gaps = dpi(2) theme.border_width = dpi(2) - theme.border_focus = theme.primary.hue_200 - theme.border_normal = theme.primary.hue_900 - theme.bg_normal = theme.primary.hue_900 - theme.bg_systray = theme.primary.hue_800 + theme.border_focus = theme.accent.hue_200 + theme.border_normal = theme.primary.hue_100 + theme.gap_single_client = false + theme.bg_normal = theme.primary.hue_100 end -return { - theme = theme, - awesome_overrides = awesome_overrides -} +return {theme = theme, awesome_overrides = awesome_overrides} diff --git a/src/.config/awesome/widget/battery/init.lua b/src/.config/awesome/widget/battery.lua similarity index 50% rename from src/.config/awesome/widget/battery/init.lua rename to src/.config/awesome/widget/battery.lua index 46dea96..beeaeb3 100644 --- a/src/.config/awesome/widget/battery/init.lua +++ b/src/.config/awesome/widget/battery.lua @@ -7,53 +7,27 @@ -- @copyright 2017 Pavel Makhov ------------------------------------------------- local awful = require('awful') -local naughty = require('naughty') local watch = require('awful.widget.watch') local wibox = require('wibox') -local clickable_container = require('widget.material.clickable-container') -local gears = require('gears') +local beautiful = require('beautiful') local dpi = require('beautiful').xresources.apply_dpi -local apps = require('configuration.apps') -- acpi sample outputs -- Battery 0: Discharging, 75%, 01:51:38 remaining -- Battery 0: Charging, 53%, 00:57:43 until charged -local HOME = os.getenv('HOME') -local PATH_TO_ICONS = HOME .. '/.config/awesome/widget/battery/icons/' local percentage = wibox.widget.textbox() +local battery_icon = wibox.widget.textbox() +battery_icon.font = beautiful.icon_font -local widget = wibox.widget { - { - id = 'icon', - widget = wibox.widget.imagebox, - resize = true - }, - layout = wibox.layout.fixed.horizontal -} - -local battery_widget = wibox.widget { - wibox.container.margin(widget, dpi(4), dpi(4), dpi(3), dpi(3)), - wibox.container.margin(percentage, dpi(0), dpi(4), dpi(4), dpi(4)), - layout = wibox.layout.fixed.horizontal -} - --- Alternative to naughty.notify - tooltip. You can compare both and choose the preferred one local battery_popup = awful.tooltip({ - objects = {battery_widget}, + objects = {percentage}, mode = 'outside', align = 'left', preferred_positions = {'right', 'left', 'top', 'bottom'} }) --- To use colors from beautiful theme put --- following lines in rc.lua before require("battery"): --- beautiful.tooltip_fg = beautiful.fg_normal --- beautiful.tooltip_bg = beautiful.bg_normal - -watch('acpi -i', 1, function(_, stdout) - local batteryIconName = 'battery' - +watch('acpi -i', 10, function(_, stdout) local battery_info = {} local capacities = {} for s in stdout:gmatch('[^\r\n]+') do @@ -86,22 +60,61 @@ watch('acpi -i', 1, function(_, stdout) end charge = charge / capacity - if status == 'Charging' or status == 'Full' then - batteryIconName = batteryIconName .. '-charging' - end - - local roundedCharge = math.floor(charge / 10) * 10 - if (roundedCharge == 0) then - batteryIconName = batteryIconName .. '-outline' - elseif (roundedCharge ~= 100) then - batteryIconName = batteryIconName .. '-' .. roundedCharge - end - - widget.icon:set_image(PATH_TO_ICONS .. batteryIconName .. '.svg') - -- Update popup text battery_popup.text = string.gsub(stdout, '\n$', '') percentage.text = math.floor(charge) - collectgarbage('collect') -end, widget) -return battery_widget + if status == 'Charging' then + battery_icon.text = '' + if math.floor(charge) <= 20 then + battery_icon.text = '' + elseif math.floor(charge) <= 30 then + battery_icon.text = '' + elseif math.floor(charge) <= 40 then + battery_icon.text = '' + elseif math.floor(charge) <= 60 then + battery_icon.text = '' + elseif math.floor(charge) <= 80 then + battery_icon.text = '' + elseif math.floor(charge) <= 90 then + battery_icon.text = '' + elseif math.floor(charge) <= 100 then + battery_icon.text = '' + end + elseif status == 'Full' then + battery_icon.text = '' + else + if math.floor(charge) <= 10 then + battery_icon.text = '' + elseif math.floor(charge) <= 20 then + battery_icon.text = '' + elseif math.floor(charge) <= 30 then + battery_icon.text = '' + elseif math.floor(charge) <= 40 then + battery_icon.text = '' + elseif math.floor(charge) <= 50 then + battery_icon.text = '' + elseif math.floor(charge) <= 60 then + battery_icon.text = '' + elseif math.floor(charge) <= 60 then + battery_icon.text = '' + elseif math.floor(charge) <= 80 then + battery_icon.text = '' + elseif math.floor(charge) <= 90 then + battery_icon.text = '' + elseif math.floor(charge) <= 100 then + battery_icon.text = '' + end + end + collectgarbage('collect') +end) + +return wibox.widget { + wibox.widget{ + battery_icon, + fg = beautiful.accent.hue_300, + widget = wibox.container.background + }, + percentage, + spacing = dpi(4), + layout = wibox.layout.fixed.horizontal +} diff --git a/src/.config/awesome/widget/clock.lua b/src/.config/awesome/widget/clock.lua new file mode 100644 index 0000000..7f48431 --- /dev/null +++ b/src/.config/awesome/widget/clock.lua @@ -0,0 +1,5 @@ +local wibox = require('wibox') +local beautiful = require('beautiful') + +local clock = wibox.widget.textclock('%d/%m %a %H:%M') +return clock diff --git a/src/.config/awesome/widget/cpu/init.lua b/src/.config/awesome/widget/cpu.lua similarity index 58% rename from src/.config/awesome/widget/cpu/init.lua rename to src/.config/awesome/widget/cpu.lua index 8096ac0..67cd77a 100644 --- a/src/.config/awesome/widget/cpu/init.lua +++ b/src/.config/awesome/widget/cpu.lua @@ -1,20 +1,9 @@ local wibox = require('wibox') local beautiful = require('beautiful') -local icons = require('theme.icons') local dpi = require('beautiful').xresources.apply_dpi local watch = require('awful.widget.watch') -local icon = wibox.widget { - wibox.widget { - image = icons.cpu, - widget = wibox.widget.imagebox - }, - top = dpi(3), - bottom = dpi(3), - widget = wibox.container.margin -} - -local percentage = wibox.widget.textbox() +local cpu = wibox.widget.textbox() local total_prev = 0 local idle_prev = 0 @@ -28,17 +17,12 @@ watch([[bash -c "cat /proc/stat | grep '^cpu '"]], 1, function(_, stdout) local diff_total = total - total_prev local diff_usage = (1000 * (diff_total - diff_idle) / diff_total + 5) / 10 - percentage.text = math.floor(diff_usage) .. '%' + cpu.text = math.floor(diff_usage) .. '%' + if diff_usage < 10 then cpu.text = '0' .. cpu.text end total_prev = total idle_prev = idle collectgarbage('collect') end) -local cpu_widget = wibox.widget { - icon, - wibox.container.margin(percentage, dpi(4), dpi(4), dpi(4), dpi(4)), - layout = wibox.layout.fixed.horizontal -} - -return wibox.container.margin(cpu_widget, dpi(4), dpi(4)) +return cpu diff --git a/src/.config/awesome/widget/material/clickable-container.lua b/src/.config/awesome/widget/material/clickable-container.lua index bcb09e5..1b466db 100644 --- a/src/.config/awesome/widget/material/clickable-container.lua +++ b/src/.config/awesome/widget/material/clickable-container.lua @@ -1,8 +1,12 @@ local wibox = require('wibox') -function build(widget) +function build(widget, label) local container = wibox.widget { - widget, + -- widget, + wibox.widget { + text = label, + widget = wibox.widget.textbox, + }, widget = wibox.container.background } local old_cursor, old_wibox diff --git a/src/.config/awesome/widget/material/markup.lua b/src/.config/awesome/widget/material/markup.lua new file mode 100644 index 0000000..19d0da2 --- /dev/null +++ b/src/.config/awesome/widget/material/markup.lua @@ -0,0 +1,59 @@ +-- Adopted from: https://github.com/lcpz/lain + +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 }) \ No newline at end of file diff --git a/src/.config/awesome/widget/material/separator.lua b/src/.config/awesome/widget/material/separator.lua new file mode 100644 index 0000000..2098d38 --- /dev/null +++ b/src/.config/awesome/widget/material/separator.lua @@ -0,0 +1,111 @@ +-- Adopted from: https://github.com/lcpz/lain/ + +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(_, _, _) + return separators.width, separators.height + end + + widget.update = function(_, _) + widget.col1 = col1 + widget.col2 = col2 + widget:emit_signal("widget::redraw_needed") + end + + widget.draw = function(_, _, cr, width, height) + if widget.col2 ~= "alpha" then + cr:set_source_rgba(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_rgba(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(_, _, _) + return separators.width, separators.height + end + + widget.update = function(c1, c2) + widget.col1 = c1 + widget.col2 = c2 + widget:emit_signal("widget::redraw_needed") + end + + widget.draw = function(_, _, cr, width, height) + if widget.col1 ~= "alpha" then + cr:set_source_rgba(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_rgba(gears.color.parse_color(widget.col2)) + cr:fill() + end + end + + return widget +end + +-- ]] + +return separators diff --git a/src/.config/awesome/widget/material/slider.lua b/src/.config/awesome/widget/material/slider.lua index cc34efc..9dfe756 100644 --- a/src/.config/awesome/widget/material/slider.lua +++ b/src/.config/awesome/widget/material/slider.lua @@ -79,8 +79,8 @@ local function new(args) forced_height = dpi(6), paddings = 0, shape = gears.shape.rounded_rect, - background_color = beautiful.primary.hue_900, - color = beautiful.primary.hue_400, + background_color = beautiful.primary.hue_100, + color = beautiful.accent.hue_400, widget = wibox.widget.progressbar } @@ -88,8 +88,8 @@ local function new(args) forced_height = dpi(8), bar_shape = gears.shape.rounded_rect, bar_height = 0, - bar_color = beautiful.primary.hue_500, - handle_color = beautiful.primary.hue_300, + bar_color = beautiful.accent.hue_500, + handle_color = beautiful.accent.hue_300, handle_shape = gears.shape.circle, handle_border_color = '#00000012', handle_border_width = dpi(3), diff --git a/src/.config/awesome/widget/memory.lua b/src/.config/awesome/widget/memory.lua new file mode 100644 index 0000000..9260f65 --- /dev/null +++ b/src/.config/awesome/widget/memory.lua @@ -0,0 +1,21 @@ +local wibox = require('wibox') +local beautiful = require('beautiful') +local watch = require('awful.widget.watch') + +local memory = wibox.widget.textbox() +memory.font = beautiful.font + +function round(exact, quantum) + local quant,frac = math.modf(exact/quantum) + return quantum * (quant + (frac > 0.5 and 1 or 0)) +end + +watch('bash -c "free | grep -z Mem.*Swap.*"', 1, function(_, stdout) + local total, used, free, shared, buff_cache, available, total_swap, used_swap, free_swap = + stdout:match('(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*(%d+)%s*Swap:%s*(%d+)%s*(%d+)%s*(%d+)') + + memory.text = round((used / 1048576), 0.01) .. 'GB' + collectgarbage('collect') +end) + +return memory diff --git a/src/.config/awesome/widget/net.lua b/src/.config/awesome/widget/net.lua new file mode 100644 index 0000000..d02ad88 --- /dev/null +++ b/src/.config/awesome/widget/net.lua @@ -0,0 +1,141 @@ +local wibox = require("wibox") +local string = string + +local spawn = require("awful.spawn") +local timer = require("gears.timer") + +-- Network infos +-- lain.widget.net + +local function line_callback(cmd, callback) + return spawn.with_line_callback(cmd, { + stdout = function (line) + callback(line) + end, + }) +end + +local timer_table = {} + +local function newtimer(name, timeout, fun, nostart, stoppable) + if not name or #name == 0 then return end + name = (stoppable and name) or timeout + if not timer_table[name] then + timer_table[name] = timer({ timeout = timeout }) + timer_table[name]:start() + end + timer_table[name]:connect_signal("timeout", fun) + if not nostart then + timer_table[name]:emit_signal("timeout") + end + return stoppable and timer_table[name] +end + +local function first_line(path) + local file, first = io.open(path, "rb"), nil + if file then + first = file:read("*l") + file:close() + end + return first +end + +local function lines_from(path) + local lines = {} + for line in io.lines(path) do + lines[#lines + 1] = line + end + return lines +end + +local function factory(args) + args = args or {} + + local net = { widget = args.widget or wibox.widget.textbox(), devices = {} } + local timeout = args.timeout or 2 + local units = args.units or 1024 -- KB + 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_devices() + net.iface = {} -- reset at every call + 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_devices() 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(first_line(string.format("/sys/class/net/%s/statistics/tx_bytes", dev)) or 0) + local now_r = tonumber(first_line(string.format("/sys/class/net/%s/statistics/rx_bytes", dev)) or 0) + + dev_now.carrier = first_line(string.format("/sys/class/net/%s/carrier", dev)) or "0" + dev_now.state = 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 first_line(string.format("/sys/class/net/%s/uevent", dev)) == "DEVTYPE=wlan" then + dev_now.wifi = true + if string.match(dev_now.carrier, "1") then + dev_now.signal = tonumber(string.match(lines_from("/proc/net/wireless")[3], "(%-%d+%.)")) or nil + end + else + dev_now.wifi = false + end + + if eth_state == "on" and first_line(string.format("/sys/class/net/%s/uevent", dev)) ~= "DEVTYPE=wlan" then + dev_now.ethernet = true + else + dev_now.ethernet = false + end + + net.devices[dev] = dev_now + + 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 + + newtimer("network", timeout, net.update) + + return net +end + +return factory \ No newline at end of file diff --git a/src/.config/awesome/widget/storage.lua b/src/.config/awesome/widget/storage.lua new file mode 100644 index 0000000..af13fe9 --- /dev/null +++ b/src/.config/awesome/widget/storage.lua @@ -0,0 +1,12 @@ +local wibox = require('wibox') +local watch = require('awful.widget.watch') +local beautiful = require('beautiful') + +local storage = wibox.widget.textbox() +storage.font = beautiful.font + +watch('bash -c "df -h $HOME | awk \'/[0-9]/ {print $2-$3}\'"', 30, function(_, stdout) + storage.text = stdout +end) + +return storage diff --git a/src/.config/awesome/widget/tag-list/init.lua b/src/.config/awesome/widget/tag-list.lua similarity index 93% rename from src/.config/awesome/widget/tag-list/init.lua rename to src/.config/awesome/widget/tag-list.lua index 4e07d96..00ab350 100644 --- a/src/.config/awesome/widget/tag-list/init.lua +++ b/src/.config/awesome/widget/tag-list.lua @@ -98,8 +98,6 @@ local function list_update(w, buttons, label, data, objects) end bgb.shape = args.shape - bgb.shape_border_width = args.shape_border_width - bgb.shape_border_color = args.shape_border_color w:add(bgb) end @@ -109,19 +107,24 @@ local TagList = function(s) return awful.widget.taglist(s, awful.widget.taglist.filter.all, awful.util.table.join(awful.button({}, 1, function(t) t:view_only() + _G._splash_to_current_tag() end), awful.button({modkey}, 1, function(t) if _G.client.focus then _G.client.focus:move_to_tag(t) t:view_only() end - end), awful.button({}, 3, awful.tag.viewtoggle), awful.button({modkey}, 3, function(t) + _G._splash_to_current_tag() + end), awful.button({modkey}, 3, function(t) if _G.client.focus then _G.client.focus:toggle_tag(t) end + _G._splash_to_current_tag() end), awful.button({}, 4, function(t) awful.tag.viewprev(t.screen) + _G._splash_to_current_tag() end), awful.button({}, 5, function(t) awful.tag.viewnext(t.screen) + _G._splash_to_current_tag() end)), {}, list_update, wibox.layout.fixed.horizontal()) end return TagList diff --git a/src/.config/awesome/widget/task-list/init.lua b/src/.config/awesome/widget/task-list.lua similarity index 96% rename from src/.config/awesome/widget/task-list/init.lua rename to src/.config/awesome/widget/task-list.lua index 4b2ab6a..e905bf4 100644 --- a/src/.config/awesome/widget/task-list/init.lua +++ b/src/.config/awesome/widget/task-list.lua @@ -55,7 +55,7 @@ local function list_update(w, buttons, label, data, objects) bg_clickable = clickable_container() bgb = wibox.container.background() tbm = wibox.container.margin(tb, dpi(4), dpi(4), dpi(1), dpi(1)) - ibm = wibox.container.margin(ib, dpi(2), dpi(2), dpi(2), dpi(2)) + ibm = wibox.container.margin(ib, dpi(1), dpi(1), dpi(1), dpi(1)) l = wibox.layout.fixed.horizontal() ll = wibox.layout.flex.horizontal() @@ -86,6 +86,8 @@ local function list_update(w, buttons, label, data, objects) -- The text might be invalid, so use pcall. if tasklist_mode == 'icon' then text = nil + elseif tasklist_mode == 'text' then + icon = nil end if text == nil or text == '' then tbm:set_margins(0) @@ -109,6 +111,7 @@ local function list_update(w, buttons, label, data, objects) bgb.shape = args.shape bgb.shape_border_width = args.shape_border_width bgb.shape_border_color = args.shape_border_color + tb.align = 'center' w:add(bgb) end diff --git a/src/.config/awesome/widget/temprature.lua b/src/.config/awesome/widget/temprature.lua new file mode 100644 index 0000000..caeabf3 --- /dev/null +++ b/src/.config/awesome/widget/temprature.lua @@ -0,0 +1,12 @@ +local wibox = require('wibox') +local watch = require('awful.widget.watch') +local beautiful = require('beautiful') + +local temprature = wibox.widget.textbox() +temprature.font = beautiful.font + +watch('bash -c "sensors | awk \'/Core 0/ {print substr($3, 2) }\'"', 30, function(_, stdout) + temprature.text = stdout +end) + +return temprature diff --git a/src/.config/awesome/widget/volume.lua b/src/.config/awesome/widget/volume.lua new file mode 100644 index 0000000..d44367f --- /dev/null +++ b/src/.config/awesome/widget/volume.lua @@ -0,0 +1,51 @@ +local awful = require("awful") +local wibox = require('wibox') +local mat_list_item = require('widget.material.list-item') +local dpi = require('beautiful').xresources.apply_dpi +local watch = require('awful.widget.watch') +local beautiful = require('beautiful') + +local volume_icon = wibox.widget.textbox() +volume_icon.font = beautiful.icon_font +local volume_widget = wibox.widget.textbox() +volume_widget.align = 'center' +volume_widget.valign = 'center' +volume_widget.font = beautiful.font + +local volume + +function update_volume() + awful.spawn.easy_async_with_shell("bash -c 'amixer -D pulse sget Master'", function(stdout) + volume = string.match(stdout, '(%d?%d?%d)%%') + awful.spawn.easy_async_with_shell("bash -c 'pacmd list-sinks | awk '/muted/ { print $2 }''", function(muted) + volume_widget.text = volume + muted = string.gsub(muted, "%s+", "") + if muted == 'muted:no' and (volume > '35' or volume == '100') then + volume_icon.text = '墳' + elseif muted == 'muted:no' and volume <= '35' and volume > '0' then + volume_icon.text = '奔' + elseif muted == 'muted:yes' then + volume_icon.text = '婢' + volume_widget.text = 'M' + elseif volume == '0' then + volume_icon.text = '奄' + end + end) + collectgarbage('collect') + end) +end + +watch('bash -c', 3, function(_, stdout) + update_volume() +end) + +return wibox.widget { + wibox.widget{ + volume_icon, + fg = beautiful.accent.hue_100, + widget = wibox.container.background + }, + volume_widget, + spacing = dpi(4), + layout = wibox.layout.fixed.horizontal +} diff --git a/src/.config/awesome/configuration/compton.conf b/src/.config/compton.conf similarity index 78% rename from src/.config/awesome/configuration/compton.conf rename to src/.config/compton.conf index d292acc..74c3a3c 100644 --- a/src/.config/awesome/configuration/compton.conf +++ b/src/.config/compton.conf @@ -32,26 +32,27 @@ inactive-opacity = 1.0; active-opacity = 1.0; frame-opacity = 1.0; inactive-opacity-override = false; -alpha-step = 0.06; -# inactive-dim = 0.2; +# alpha-step = 0.06; +# inactive-dim = 0.05; # inactive-dim-fixed = true; -blur-background = true; -blur-background-frame = true; -blur-method = "kawase"; -blur-strength = 10; -blur-background-fixed = true; -blur-background-exclude = [ - "window_type = 'dock'", - "window_type = 'desktop'", - "class_g = 'slop'", - "_GTK_FRAME_EXTENTS@:c" -]; +# blur-background = true; +# blur-background-frame = true; +# blur-strength = 20; +# blur-background-fixed = true; +# blur-background-exclude = [ +# "window_type = 'dock'", +# "window_type = 'desktop'", +# "class_g = 'slop'", +# "WM_NAME@:s = 'SplashTerminal'", +# "WM_NAME@:s = 'dropdown_terminal'", +# "_GTK_FRAME_EXTENTS@:c" +# ]; # Fading fading = true; fade-delta = 4; -fade-in-step = 0.04; -fade-out-step = 0.04; +fade-in-step = 0.1; +fade-out-step = 0.1; no-fading-openclose = false; # no-fading-destroyed-argb = true; fade-exclude = [ ]; @@ -79,7 +80,7 @@ invert-color-include = [ ]; # GLX backend vsync="opengl-swc"; unredir-if-possible=true; -#paint-on-overlay=true; +# paint-on-overlay=true; #glx-no-stencil=true; glx-copy-from-front=false; # glx-no-stencil = true; @@ -94,9 +95,9 @@ glx-no-rebind-pixmap = true; # Window type settings wintypes: { - tooltip = { - fade = true; + tooltip = { + fade = true; shadow = true; - focus = true; + focus = true; }; }; diff --git a/src/.config/kitty/dracula.conf b/src/.config/kitty/dracula.conf index 8bee635..27e9dc7 100644 --- a/src/.config/kitty/dracula.conf +++ b/src/.config/kitty/dracula.conf @@ -9,7 +9,7 @@ # Alternatively copy paste below directly into kitty.conf foreground #f8f8f2 -background #282a36 +background #282828 selection_foreground #ffffff selection_background #44475a diff --git a/src/.config/kitty/gruvbox-material.conf b/src/.config/kitty/gruvbox-material.conf new file mode 100644 index 0000000..62757db --- /dev/null +++ b/src/.config/kitty/gruvbox-material.conf @@ -0,0 +1,38 @@ +# Original Project: +# https://github.com/sainnhe/gruvbox-material/ +# Colors are different than original, just to match my taste :P + +foreground #d6d6d6 +background #282828 + +# black +color0 #282828 +color8 #6e6e6e + +# red +color1 #f35a5a +color9 #ba524a + +# green +color2 #92c96a +color10 #7b9d62 + +# yellow +color3 #e1be7f +color11 #cd996a + +# blue +color4 #66aeea +color12 #4083bc + +# magenta +color5 #c57cda +color13 #9955ac + +# cyan +color6 #3cb46c +color14 #319659 + +# white +color7 #d1d1d1 +color15 #858585 diff --git a/src/.config/kitty/gruvbox.conf b/src/.config/kitty/gruvbox.conf new file mode 100644 index 0000000..7fdfb3e --- /dev/null +++ b/src/.config/kitty/gruvbox.conf @@ -0,0 +1,40 @@ +# gruvbox-dark colorscheme for kitty +# snazzy theme used as base + +foreground #ebdbb2 +background #272727 +selection_foreground #655b53 +selection_background #ebdbb2 +url_color #d65c0d + +# black +color0 #272727 +color8 #928373 + +# red +color1 #cc231c +color9 #fb4833 + +# green +color2 #989719 +color10 #b8ba25 + +# yellow +color3 #d79920 +color11 #fabc2e + +# blue +color4 #448488 +color12 #83a597 + +# magenta +color5 #b16185 +color13 #d3859a + +# cyan +color6 #689d69 +color14 #8ec07b + +# white +color7 #a89983 +color15 #ebdbb2 diff --git a/src/.config/kitty/kitty.conf b/src/.config/kitty/kitty.conf index 99630f7..9875533 100644 --- a/src/.config/kitty/kitty.conf +++ b/src/.config/kitty/kitty.conf @@ -1,10 +1,11 @@ -include dracula.conf +include gruvbox.conf -background_opacity 0.95 +background_opacity 0.9 font_family FiraCode Nerd Font Mono bold_font auto italic_font auto bold_italic_font auto -window_padding_width 4 +window_padding_width 1 font_size 12 disable_ligatures always +enable_audio_bell no diff --git a/src/.config/nvim/.gitignore b/src/.config/nvim/.gitignore new file mode 100644 index 0000000..b625983 --- /dev/null +++ b/src/.config/nvim/.gitignore @@ -0,0 +1,8 @@ +.netrwhist +spell/ +plugged/ +*.swp +temp/ +autoload/ +session/ + diff --git a/src/.config/nvim/coc-settings.json b/src/.config/nvim/coc-settings.json new file mode 100644 index 0000000..156bff3 --- /dev/null +++ b/src/.config/nvim/coc-settings.json @@ -0,0 +1,134 @@ +{ + // suggestions + // "suggest.echodocSupport": true, + // TODO add more labels and give them cool glyphs + "suggest.completionItemKindLabels": { + "text": "t", + "method": "m", + "function": "" + }, + "snippets.priority": 1, + //"yank.priority": 1, + "suggest.languageSourcePriority": 99, + "coc.source.file.priority": 2, + "coc.source.around.priority": 3, + "coc.source.buffer.priority": 4, + + // diagnostics + "diagnostic.errorSign": " ", + "diagnostic.warningSign": " ", + "diagnostic.infoSign": "", + "diagnostic.hintSign": " ", + // "diagnostic.displayByAle": true, + // "diagnostic.virtualText": true, // this won't work with codelens when error on same line + + // codelens + "codeLens.enable": true, + "java.referencesCodeLens.enabled": true, + "java.implementationsCodeLens.enabled": true, + "java.completion.enabled": true, + "java.jdt.ls.vmargs": "-javaagent:/usr/local/share/lombok/lombok.jar", + + // list + "list.indicator": ">", + "list.selectedSignText": " ", + + // autoformat + "coc.preferences.formatOnSaveFiletypes": [ + "css", + "markdown", + "javascript", + "graphql", + "html", + "yaml", + "json", + "python", + "java" + ], + "coc.preferences.hoverTarget": "float", + + // python config + "python.analysis.autoImportCompletions": true, + "python.analysis.autoSearchPaths": true, + "python.analysis.diagnosticMode": "openFilesOnly", + "python.analysis.stubPath": "typings", + "python.analysis.typeshedPaths": [], + "python.analysis.diagnosticSeverityOverrides": {}, + "python.analysis.typeCheckingMode": "basic", + "python.analysis.useLibraryCodeForTypes": true, + "python.pythonPath": "python", + "python.venvPath": "", + "python.formatting.provider": "black", + "python.formatting.blackPath": "black", + "python.formatting.blackArgs": [], + "python.formatting.autopep8Path": "autopep8", + "python.formatting.autopep8Args": [], + "python.formatting.yapfPath": "yapf", + "python.formatting.yapfArgs": [], + "python.linting.enabled": true, + "python.linting.flake8Enabled": false, + "python.linting.banditEnabled": false, + "python.linting.mypyEnabled": false, + "python.linting.pytypeEnabled": false, + "python.linting.prospectorEnabled": false, + "python.linting.pydocstyleEnabled": false, + "python.linting.pylamaEnabled": false, + "python.linting.pylintEnabled": false, + "pyright.disableCompletion": false, + "pyright.disableLanguageServices": false, + "pyright.disableOrganizeImports": false, + + // snippets + "snippets.ultisnips.directories": ["UltiSnips", "~/.config/nvim/snips"], + //"snippets.userSnippetsDirectory": "~/.config/nvim/snips", + + // emmet + "emmet.includeLanguages": { + "vue-html": "html", + "javascript": "javascriptreact" + }, + + // CSS (disable since I'm also using stylelintplus) + "css.validate": false, + "less.validate": false, + "scss.validate": false, + "wxss.validate": false, + + // explorer + "explorer.width": 30, + "explorer.file.root.template": "[icon] [git] [hidden & 1][root]", + "explorer.icon.enableNerdfont": true, + "explorer.previewAction.onHover": false, + "explorer.icon.enableVimDevicons": false, + "explorer.file.showHiddenFiles": false, + "explorer.keyMappings.global": { + "": ["expandable?", "expand", "open"], + "v": "open:vsplit" + }, + + "languageserver": { + "lua": { + "command": "/home/chris/.luambenvs/neovim4/bin/lua-lsp", + "filetypes": ["lua"], + "trace.server": "verbose" + } + }, + + "bookmark.sign": "", + + //coc-emoji + "coc.source.emoji.filetypes": ["markdown"] + + // lua + //"lua.useSumnekoLs": true, + //"lua.commandPath": "/home/chris/.luambenvs/neovim3/bin/lua-lsp" + //"lua.enable": true, + //"Lua.completion.enable": true, + //"Lua.runtime.version": "Lua 5.1", + //"Lua.runtime.path": ["?.lua", "?/init.lua", "?/?.lua"], + //"lua.version": "5.1" + //"lua.commandPath": "/home/chris/.vscode-insiders/extensions/sumneko.lua-1.0.5/server/bin/Linux/lua-language-server" + + // TODO b:coc_suggest_disable=1 GOYO + // TODO add to paths.vim g:coc_node_path +} diff --git a/src/.config/nvim/init.vim b/src/.config/nvim/init.vim new file mode 100644 index 0000000..b969aa3 --- /dev/null +++ b/src/.config/nvim/init.vim @@ -0,0 +1,621 @@ +"***************************************************************************** +"" Plugin Installation +"***************************************************************************** +let vimplug_exists=expand('~/.config/nvim/autoload/plug.vim') +if has('win32')&&!has('win64') + let curl_exists=expand('C:\Windows\Sysnative\curl.exe') +else + let curl_exists=expand('curl') +endif + +if !filereadable(vimplug_exists) + if !executable(curl_exists) + echoerr "You have to install curl or first install vim-plug yourself!" + execute "q!" + endif + echo "Installing Vim-Plug..." + echo "" + silent exec "!"curl_exists" -fLo " . shellescape(vimplug_exists) . " --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" + let g:not_finish_vimplug = "yes" + + autocmd VimEnter * PlugInstall +endif + +set nocompatible +filetype on +call plug#begin() +" Load plugins +" VIM enhancements +Plug 'ciaranm/securemodelines' +Plug 'editorconfig/editorconfig-vim' +Plug 'justinmk/vim-sneak' + +" GUI enhancements +Plug 'machakann/vim-highlightedyank' +Plug 'andymass/vim-matchup' + +" Fuzzy finder +Plug 'airblade/vim-rooter' +Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } +Plug 'junegunn/fzf.vim' + +" Semantic language support +Plug 'neoclide/coc.nvim', {'branch': 'release'} + +" Syntactic language support +Plug 'cespare/vim-toml' +Plug 'stephpy/vim-yaml' +Plug 'rhysd/vim-clang-format' +Plug 'dag/vim-fish' +Plug 'godlygeek/tabular' + +Plug 'scrooloose/nerdtree' +Plug 'jistr/vim-nerdtree-tabs' +Plug 'ryanoasis/vim-devicons' +Plug 'tpope/vim-commentary' +Plug 'tpope/vim-fugitive' +Plug 'vim-airline/vim-airline' +Plug 'vim-airline/vim-airline-themes' +Plug 'airblade/vim-gitgutter' +Plug 'vim-scripts/grep.vim' +Plug 'vim-scripts/CSApprox' +Plug 'Raimondi/delimitMate' +Plug 'dense-analysis/ale' +Plug 'Yggdroot/indentLine' +Plug 'tpope/vim-rhubarb' " required by fugitive to :Gbrowse +Plug 'liuchengxu/vim-which-key' +Plug 'severin-lemaignan/vim-minimap' +Plug 'tpope/vim-surround' +Plug 'morhetz/gruvbox' +Plug 'sainnhe/gruvbox-material' " I switch when I feel like it :P +Plug 'mg979/vim-visual-multi' +Plug 'ntpeters/vim-better-whitespace' +Plug 'yuttie/comfortable-motion.vim' + +let g:make = 'gmake' +if exists('make') + let g:make = 'make' +endif +Plug 'Shougo/vimproc.vim', {'do': g:make} + +"" Vim-Session +Plug 'xolox/vim-misc' +Plug 'xolox/vim-session' + +"" Snippets +Plug 'SirVer/ultisnips' +Plug 'honza/vim-snippets' + +" c +Plug 'vim-scripts/c.vim', {'for': ['c', 'cpp']} +Plug 'ludwig/split-manpage.vim' + +" elm +"" Elm Bundle +Plug 'elmcast/elm-vim' + +" erlang +Plug 'jimenezrick/vimerl' + +" go +"" Go Lang Bundle +Plug 'fatih/vim-go', {'do': ':GoInstallBinaries'} + +" haskell +"" Haskell Bundle +Plug 'eagletmt/neco-ghc' +Plug 'dag/vim2hs' +Plug 'pbrisbin/vim-syntax-shakespeare' + +" html +"" HTML Bundle +Plug 'hail2u/vim-css3-syntax' +Plug 'gko/vim-coloresque' +Plug 'tpope/vim-haml' +Plug 'mattn/emmet-vim' + +" javascript +"" Javascript Bundle +Plug 'jelera/vim-javascript-syntax' + +" python +"" Python Bundle +Plug 'raimon49/requirements.txt.vim', {'for': 'requirements'} + +" ruby +Plug 'tpope/vim-rails' +Plug 'tpope/vim-rake' +Plug 'tpope/vim-projectionist' +Plug 'thoughtbot/vim-rspec' +Plug 'ecomba/vim-ruby-refactoring', {'tag': 'main'} + +" rust +" Vim racer +Plug 'racer-rust/vim-racer' + +" Rust.vim +Plug 'rust-lang/rust.vim' + +" svelte +Plug 'leafOfTree/vim-svelte-plugin' + +" typescript +Plug 'leafgarland/typescript-vim' +Plug 'HerringtonDarkholme/yats.vim' + +" vuejs +Plug 'posva/vim-vue' +Plug 'leafOfTree/vim-vue-plugin' +call plug#end() + +"***************************************************************************** +"" End of Plugin Installation +"***************************************************************************** + +"***************************************************************************** +"" Basic Settings +"***************************************************************************** + +syntax on +set ruler +set autoindent +let no_buffers_menu=1 +colorscheme gruvbox +set bg=dark +set mousemodel=popup +set t_Co=256 +hi Normal ctermbg=230 +set updatetime=100 +set mouse=a +set noswapfile +set colorcolumn=80 + +"" Set smart line numbers +set number relativenumber +augroup numbertoggle + autocmd! + autocmd BufEnter,FocusGained,InsertLeave * set relativenumber + autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber +augroup END + +"" Encoding +set encoding=utf-8 +set fileencoding=utf-8 +set fileencodings=utf-8 + +"" Fix backspace indent +set backspace=indent,eol,start + +"" Tabs. May be overridden by autocmd rules +set tabstop=4 +set softtabstop=0 +set shiftwidth=4 +set expandtab + +"" Map leader to +" https://sheerun.net/2014/03/21/how-to-boost-your-vim-productivity/ +let mapleader = "\" +if executable('ag') + set grepprg=ag\ --nogroup\ --nocolor +endif +if executable('rg') + set grepprg=rg\ --no-heading\ --vimgrep + set grepformat=%f:%l:%c:%m +endif + +" session management +let g:session_directory = "~/.config/nvim/session" +let g:session_autoload = "no" +let g:session_autosave = "no" +let g:session_command_aliases = 1 + +" deal with colors +if !has('gui_running') + set t_Co=256 +endif +if (match($TERM, "-256color") != -1) && (match($TERM, "screen-256color") == -1) + " screen does not (yet) support truecolor + set termguicolors +endif +let base16colorspace=256 + + +" IndentLine +let g:indentLine_enabled = 1 +let g:indentLine_concealcursor = 0 +let g:indentLine_char = '┆' +let g:indentLine_faster = 1 + +au TermEnter * setlocal scrolloff=0 +au TermLeave * setlocal scrolloff=3 + +"" Status bar +set laststatus=2 + +"" Use modeline overrides +set modeline +set modelines=10 +set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\ + +" remove trailing whitespaces +command! FixWhitespace :%s/\s\+$//e + +"" Copy/Paste/Cut to system clipboard +if has('unnamedplus') + set clipboard=unnamed,unnamedplus +endif + +" Sane splits +set splitright +set splitbelow + +" Permanent undo +set undodir=~/.vimdid +set undofile + +" Decent wildmenu +set wildmenu +set wildmode=list:longest +set wildignore=.hg,.svn,*~,*.png,*.jpg,*.gif,*.settings,Thumbs.db,*.min.js,*.swp,publish/*,intermediate/*,*.o,*.hi,Zend,vendor + +"" Searching +set hlsearch +set incsearch +set ignorecase +set smartcase + +"***************************************************************************** +"" End of Base Settings +"***************************************************************************** + +"***************************************************************************** +"" Plugin Settings +"***************************************************************************** + +" vim-airline +if !exists('g:airline_symbols') + let g:airline_symbols = {} +endif +let g:airline_symbols.branch = '' +let g:airline_symbols.readonly = '' +let g:airline_symbols.linenr = '' +let g:airline#extensions#branch#enabled = 1 +let g:airline#extensions#ale#enabled = 1 +let g:airline#extensions#tabline#enabled = 1 +let g:airline_skip_empty_sections = 1 +let g:airline_theme='gruvbox' + +"" NERDTree configuration +let g:NERDTreeChDirMode=2 +let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__'] +let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$'] +let g:NERDTreeShowHidden=1 +let g:nerdtree_tabs_focus_on_files=1 +let g:NERDTreeMapOpenInTabSilent = '' +let g:NERDTreeWinSize = 30 +set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite +nnoremap :NERDTreeFind +nnoremap :NERDTreeToggle + +" grep.vim +nnoremap f :Rgrep +let Grep_Default_Options = '-IR' +let Grep_Skip_Files = '*.log *.db' +let Grep_Skip_Dirs = '.git node_modules' + +" vim rooter +let g:rooter_silent_chdir = 1 + +"***************************************************************************** +"" End of Plugin Settings +"***************************************************************************** + +"***************************************************************************** +"" Language Settings +"***************************************************************************** + +" PYTHON +" vim-python +augroup vimrc-python + autocmd! + autocmd FileType python setlocal expandtab shiftwidth=4 tabstop=8 + \ formatoptions+=croq softtabstop=4 + \ cinwords=if,elif,else,for,while,try,except,finally,def,class,with +augroup END +" jedi-vim +let g:jedi#popup_on_dot = 0 +let g:jedi#goto_assignments_command = "g" +let g:jedi#goto_definitions_command = "d" +let g:jedi#documentation_command = "K" +let g:jedi#usages_command = "n" +let g:jedi#rename_command = "r" +let g:jedi#show_call_signatures = "0" +let g:jedi#completions_command = "" +let g:jedi#smart_auto_mappings = 0 +" ale +let g:ale_linters = {} +:call extend(g:ale_linters, { + \'python': ['flake8'], }) +" vim-airline +let g:airline#extensions#virtualenv#enabled = 1 +" Syntax highlight +let python_highlight_all = 1 + +" JAVASCRIPT +let g:javascript_enable_domhtmlcss = 1 +" vim-javascript +augroup vimrc-javascript + autocmd! + autocmd FileType javascript setl tabstop=4|setl shiftwidth=4|setl expandtab softtabstop=4 +augroup END + +" RUST +" Vim racer +au FileType rust nmap gd (rust-def) +au FileType rust nmap gs (rust-def-split) +au FileType rust nmap gx (rust-def-vertical) +au FileType rust nmap gd (rust-doc) + +" GOLANG +" vim-go +" run :GoBuild or :GoTestCompile based on the go file +function! s:build_go_files() + let l:file = expand('%') + if l:file =~# '^\f\+_test\.go$' + call go#test#Test(0, 1) + elseif l:file =~# '^\f\+\.go$' + call go#cmd#Build(0) + endif +endfunction +let g:go_list_type = "quickfix" +let g:go_fmt_command = "goimports" +let g:go_fmt_fail_silently = 1 +let g:go_highlight_types = 1 +let g:go_highlight_fields = 1 +let g:go_highlight_functions = 1 +let g:go_highlight_methods = 1 +let g:go_highlight_operators = 1 +let g:go_highlight_build_constraints = 1 +let g:go_highlight_structs = 1 +let g:go_highlight_generate_tags = 1 +let g:go_highlight_space_tab_error = 0 +let g:go_highlight_array_whitespace_error = 0 +let g:go_highlight_trailing_whitespace_error = 0 +let g:go_highlight_extra_types = 1 +autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 +augroup completion_preview_close + autocmd! + if v:version > 703 || v:version == 703 && has('patch598') + autocmd CompleteDone * if !&previewwindow && &completeopt =~ 'preview' | silent! pclose | endif + endif +augroup END +augroup go + au! + au Filetype go command! -bang A call go#alternate#Switch(0, 'edit') + au Filetype go command! -bang AV call go#alternate#Switch(0, 'vsplit') + au Filetype go command! -bang AS call go#alternate#Switch(0, 'split') + au Filetype go command! -bang AT call go#alternate#Switch(0, 'tabe') + au FileType go nmap dd (go-def-vertical) + au FileType go nmap dv (go-doc-vertical) + au FileType go nmap db (go-doc-browser) + au FileType go nmap r (go-run) + au FileType go nmap t (go-test) + au FileType go nmap gt (go-coverage-toggle) + au FileType go nmap i (go-info) + au FileType go nmap l (go-metalinter) + au FileType go nmap :GoDecls + au FileType go nmap dr :GoDeclsDir + au FileType go imap :GoDecls + au FileType go imap dr :GoDeclsDir + au FileType go nmap rb :call build_go_files() +augroup END +" ale +:call extend(g:ale_linters, { + \"go": ['golint', 'go vet'], }) + +" HTML +" for html files, 2 spaces +autocmd Filetype html setlocal ts=2 sw=2 expandtab + +" C/C++ +autocmd FileType c setlocal tabstop=4 shiftwidth=4 expandtab +autocmd FileType cpp setlocal tabstop=4 shiftwidth=4 expandtab + +" HASKELL +let g:haskell_conceal_wide = 1 +let g:haskell_multiline_strings = 1 +let g:necoghc_enable_detailed_browse = 1 +autocmd Filetype haskell setlocal omnifunc=necoghc#omnifunc + +" RUBY +let g:rubycomplete_buffer_loading = 1 +let g:rubycomplete_classes_in_global = 1 +let g:rubycomplete_rails = 1 +augroup vimrc-ruby + autocmd! + autocmd BufNewFile,BufRead *.rb,*.rbw,*.gemspec setlocal filetype=ruby + autocmd FileType ruby set tabstop=2|set shiftwidth=2|set expandtab softtabstop=2 +augroup END +let g:tagbar_type_ruby = { + \ 'kinds' : [ + \ 'm:modules', + \ 'c:classes', + \ 'd:describes', + \ 'C:contexts', + \ 'f:methods', + \ 'F:singleton methods' + \ ] +\ } +" RSpec.vim mappings +map t :call RunCurrentSpecFile() +map s :call RunNearestSpec() +map l :call RunLastSpec() +map a :call RunAllSpecs() +" For ruby refactory +if has('nvim') + runtime! macros/matchit.vim +else + packadd! matchit +endif +" Ruby refactory +nnoremap rap :RAddParameter +nnoremap rcpc :RConvertPostConditional +nnoremap rel :RExtractLet +vnoremap rec :RExtractConstant +vnoremap relv :RExtractLocalVariable +nnoremap rit :RInlineTemp +vnoremap rrlv :RRenameLocalVariable +vnoremap rriv :RRenameInstanceVariable +vnoremap rem :RExtractMethod + +" ELM +" elm-vim +let g:elm_setup_keybindings = 0 +let g:elm_format_autosave = 1 + +" ERLANG +let erlang_folding = 1 +let erlang_show_errors = 1 + +" VUE +" vim vue +let g:vue_disable_pre_processors=1 +" vim vue plugin +let g:vim_vue_plugin_load_full_syntax = 1 + +" SVELTE +let g:vim_svelte_plugin_load_full_syntax = 1 + +" TYPESCRIPT +let g:yats_host_keyword = 1 + +"***************************************************************************** +"" End of Language Settings +"***************************************************************************** + +"***************************************************************************** +"" Key Bindings / Shortcuts +"***************************************************************************** + +" Reload Nvim +noremap r :so % + +" Confirm before quitting all +noremap :confirm qall + +" Switch split-windows +nmap :wincmd k +nmap :wincmd j +nmap :wincmd h +nmap :wincmd l +nmap :wincmd k +nmap :wincmd j +nmap :wincmd h +nmap :wincmd l + +" Ctrl-z/y for undo-redo +map +map + +" Open hotkeys +map :Files +nmap ; :Buffers + +" Quick-save +nmap w :w + +" Ctrl+j/k to go to normal mode +nnoremap +inoremap +vnoremap +snoremap +xnoremap +cnoremap +onoremap +lnoremap +tnoremap +nnoremap +inoremap +vnoremap +snoremap +xnoremap +cnoremap +onoremap +lnoremap +tnoremap + +" Ctrl+h to stop searching +vnoremap :nohlsearch +nnoremap :nohlsearch + +" Jump to start and end of line using the home row keys +map H ^ +map L $ + +" Close buffer / Exit +noremap c :bd +noremap z :qa + +" ; as : +nnoremap ; : + +" no one is really happy until you have this shortcuts +cnoreabbrev W! w! +cnoreabbrev Q! q! +cnoreabbrev Qall! qall! +cnoreabbrev Wq wq +cnoreabbrev Wa wa +cnoreabbrev wQ wq +cnoreabbrev WQ wq +cnoreabbrev W w +cnoreabbrev Q q +cnoreabbrev Qall qall + +" Left and right to switch buffers +nnoremap :bp +nnoremap :bn + +" Move by line +nnoremap j gj +nnoremap k gk + +" which key +nnoremap :WhichKey '' + +" Very magic by default +nnoremap ? ?\v +nnoremap / /\v +cnoremap %s/ %sm/ + +" Search mappings: These will make it so that going to the next one in a +" search will center on the line it's found in. +nnoremap n nzzzv +nnoremap N Nzzzv + +" Open new file adjacent to current file +nnoremap e :e =expand("%:p:h") . "/" + +" Split Screen +noremap hhh :split +noremap vvv :vsplit + +" Use to trigger completion. +inoremap coc#refresh() + +" Fuzzy Finder +nnoremap ff :FZF -m + +noremap s :Rg +let g:fzf_layout = { 'down': '~20%' } + +"***************************************************************************** +"" End of Key Bindings / Shortcuts +"***************************************************************************** + +"***************************************************************************** +" External Modules +"***************************************************************************** +source $HOME/.config/nvim/src/coc.vim +source $HOME/.config/nvim/src/coc-extensions.vim +source $HOME/.config/nvim/src/fzf.vim + diff --git a/src/.config/nvim/src/coc-extensions.vim b/src/.config/nvim/src/coc-extensions.vim new file mode 100644 index 0000000..d44e316 --- /dev/null +++ b/src/.config/nvim/src/coc-extensions.vim @@ -0,0 +1,33 @@ +let g:coc_global_extensions = [ + \ 'coc-snippets', + \ 'coc-actions', + \ 'coc-sh', + \ 'coc-java-debug', + \ 'coc-java', + \ 'coc-lists', + \ 'coc-emmet', + \ 'coc-tasks', + \ 'coc-pairs', + \ 'coc-tsserver', + \ 'coc-floaterm', + \ 'coc-fzf-preview', + \ 'coc-html', + \ 'coc-css', + \ 'coc-cssmodules', + \ 'coc-stylelintplus', + \ 'coc-emoji', + \ 'coc-bookmark', + \ 'coc-yaml', + \ 'coc-pyright', + \ 'coc-explorer', + \ 'coc-svg', + \ 'coc-prettier', + \ 'coc-vimlsp', + \ 'coc-xml', + \ 'coc-yank', + \ 'coc-json', + \ 'coc-marketplace', + \ ] + " \ 'coc-tabnine', + " \ 'coc-highlight', + diff --git a/src/.config/nvim/src/coc.vim b/src/.config/nvim/src/coc.vim new file mode 100644 index 0000000..0b0631c --- /dev/null +++ b/src/.config/nvim/src/coc.vim @@ -0,0 +1,165 @@ +" Use tab for trigger completion with characters ahead and navigate. +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use to trigger completion. +inoremap coc#refresh() + +" Use to confirm completion, `u` means break undo chain at current +" position. Coc only does snippet and additional edit on confirm. +if exists('*complete_info') + inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" +else + imap pumvisible() ? "\" : "\u\" +endif + +" GoTo code navigation. +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" Use K to show documentation in preview window. +nnoremap K :call show_documentation() + +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + elseif (coc#rpc#ready()) + call CocActionAsync('doHover') + else + execute '!' . &keywordprg . " " . expand('') + endif +endfunction + +" set keywordprg=:call\ CocActionAsync('doHover') +" augroup VimHelp +" autocmd! +" autocmd Filetype vim,help setlocal keywordprg=:help +" augroup END + +" Highlight the symbol and its references when holding the cursor. +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming. +" nmap rn (coc-rename) + +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s). + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder. + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +" Applying codeAction to the selected region. +" Example: `aap` for current paragraph +" xmap a (coc-codeaction-selected) +" nmap a (coc-codeaction-selected) + +" Remap keys for applying codeAction to the current line. +" nmap ac (coc-codeaction) +" Apply AutoFix to problem on the current line. +" nmap qf (coc-fix-current) + +" Introduce function text object +" NOTE: Requires 'textDocument.documentSymbol' support from the language server. +xmap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap if (coc-funcobj-i) +omap af (coc-funcobj-a) + +" Remap and for scroll float windows/popups. +" Note coc#float#scroll works on neovim >= 0.4.3 or vim >= 8.2.0750 +nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" +nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" +inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" +inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" + +" NeoVim-only mapping for visual mode scroll +" Useful on signatureHelp after jump placeholder of snippet expansion +if has('nvim') + vnoremap coc#float#has_scroll() ? coc#float#nvim_scroll(1, 1) : "\" + vnoremap coc#float#has_scroll() ? coc#float#nvim_scroll(0, 1) : "\" +endif + +" Add `:Format` command to format current buffer. +command! -nargs=0 Format :call CocAction('format') + +" Add `:Fold` command to fold current buffer. +command! -nargs=? Fold :call CocAction('fold', ) + +" Add `:OR` command for organize imports of the current buffer. +command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') + +" Add (Neo)Vim's native statusline support. +" NOTE: Please see `:h coc-status` for integrations with external plugins that +" provide custom statusline: lightline.vim, vim-airline. +" set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} + +" Mappings using CoCList: +" Show all diagnostics. +" TODO add these to which key +" nnoremap a :CocList diagnostics +" " Manage extensions. +" nnoremap e :CocList extensions +" " Show commands. +" nnoremap c :CocList commands +" " Find symbol of current document. +" nnoremap o :CocList outline +" " Search workspace symbols. +" nnoremap s :CocList -I symbols +" " Do default action for next item. +" nnoremap j :CocNext +" " Do default action for previous item. +" nnoremap k :CocPrev +" " Resume latest coc list. +" nnoremap p :CocListResume + +" Explorer +let g:coc_explorer_global_presets = { +\ 'floating': { +\ 'position': 'floating', +\ }, +\ 'floatingLeftside': { +\ 'position': 'floating', +\ 'floating-position': 'left-center', +\ 'floating-width': 30, +\ }, +\ 'floatingRightside': { +\ 'position': 'floating', +\ 'floating-position': 'right-center', +\ 'floating-width': 30, +\ }, +\ 'simplify': { +\ 'file.child.template': '[selection | clip | 1] [indent][icon | 1] [filename omitCenter 1]' +\ } +\ } +"nmap e :CocCommand explorer +" nnoremap e :CocCommand explorer +" nmap f :CocCommand explorer --preset floatingRightside +autocmd BufEnter * if (winnr("$") == 1 && &filetype == 'coc-explorer') | q | endif + +" Snippets +" Use for trigger snippet expand. +imap (coc-snippets-expand) + +" Use for select text for visual placeholder of snippet. +vmap (coc-snippets-select) + +" Use for jump to next placeholder, it's default of coc.nvim +let g:coc_snippet_next = '' + +" Use for jump to previous placeholder, it's default of coc.nvim +let g:coc_snippet_prev = '' + +" Use for both expand and jump (make expand higher priority.) +imap (coc-snippets-expand-jump) diff --git a/src/.config/nvim/src/fzf.vim b/src/.config/nvim/src/fzf.vim new file mode 100644 index 0000000..fbb5457 --- /dev/null +++ b/src/.config/nvim/src/fzf.vim @@ -0,0 +1,78 @@ +" This is the default extra key bindings +let g:fzf_action = { + \ 'ctrl-t': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } + +" Enable per-command history. +" CTRL-N and CTRL-P will be automatically bound to next-history and +" previous-history instead of down and up. If you don't like the change, +" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS. +let g:fzf_history_dir = '~/.local/share/fzf-history' +let g:fzf_buffers_jump = 1 + +" map :Files +" map b :Buffers +" nnoremap g :Rg +" nnoremap t :Tags +" nnoremap m :Marks + + +let g:fzf_tags_command = 'ctags -R' +" Border color +let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } } + +let $FZF_DEFAULT_OPTS = '--layout=reverse --inline-info' +let $FZF_DEFAULT_COMMAND="rg --files --hidden --glob '!.git/**'" +"-g '!{node_modules,.git}' + +" Customize fzf colors to match your color scheme +let g:fzf_colors = +\ { 'fg': ['fg', 'Normal'], + \ 'bg': ['bg', 'Normal'], + \ 'hl': ['fg', 'Comment'], + \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'], + \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'], + \ 'hl+': ['fg', 'Statement'], + \ 'info': ['fg', 'PreProc'], + \ 'border': ['fg', 'Ignore'], + \ 'prompt': ['fg', 'Conditional'], + \ 'pointer': ['fg', 'Exception'], + \ 'marker': ['fg', 'Keyword'], + \ 'spinner': ['fg', 'Label'], + \ 'header': ['fg', 'Comment'] } + +"Get Files +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, fzf#vim#with_preview({'options': ['--layout=reverse', '--inline-info']}), 0) + + +" Get text in files with Rg +" command! -bang -nargs=* Rg +" \ call fzf#vim#grep( +" \ "rg --column --line-number --no-heading --color=always --smart-case --glob '!.git/**' ".shellescape(), 1, + + " Make Ripgrep ONLY search file contents and not filenames +command! -bang -nargs=* Rg + \ call fzf#vim#grep( + \ 'rg --column --line-number --hidden --smart-case --no-heading --color=always '.shellescape(), 1, + \ 0 ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%') + \ : fzf#vim#with_preview({'options': '--delimiter : --nth 4.. -e'}, 'right:50%', '?'), + \ 0) + +" Ripgrep advanced +function! RipgrepFzf(query, fullscreen) + let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true' + let initial_command = printf(command_fmt, shellescape(a:query)) + let reload_command = printf(command_fmt, '{q}') + let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]} + call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen) +endfunction + +command! -nargs=* -bang RG call RipgrepFzf(, 0) + +" Git grep +command! -bang -nargs=* GGrep + \ call fzf#vim#grep( + \ 'git grep --line-number '.shellescape(), 0, + \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), 0) diff --git a/src/.config/starship.toml b/src/.config/starship.toml index b1efa66..d246732 100644 --- a/src/.config/starship.toml +++ b/src/.config/starship.toml @@ -1,3 +1,11 @@ +[line_break] +disabled = true + +[character] +success_symbol = "[\\$>](bold green)" +error_symbol = "[\\$>](bold red)" +vicmd_symbol = "[\\$<](bold blue)" + [aws] symbol = " " diff --git a/src/.profile b/src/.profile new file mode 100644 index 0000000..4d8471b --- /dev/null +++ b/src/.profile @@ -0,0 +1,25 @@ +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi + +# include personal scripts/bin +if [ -d "$HOME/scripts/bin" ] ; then + PATH="$HOME/scripts/bin:$PATH" +fi + +source "$HOME/.cargo/env" + diff --git a/src/.vimrc b/src/.vimrc index 10697ca..7434da2 100644 --- a/src/.vimrc +++ b/src/.vimrc @@ -1,110 +1,24 @@ "GENERAL SETTINGS syntax on -set number set autoread -autocmd FocusGained,BufEnter,CursorHold,CursorHoldI * if mode() != 'c' | checktime | endif set clipboard=unnamedplus set tabstop=4 set shiftwidth=4 set softtabstop=4 set expandtab -set updatetime=250 +set updatetime=25 set title set belloff=all - -"KEYBINDINGS -nmap v -nmap v -nmap v -nmap v -vmap -vmap -vmap -vmap -imap v -imap v -imap v -imap v -vmap yi -vmap di -map pi -map v$ -nmap 10j -nmap 10k -imap pi -map u -map i -map ggVG -map "+y -imap :w -map :w -map :bd -map :q! -map :tabnew# -map :source ~/.vimrc - - -" VUNDLE PLUGINS +set number relativenumber +augroup numbertoggle + autocmd! + autocmd BufEnter,FocusGained,InsertLeave * set relativenumber + autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber +augroup END set nocompatible filetype off -set rtp+=~/.vim/bundle/Vundle.vim -call vundle#begin() -Plugin 'VundleVim/Vundle.vim' -Plugin 'morhetz/gruvbox' -Plugin 'dracula/vim',{'name':'dracula'} -Plugin 'rakr/vim-one' -Plugin 'vim-airline/vim-airline' -Plugin 'vim-airline/vim-airline-themes' -Plugin 'airblade/vim-gitgutter' -Plugin 'preservim/nerdtree' -Plugin 'dense-analysis/ale' -Plugin 'tpope/vim-surround' -Plugin 'jiangmiao/auto-pairs' -Plugin 'ycm-core/YouCompleteMe' -" Plugin 'Chiel92/vim-autoformat' -----> sudo apt-get install astyle (for cpp) -call vundle#end() - " PLUGIN PREFERENCES -let g:airline_powerline_fonts = 1 -if !exists('g:airline_symbols') - let g:airline_symbols = {} -endif -let g:airline_left_sep = '»' -let g:airline_left_sep = '▶' -let g:airline_right_sep = '«' -let g:airline_right_sep = '◀' -let g:airline_symbols.linenr = '¶' -let g:airline_symbols.branch = '⎇' -let g:airline_symbols.paste = 'ρ' -let g:airline_symbols.paste = 'Þ' -let g:airline_symbols.paste = '∥' -let g:airline_symbols.whitespace = 'Ξ' -let g:airline_left_sep = '' -let g:airline_left_alt_sep = '' -let g:airline_right_sep = '' -let g:airline_right_alt_sep = '' -let g:airline_symbols.branch = '' -let g:airline_symbols.readonly = '' -let g:airline_symbols.linenr = 'L' -filetype plugin indent on -let g:NERDTreeWinPos = "right" -let g:airline#extensions#tabline#enabled = 1 -let g:airline#extensions#tabline#left_sep = ' ' -let g:airline#extensions#tabline#left_alt_sep = '|' nmap :NERDTreeToggle let NERDTreeShowHidden=1 - -" THEMING -set termguicolors -colorscheme dracula -set background=dark -hi Normal guibg=NONE ctermbg=NONE - - -" CHANGE CURSOR SHAPE BASED ON MODE -" (Only works on VTE-based terminal) -let &t_SI = "\[6 q" -let &t_SR = "\[4 q" -let &t_EI = "\[2 q" diff --git a/src/.xprofile b/src/.xprofile new file mode 100755 index 0000000..d8392dd --- /dev/null +++ b/src/.xprofile @@ -0,0 +1,13 @@ +#!/bin/sh + +# Run at startup +# This file is sourced by Xresources (GDM, LightDM, all source this) +# ------------------------------------------------------------------ + +# Make the keyboard movements faster +xset r rate 340 50 + +# Touchpad necessities +xinput set-prop "ETPS/2 Elantech Touchpad" "libinput Natural Scrolling Enabled" 1 +xinput set-prop "ETPS/2 Elantech Touchpad" "libinput Tapping Enabled" 1 + diff --git a/src/.zprofile b/src/.zprofile new file mode 120000 index 0000000..aa7da3a --- /dev/null +++ b/src/.zprofile @@ -0,0 +1 @@ +.profile \ No newline at end of file diff --git a/src/.zshrc b/src/.zshrc index 19b5edc..c932a45 100644 --- a/src/.zshrc +++ b/src/.zshrc @@ -78,7 +78,7 @@ ex () *.7z) 7z x $1 ;; *.deb) ar x $1 ;; *.tar.xz) tar xf $1 ;; - *.tar.zst) unzstd $1 ;; + *.tar.zst) unzstd $1 ;; *) echo "'$1' cannot be extracted via ex()" ;; esac else @@ -87,7 +87,7 @@ ex () } -### ALIASES ### +### ALIASES ### # =========== # # switch between shells alias tobash="sudo chsh $USER -s /bin/bash && echo 'Now log out.'" @@ -95,7 +95,7 @@ alias tozsh="sudo chsh $USER -s /bin/zsh && echo 'Now log out.'" alias tofish="sudo chsh $USER -s /bin/fish && echo 'Now log out.'" # navigation -alias ..='cd ..' +alias ..='cd ..' alias ...='cd ../..' alias .3='cd ../../..' alias .4='cd ../../../..' @@ -112,15 +112,19 @@ alias mv='mv -i' alias rm='rm -i' alias np='nano -w PKGBUILD' alias more=less -alias ll='ls -alF' -alias la='ls -A' -alias l='ls -CF' + +# Colorize ls output +alias ls='ls --color=auto' +alias ll='ls -alF --color=auto' +alias la='ls -A --color=auto' +alias l='ls -CF --color=auto' # adding flags alias df='df -h' # human-readable sizes alias free='free -m' # show sizes in MB -alias lynx='lynx -cfg=~/.lynx/lynx.cfg -lss=~/.lynx/lynx.lss -vikeys' -alias vifm='./.config/vifm/scripts/vifmrun' + +# programs +alias nv=nvim ## get top process eating memory alias psmem='ps auxf | sort -nr -k 4' @@ -150,12 +154,12 @@ ZSH_AUTOSUGGEST_STRATEGY=(history completion match_prev_cmd) # (MUST be at the end of file) # Install using makefile at ~/.config/zsh... Ditch package managers plugins () { - source ~/.config/zsh/keybindings.zsh + source ~/.config/zsh/keybindings.zsh source ~/.config/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh source ~/.config/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh source ~/.config/zsh/plugins/zsh-completions/zsh-completions.plugin.zsh # Better tab-completion } plugins || make -i -C ~/.config/zsh -export NVM_DIR="/home/purhan/.nvm" -[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh + diff --git a/src/scripts/Makefile b/src/scripts/Makefile index 1bfd0a0..ea5e56a 100644 --- a/src/scripts/Makefile +++ b/src/scripts/Makefile @@ -15,15 +15,14 @@ apt = firefox \ gnome-tweaks \ htop \ vim \ + neovim \ awesome \ python3-pip \ python3-venv \ - fonts-powerline \ npm \ nodejs \ kitty \ zsh \ - fish \ stow \ arandr @@ -52,7 +51,7 @@ essentials: # ================================= # sudo apt install \ git \ - curl \ + curl others: ### SETTING UP SHELLS ### diff --git a/src/scripts/bin/launcher b/src/scripts/bin/launcher new file mode 100755 index 0000000..6da0101 --- /dev/null +++ b/src/scripts/bin/launcher @@ -0,0 +1,321 @@ +#!/usr/bin/env bash +# terminal application launcher for sway, using fzf +# Based on: https://gitlab.com/FlyingWombat/my-scripts/blob/master/sway-launcher +# https://gist.github.com/Biont/40ef59652acf3673520c7a03c9f22d2a +shopt -s nullglob globstar +set -o pipefail +if ! { exec 0>&3; } 1>/dev/null 2>&1; then + exec 3>/dev/null # If file descriptor 3 is unused in parent shell, output to /dev/null +fi +# shellcheck disable=SC2154 +trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR +IFS=$'\n\t' +DEL=$'\34' + +TERMINAL_COMMAND="${TERMINAL_COMMAND:="$TERM -e"}" +GLYPH_COMMAND="${GLYPH_COMMAND- }" +GLYPH_DESKTOP="${GLYPH_DESKTOP- }" +CONFIG_DIR="${XDG_CONFIG_HOME:-$HOME/.config}/sway-launcher-desktop" +PROVIDERS_FILE="${PROVIDERS_FILE:=providers.conf}" +if [[ "${PROVIDERS_FILE#/}" == "${PROVIDERS_FILE}" ]]; then + # $PROVIDERS_FILE is a relative path, prepend $CONFIG_DIR + PROVIDERS_FILE="${CONFIG_DIR}/${PROVIDERS_FILE}" +fi + +# Provider config entries are separated by the field separator \034 and have the following structure: +# list_cmd,preview_cmd,launch_cmd +declare -A PROVIDERS +if [ -f "${PROVIDERS_FILE}" ]; then + eval "$(awk -F= ' + BEGINFILE{ provider=""; } + /^\[.*\]/{sub("^\\[", "");sub("\\]$", "");provider=$0} + /^(launch|list|preview)_cmd/{st = index($0,"=");providers[provider][$1] = substr($0,st+1)} + ENDFILE{ + for (key in providers){ + if(!("list_cmd" in providers[key])){continue;} + if(!("launch_cmd" in providers[key])){continue;} + if(!("preview_cmd" in providers[key])){continue;} + for (entry in providers[key]){ + gsub(/[\x27,\047]/,"\x27\"\x27\"\x27", providers[key][entry]) + } + print "PROVIDERS[\x27" key "\x27]=\x27" providers[key]["list_cmd"] "\034" providers[key]["preview_cmd"] "\034" providers[key]["launch_cmd"] "\x27\n" + } + }' "${PROVIDERS_FILE}")" + if [[ ! -v HIST_FILE ]]; then + HIST_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/${0##*/}-${PROVIDERS_FILE##*/}-history.txt" + fi +else + PROVIDERS['desktop']="${0} list-entries${DEL}${0} describe-desktop \"{1}\"${DEL}${0} run-desktop '{1}' {2}" + PROVIDERS['command']="${0} list-commands${DEL}${0} describe-command \"{1}\"${DEL}${TERMINAL_COMMAND} {1}" + if [[ ! -v HIST_FILE ]]; then + HIST_FILE="${XDG_CACHE_HOME:-$HOME/.cache}/${0##*/}-history.txt" + fi +fi +PROVIDERS['user']="exit${DEL}exit${DEL}{1}" # Fallback provider that simply executes the exact command if there were no matches + +if [[ -n "${HIST_FILE}" ]]; then + mkdir -p "${HIST_FILE%/*}" && touch "$HIST_FILE" + readarray HIST_LINES <"$HIST_FILE" +fi + +function describe() { + # shellcheck disable=SC2086 + readarray -d ${DEL} -t PROVIDER_ARGS <<<${PROVIDERS[${1}]} + # shellcheck disable=SC2086 + [ -n "${PROVIDER_ARGS[1]}" ] && eval "${PROVIDER_ARGS[1]//\{1\}/${2}}" +} +function describe-desktop() { + description=$(sed -ne '/^Comment=/{s/^Comment=//;p;q}' "$1") + echo -e "\033[33m$(sed -ne '/^Name=/{s/^Name=//;p;q}' "$1")\033[0m" + echo "${description:-No description}" +} +function describe-command() { + readarray arr < <(whatis -l "$1" 2>/dev/null) + description="${arr[0]}" + description="${description#* - }" + echo -e "\033[33m${1}\033[0m" + echo "${description:-No description}" +} + +function provide() { + # shellcheck disable=SC2086 + readarray -d ${DEL} -t PROVIDER_ARGS <<<${PROVIDERS[$1]} + eval "${PROVIDER_ARGS[0]}" +} +function list-commands() { + IFS=: read -ra path <<<"$PATH" + for dir in "${path[@]}"; do + printf '%s\n' "$dir/"* | + awk -F / -v pre="$GLYPH_COMMAND" '{print $NF "\034command\034\033[31m" pre "\033[0m" $NF;}' + done | sort -u +} +function list-entries() { + # Get locations of desktop application folders according to spec + # https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html + IFS=':' read -ra DIRS <<<"${XDG_DATA_HOME-${HOME}/.local/share}:${XDG_DATA_DIRS-/usr/local/share:/usr/share}" + for i in "${!DIRS[@]}"; do + if [[ ! -d "${DIRS[i]}" ]]; then + unset -v 'DIRS[$i]' + else + DIRS[$i]="${DIRS[i]}/applications/**/*.desktop" + fi + done + # shellcheck disable=SC2068 + entries ${DIRS[@]} +} +function entries() { + # shellcheck disable=SC2068 + awk -v pre="$GLYPH_DESKTOP" -F= ' + function desktopFileID(filename){ + sub("^.*applications/", "", filename); + sub("/", "-", filename); + return filename + } + BEGINFILE{ + application=0; + block=""; + a=0 + + id=desktopFileID(FILENAME) + if(id in fileIds){ + nextfile; + }else{ + fileIds[id]=0 + } + } + /^\[Desktop Entry\]/{block="entry"} + /^Type=Application/{application=1} + /^\[Desktop Action/{ + sub("^\\[Desktop Action ", ""); + sub("\\]$", ""); + block="action"; + a++; + actions[a,"key"]=$0 + } + /^\[X-/{ + sub("^\\[X-", ""); + sub("\\]$", ""); + block="action"; + a++; + actions[a,"key"]=$0 + } + /^Name=/{ (block=="action")? actions[a,"name"]=$2 : name=$2 } + ENDFILE{ + if (application){ + print FILENAME "\034desktop\034\033[33m" pre name "\033[0m"; + if (a>0) + for (i=1; i<=a; i++) + print FILENAME "\034desktop\034\033[33m" pre name "\033[0m (" actions[i, "name"] ")\034" actions[i, "key"] + } + }' \ + $@ &3)" + echo "Generated Launch command from .desktop file: ${CMD}" >&3 + bash -c "${CMD}" +} +function generate-command() { + # Define the search pattern that specifies the block to search for within the .desktop file + PATTERN="^\\\\[Desktop Entry\\\\]" + if [[ -n $2 ]]; then + PATTERN="^\\\\[Desktop Action ${2}\\\\]" + fi + echo "Searching for pattern: ${PATTERN}" >&3 + # 1. We see a line starting [Desktop, but we're already searching: deactivate search again + # 2. We see the specified pattern: start search + # 3. We see an Exec= line during search: remove field codes and set variable + # 3. We see a Path= line during search: set variable + # 4. Finally, build command line + awk -v pattern="${PATTERN}" -v terminal_cmd="${TERMINAL_COMMAND}" -F= ' + BEGIN{a=0;exec=0;path=0} + /^\[Desktop/{ + if(a){ a=0 } + } + $0 ~ pattern{ a=1 } + /^Terminal=/{ + sub("^Terminal=", ""); + if ($0 == "true") { terminal=1 } + } + /^Exec=/{ + if(a && !exec){ + sub("^Exec=", ""); + gsub(" ?%[cDdFfikmNnUuv]", ""); + exec=$0; + } + } + /^Path=/{ + if(a && !path){ path=$2 } + } + END{ + if(path){ printf "cd " path " && " } + if (terminal){ printf terminal_cmd " " } + print exec + }' "$1" +} + +function autostart() { + for application in $(list-autostart); do + (exec setsid /bin/sh -c "$(run-desktop "${application}")" &>/dev/null &) + done +} + +function list-autostart() { + # Get locations of desktop application folders according to spec + # https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html + IFS=':' read -ra DIRS <<<"${XDG_CONFIG_HOME-${HOME}/.config}:${XDG_CONFIG_DIRS-/etc/xdg}" + for i in "${!DIRS[@]}"; do + if [[ ! -d "${DIRS[i]}" ]]; then + unset -v 'DIRS[$i]' + else + DIRS[$i]="${DIRS[i]}/autostart/*.desktop" + fi + done + + # shellcheck disable=SC2068 + awk -v pre="$GLYPH_DESKTOP" -F= ' + function desktopFileID(filename){ + sub("^.*autostart/", "", filename); + sub("/", "-", filename); + return filename + } + BEGINFILE{ + application=0; + block=""; + a=0 + + id=desktopFileID(FILENAME) + if(id in fileIds){ + nextfile; + }else{ + fileIds[id]=0 + } + } + /^\[Desktop Entry\]/{block="entry"} + /^Type=Application/{application=1} + /^Name=/{ iname=$2 } + ENDFILE{ + if (application){ + print FILENAME; + } + }' \ + ${DIRS[@]} &3 + +FZFPIPE=$(mktemp -u) +mkfifo "$FZFPIPE" +trap 'rm "$FZFPIPE"' EXIT INT + +# Append Launcher History, removing usage count +(printf '%s' "${HIST_LINES[@]#* }" >>"$FZFPIPE") & + +# Iterate over providers and run their list-command +for PROVIDER_NAME in "${!PROVIDERS[@]}"; do + (bash -c "${0} provide ${PROVIDER_NAME}" >>"$FZFPIPE") & +done + +readarray -t COMMAND_STR <<<$( + fzf --ansi +s -x -d '\034' --nth ..3 --with-nth 3 \ + --print-query \ + --preview "$0 describe {2} {1}" \ + --preview-window=up:2:noborder \ + --no-multi --cycle \ + --prompt="${GLYPH_PROMPT-# }" \ + --header='' --no-info --margin='1,2' \ + --color='16,gutter:-1' \ + <"$FZFPIPE" +) || exit 1 +# Get the last line of the fzf output. If there were no matches, it contains the query which we'll treat as a custom command +# If there were matches, it contains the selected item +COMMAND_STR=$(printf '%s\n' "${COMMAND_STR[@]: -1}") +# We still need to format the query to conform to our fallback provider. +# We check for the presence of field separator character to determine if we're dealing with a custom command +if [[ $COMMAND_STR != *$'\034'* ]]; then + COMMAND_STR="${COMMAND_STR}"$'\034user\034'"${COMMAND_STR}"$'\034' + SKIP_HIST=1 # I chose not to include custom commands in the history. If this is a bad idea, open an issue please +fi + +[ -z "$COMMAND_STR" ] && exit 1 + +if [[ -n "${HIST_FILE}" && ! "$SKIP_HIST" ]]; then + # update history + for i in "${!HIST_LINES[@]}"; do + if [[ "${HIST_LINES[i]}" == *" $COMMAND_STR"$'\n' ]]; then + HIST_COUNT=${HIST_LINES[i]%% *} + HIST_LINES[$i]="$((HIST_COUNT + 1)) $COMMAND_STR"$'\n' + match=1 + break + fi + done + if ! ((match)); then + HIST_LINES+=("1 $COMMAND_STR"$'\n') + fi + + printf '%s' "${HIST_LINES[@]}" | sort -nr >"$HIST_FILE" +fi + +# shellcheck disable=SC2086 +readarray -d $'\034' -t PARAMS <<<${COMMAND_STR} +# shellcheck disable=SC2086 +readarray -d ${DEL} -t PROVIDER_ARGS <<<${PROVIDERS[${PARAMS[1]}]} +# Substitute {1}, {2} etc with the correct values +COMMAND=${PROVIDER_ARGS[2]//\{1\}/${PARAMS[0]}} +COMMAND=${COMMAND//\{2\}/${PARAMS[3]}} +COMMAND=${COMMAND%%[[:space:]]} + +if [ -t 1 ]; then + echo "Launching command: ${COMMAND}" >&3 + setsid /bin/sh -c "${COMMAND}" >&/dev/null