From 374863da12fdaabb531ce967ab0a9faca5cae9ba Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Sat, 27 Aug 2022 14:24:14 +0300 Subject: [PATCH] Update 27.08.2022 --- .config/X11/xresources | 36 +++++++++++++ .config/awesome/rc.lua | 95 ++++++++++++++++++---------------- .config/nsxiv/exec/image-info | 21 ++++++++ .config/nsxiv/exec/key-handler | 40 ++++++++++++++ .config/nsxiv/exec/nsxiv-url | 32 ++++++++++++ .config/nsxiv/exec/thumb-info | 20 +++++++ .config/nsxiv/exec/win-title | 27 ++++++++++ .config/sx/sxrc | 1 + 8 files changed, 227 insertions(+), 45 deletions(-) create mode 100644 .config/X11/xresources create mode 100755 .config/nsxiv/exec/image-info create mode 100755 .config/nsxiv/exec/key-handler create mode 100644 .config/nsxiv/exec/nsxiv-url create mode 100755 .config/nsxiv/exec/thumb-info create mode 100755 .config/nsxiv/exec/win-title diff --git a/.config/X11/xresources b/.config/X11/xresources new file mode 100644 index 00000000..9ef9cbaa --- /dev/null +++ b/.config/X11/xresources @@ -0,0 +1,36 @@ +! special +*.foreground: #d8dee9 +*.background: #1d1f21 +*.cursorColor: #d8dee9 + +! black +*.color0: #2d2d2d +*.color8: #444444 + +! red +*.color1: #ed0b0b +*.color9: #b55454 + +! green +*.color2: #40a62f +*.color10: #78a670 + +! yellow +*.color3: #f2e635 +*.color11: #faf380 + +! blue +*.color4: #327bd1 +*.color12: #68a7d4 + +! magenta +*.color5: #b30ad0 +*.color13: #c583d0 + +! cyan +*.color6: #32d0fc +*.color14: #8adaf1 + +! white +*.color7: #555555 +*.color15: #e0e3e7 diff --git a/.config/awesome/rc.lua b/.config/awesome/rc.lua index 09e4cf3c..b27ab148 100644 --- a/.config/awesome/rc.lua +++ b/.config/awesome/rc.lua @@ -7,9 +7,8 @@ local batteryarc_widget = require("awesome-wm-widgets.batteryarc-widget.batterya local cpu_widget = require("awesome-wm-widgets.cpu-widget.cpu-widget") local brightness_widget = require("awesome-wm-widgets.brightness-widget.brightness") local spotify_widget = require("awesome-wm-widgets.spotify-widget.spotify") -local volume_widget = require("awesome-wm-widgets.volume-widget.volume") +local spotify_shell = require("awesome-wm-widgets.spotify-shell.spotify-shell") local calendar_widget = require("awesome-wm-widgets.calendar-widget.calendar") -local logout_menu_widget = require("awesome-wm-widgets.logout-menu-widget.logout-menu") local net_speed_widget = require("awesome-wm-widgets.net-speed-widget.net-speed") local ram_widget = require("awesome-wm-widgets.ram-widget.ram-widget") local weather_widget = require("awesome-wm-widgets.weather-widget.weather") @@ -26,6 +25,7 @@ local beautiful = require("beautiful") local naughty = require("naughty") local menubar = require("menubar") local hotkeys_popup = require("awful.hotkeys_popup") + -- Enable hotkeys help widget for VIM and other apps -- when client with a matching name is opened: require("awful.hotkeys_popup.keys") @@ -97,41 +97,41 @@ end beautiful.init(gears.filesystem.get_configuration_dir() .. "mytheme.lua") -- This is used later as the default terminal and editor to run. -terminal = "alacritty" -editor = os.getenv("EDITOR") or "nvim" -editor_cmd = terminal .. " -e " .. editor +local terminal = "alacritty" +local editor = os.getenv("EDITOR") or "nvim" +local editor_cmd = terminal .. " -e " .. editor -- Default modkey. -- Usually, Mod4 is the key with a logo between Control and Alt. -- If you do not like this or do not have such a key, -- I suggest you to remap Mod4 to another key using xmodmap or other tools. -- However, you can use another modifier like Mod1, but it may interact with others. -modkey = "Mod4" +local modkey = "Mod4" -- Table of layouts to cover with awful.layout.inc, order matters. awful.layout.layouts = { awful.layout.suit.tile, - awful.layout.suit.spiral.dwindle, - awful.layout.suit.spiral, - --awful.layout.suit.floating, - --awful.layout.suit.tile.left, - --awful.layout.suit.tile.bottom, - --awful.layout.suit.tile.top, + awful.layout.suit.tile.left, awful.layout.suit.fair, - --awful.layout.suit.fair.horizontal, - --awful.layout.suit.max, - --awful.layout.suit.max.fullscreen, - --awful.layout.suit.magnifier, - --awful.layout.suit.corner.nw, - --awful.layout.suit.corner.ne, - --awful.layout.suit.corner.sw, - --awful.layout.suit.corner.se, + awful.layout.suit.fair.horizontal, + awful.layout.suit.tile.top, + awful.layout.suit.tile.bottom, + --[[ awful.layout.suit.spiral.dwindle, ]] + --[[ awful.layout.suit.spiral, ]] + --[[ awful.layout.suit.floating, ]] + --[[ awful.layout.suit.max, ]] + --[[ awful.layout.suit.max.fullscreen, ]] + --[[ awful.layout.suit.magnifier, ]] + --[[ awful.layout.suit.corner.nw, ]] + --[[ awful.layout.suit.corner.ne, ]] + --[[ awful.layout.suit.corner.sw, ]] + --[[ awful.layout.suit.corner.se, ]] } -- }}} -- {{{ Menu -- Create a launcher widget and a main menu -myawesomemenu = { +local myawesomemenu = { { "hotkeys", function() @@ -149,10 +149,10 @@ myawesomemenu = { }, } -mymainmenu = +local mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon }, { "open terminal", terminal } } }) -mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu }) +-- local mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon, menu = mymainmenu }) -- Menubar configuration menubar.utils.terminal = terminal -- Set the terminal for applications that require it @@ -163,12 +163,13 @@ menubar.utils.terminal = terminal -- Set the terminal for applications that requ -- {{{ Wibar -- Create a textclock widget -mytextclock = wibox.widget.textclock() +local mytextclock = wibox.widget.textclock(" %d.%m.%Y, %H:%M:%S, %j ", 1) + local cw = calendar_widget({ theme = "nord", placement = "top_right", - previous_month_button = 4, - next_month_button = 5, + previous_month_button = 1, + next_month_button = 3, }) mytextclock:connect_signal("button::press", function(_, _, _, button) @@ -295,6 +296,9 @@ awful.screen.connect_for_each_screen(function(s) ram_widget(), net_speed_widget(), spotify_widget({ + font = "JetBrainsMono NF 10", + play_icon = "/usr/share/icons/Papirus-Light/24x24/categories/spotify.svg", + pause_icon = "/usr/share/icons/Papirus-Dark/24x24/panel/spotify-indicator.svg", dim_when_paused = true, dim_opacity = 0.5, max_lenght = -1, @@ -334,7 +338,7 @@ root.buttons(gears.table.join( -- }}} -- {{{ Key bindings -globalkeys = gears.table.join( +local globalkeys = gears.table.join( awful.key({}, "#233", function() brightness_widget:inc() @@ -353,6 +357,14 @@ globalkeys = gears.table.join( awful.spawn.with_shell("pulsemixer --toggle-mute") end), -- mute awful.key({}, "#172", function() + awful.spawn.with_shell("sp play") + end), -- play/pause + + awful.key({ modkey }, "d", function() + spotify_shell.launch() + end, { description = "spotify shell", group = "media controls" }), + + awful.key({ "Control" }, "#172", function() awful.spawn.with_shell("playerctl -a play-pause") end), -- play/pause @@ -466,7 +478,7 @@ globalkeys = gears.table.join( end, { description = "show the menubar", group = "launcher" }) ) -clientkeys = gears.table.join( +local clientkeys = gears.table.join( awful.key({ modkey }, "f", function(c) c.fullscreen = not c.fullscreen c:raise() @@ -551,7 +563,7 @@ for i = 1, 9 do ) end -clientbuttons = gears.table.join( +local clientbuttons = gears.table.join( awful.button({}, 1, function(c) c:emit_signal("request::activate", "mouse_click", { raise = true }) end), @@ -559,7 +571,7 @@ clientbuttons = gears.table.join( c:emit_signal("request::activate", "mouse_click", { raise = true }) awful.mouse.client.move(c) end), - awful.button({ modkey }, 3, function(c) + awful.button({ modkey, "Control" }, 1, function(c) c:emit_signal("request::activate", "mouse_click", { raise = true }) awful.mouse.client.resize(c) end) @@ -581,9 +593,9 @@ awful.rules.rules = { focus = awful.client.focus.filter, raise = true, keys = clientkeys, - -- buttons = clientbuttons, + buttons = clientbuttons, screen = awful.screen.preferred, - --placement = awful.placement.no_overlap+awful.placement.no_offscreen + placement = awful.placement.no_overlap + awful.placement.no_offscreen, }, }, @@ -602,6 +614,7 @@ awful.rules.rules = { "Wpa_gui", "veromix", "xtightvncviewer", + "Nsxiv", }, -- Note that the name property shown in xprop might be set slightly after creation of the client @@ -615,30 +628,22 @@ awful.rules.rules = { "pop-up", -- e.g. Google Chrome's (detached) Developer Tools. }, }, - properties = { floating = true, beautiful.useless }, + properties = { floating = true, placement = awful.placement.centered, beautiful.useless }, }, -- Add titlebars to normal clients and dialogs { rule_any = { type = { "normal", "dialog" } }, properties = { titlebars_enabled = false } }, { - rule_any = { - class = { "tuxedo-control-center", "corectrl" }, - }, + rule_any = { class = { "tuxedo-control-center", "corectrl" } }, properties = { screen = 1, tag = "7" }, }, { - rule_any = { - class = { "Thunderbird", "discord", "ripcord", "TelegramDesktop" }, - }, + rule_any = { class = { "Thunderbird", "discord", "ripcord", "TelegramDesktop" } }, properties = { screen = 1, tag = "8" }, }, - { - rule_any = { - class = { "Spotify" }, - }, - properties = { screen = 1, tag = "9" }, - }, + { rule_any = { class = { "Spotify" } }, properties = { screen = 1, tag = "9" } }, + { rule_any = { class = { "mpv" } }, properties = { fullscreen = true } }, -- Set Firefox to always map on the tag named "2" on screen 1. -- { rule = { class = "Firefox" }, diff --git a/.config/nsxiv/exec/image-info b/.config/nsxiv/exec/image-info new file mode 100755 index 00000000..5f061235 --- /dev/null +++ b/.config/nsxiv/exec/image-info @@ -0,0 +1,21 @@ +#!/bin/sh + +# Example for $XDG_CONFIG_HOME/nsxiv/exec/image-info +# Called by nsxiv(1) whenever an image gets loaded. +# The output is displayed in nsxiv's status bar. +# Arguments: +# $1: path to image file (as provided by the user) +# $2: image width +# $3: image height +# $4: fully resolved path to the image file + +s=" " # field separator + +exec 2>/dev/null + +filename=$(basename -- "$1") +filesize=$(du -Hh -- "$1" | cut -f 1) +geometry="${2}x${3}" + +echo "${filesize}${s}${geometry}${s}${filename}" + diff --git a/.config/nsxiv/exec/key-handler b/.config/nsxiv/exec/key-handler new file mode 100755 index 00000000..4b711bef --- /dev/null +++ b/.config/nsxiv/exec/key-handler @@ -0,0 +1,40 @@ +#!/bin/sh + +# Example for $XDG_CONFIG_HOME/nsxiv/exec/key-handler +# Called by nsxiv(1) after the external prefix key (C-x by default) is pressed. +# The next key combo is passed as its first argument. Passed via stdin are the +# images to act upon: all marked images, if in thumbnail mode and at least one +# image has been marked, otherwise the current image. nsxiv(1) will block until +# the handler terminates. It then checks which images have been modified and +# reloads them. + +# By default nsxiv(1) will send one image per-line to stdin, however when using +# -0 the image list will be NULL separated and the enviornment variable +# "$NSXIV_USING_NULL" will be set to 1. + +# The key combo argument has the following form: "[C-][M-][S-]KEY", +# where C/M/S indicate Ctrl/Meta(Alt)/Shift modifier states and KEY is the X +# keysym as listed in /usr/include/X11/keysymdef.h without the "XK_" prefix. +# If KEY has an uppercase equivalent, S-KEY is resolved into it. For instance, +# K replaces S-k and Scedilla replaces S-scedilla, but S-Delete is sent as-is. + +rotate() { + degree="$1" + tr '\n' '\0' | xargs -0 realpath | sort | uniq | while read file; do + case "$(file -b -i "$file")" in + image/jpeg*) jpegtran -rotate "$degree" -copy all -outfile "$file" "$file" ;; + *) mogrify -rotate "$degree" "$file" ;; + esac + done +} + +case "$1" in + "C-x") xclip -in -filter | tr '\n' ' ' | xclip -in -selection clipboard ;; + "C-c") while read file; do xclip -selection clipboard -target image/png "$file"; done ;; + "C-e") while read file; do urxvt -bg "#444" -fg "#eee" -sl 0 -title "$file" -e sh -c "exiv2 pr -q -pa '$file' | less" & done ;; + "C-g") tr '\n' '\0' | xargs -0 gimp & ;; + "C-r") while read file; do rawtherapee "$file" & done ;; + "C-comma") rotate 270 ;; + "C-period") rotate 90 ;; + "C-slash") rotate 180 ;; +esac diff --git a/.config/nsxiv/exec/nsxiv-url b/.config/nsxiv/exec/nsxiv-url new file mode 100644 index 00000000..21740935 --- /dev/null +++ b/.config/nsxiv/exec/nsxiv-url @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +cache_dir="${TMPDIR:-/tmp}/nsxiv" + +die() { + [ -n "$1" ] && printf '%s\n' "$*" >&2; + exit 1 +} + +cleanup() { + rm -f -- "$cache_dir"/* +} + +get_image() ( + cd "$cache_dir" && curl -sSLO "$1" +) + +### main ### + +[ -z "$1" ] && die "No arguments given" +trap cleanup EXIT +[ -d "$cache_dir" ] || mkdir -p -- "$cache_dir" || die +while [ -n "$1" ]; do + case "$1" in + *://*.*) get_image "$1" ;; + *) echo "Invalid url: $1" >&2 ;; + esac + shift +done + +[ "$(find "$cache_dir" -type f -print | wc -l)" -ne 0 ] && +nsxiv -p "$cache_dir" diff --git a/.config/nsxiv/exec/thumb-info b/.config/nsxiv/exec/thumb-info new file mode 100755 index 00000000..b422f9c1 --- /dev/null +++ b/.config/nsxiv/exec/thumb-info @@ -0,0 +1,20 @@ +#!/bin/sh + +# Example for $XDG_CONFIG_HOME/nsxiv/exec/thumb-info +# Called by nsxiv(1) whenever the selected thumbnail changes. +# The output is displayed in nsxiv's status bar. +# Arguments: +# $1: path to image file (as provided by the user) +# $2: empty +# $3: empty +# $4: fully resolved path to the image file + +s=" " # field separator + +exec 2>/dev/null + +filename=$(basename -- "$4") +filesize=$(du -Hh -- "$4" | cut -f 1) + +echo "${filesize}${s}${filename}" + diff --git a/.config/nsxiv/exec/win-title b/.config/nsxiv/exec/win-title new file mode 100755 index 00000000..31994ef5 --- /dev/null +++ b/.config/nsxiv/exec/win-title @@ -0,0 +1,27 @@ +#!/bin/sh + +# Example for $XDG_CONFIG_HOME/nsxiv/exec/win-title +# Called by nsxiv(1) whenever any of the relevant information changes. +# The output is set as nsxiv's window title. +# +# Arguments, "Optional" arguments might be empty: +# $1: resolved absolute path of the current file +# $2: current file number +# $3: total file number +# $4: image width (Optional: Disabled on thumbnails mode) +# $5: image height (Optional: Disabled on thumbnails mode) +# $6: current zoom (Optional: Disabled on thumbnails mode) +# +# The term file is used rather than image as nsxiv does not +# precheck that the input files are valid images. Total file +# count may be different from the actual count of valid images. + +exec 2>/dev/null + +filename="${1##*/}" + +if [ -n "$4" ]; then # image mode + printf "%s" "nsxiv - ${filename} | ${4}x${5} ${6}% [${2}/${3}]" +else + printf "%s" "nsxiv - ${filename} [${2}/${3}]" +fi diff --git a/.config/sx/sxrc b/.config/sx/sxrc index 08ea1aa7..87a0dda0 100755 --- a/.config/sx/sxrc +++ b/.config/sx/sxrc @@ -7,5 +7,6 @@ for program in $autostart; do done >/dev/null 2>&1 numlockx on & +xrdb -load $XDG_CONFIG_HOME/X11/xresources & exec dbus-launch --sh-syntax --exit-with-session awesome