diff --git a/awesome/init.fnl b/awesome/init.fnl index 237f8dd..d6b17a0 100644 --- a/awesome/init.fnl +++ b/awesome/init.fnl @@ -65,7 +65,7 @@ (fn get-volume [?callback] (let [cb (or ?callback (fn [] nil))] - (awful.spawn.easy_async_with_shell "pamixer --get-volume" cb))) + (awful.spawn.easy_async_with_shell "pamixer --get-volume-human" cb))) ;; Table of layouts to cover with awful.layout.inc, order matters. (set awful.layout.layouts [ @@ -426,6 +426,6 @@ (awful.spawn.with_shell "flameshot") (awful.spawn.with_shell "caffeine") (awful.spawn.with_shell "nextcloud --background") -(awful.spawn.with_shell "emacs --daemon") +(awful.spawn.with_shell "emacs --with-profile --daemon default") (awful.spawn.with_shell "libinput-gestures-setup start") (awful.spawn.with_shell "bluetoothctl power on") diff --git a/awesome/keybindings.fnl b/awesome/keybindings.fnl index f861e7d..a0a99c3 100644 --- a/awesome/keybindings.fnl +++ b/awesome/keybindings.fnl @@ -10,6 +10,10 @@ (local ctrl "Control") (local alt "Mod1") +(fn get-volume [?callback] + (let [cb (or ?callback (fn [] nil))] + (awful.spawn.easy_async_with_shell "pamixer --get-volume-human" cb))) + (local keybindings { :globalkeys (gears.table.join @@ -74,7 +78,7 @@ {:description "restore minimized" :group "client"}) ;; Prompt - (awful.key [ modkey ] "r" (fn [] (: (. (awful.screen.focused) :mypromptbox) :run)) + (awful.key [ modkey ] "r" (fn [] (awful.spawn "/home/chris/.dotfiles/rofi/launchers-git/run.sh")) {:description "run prompt" :group "launcher"}) (awful.key [ modkey ] "x" (fn [] @@ -90,6 +94,10 @@ ;; utilities (awful.key [] "Print" (fn [] (awful.spawn "flameshot gui")) {:description "screenshot" :group "utilities"}) + (awful.key [ modkey ] "." (fn [] (awful.spawn "/home/chris/.dotfiles/rofi/launchers-git/emoji.sh")) + {:description "emoji picker" :group "utilities"}) + (awful.key [ modkey ] "v" (get-volume) + {:description "See current volume" :group "audio" }) ;; Menubar ;; (awful.key [ modkey ] "p" (fn [] (menubar.show)) ;; {:description "show the menubar" :group "launcher"}) @@ -99,6 +107,8 @@ {:description "launch dired in new emacs frame" :group "apps" }) (awful.key [ modkey ] "i" (fn [] (awful.spawn "emacsclient -c -e '(mu4e)'")) {:description "launch mu4e in new emacs frame" :group "apps" }) + (awful.key [ modkey shift ] "Return" (fn [] (awful.spawn "emacsclient -c -e '(+eshell/frame)'")) + {:description "launch eshell in new emacs frame" :group "apps" }) (awful.key [ modkey ] "e" (fn [] (awful.spawn "emacsclient -c -a 'emacs'")) {:description "launch new emacs frame" :group "apps" }) ;; rofi diff --git a/awesome/rules.fnl b/awesome/rules.fnl index 415390e..3daf65d 100644 --- a/awesome/rules.fnl +++ b/awesome/rules.fnl @@ -20,12 +20,15 @@ } } - ;; floating and centered + ;; floating and centered videos from mpv or firefox pnp { :rule_any { :class [ "mpv" ] + :name [ + "Picture-in-Picture" + ] } :properties { :floating true @@ -35,6 +38,23 @@ :placement (+ awful.placement.no_offscreen awful.placement.centered) } } + ;; sxiv floating on main screen for quick picture viewing + { + :rule_any { + :class [ + "sxiv" + "Sxiv" + ] + } + :properties { + :floating true + :raise true + :height 900 + :width 1500 + :placement (+ awful.placement.no_offscreen awful.placement.centered) + } + } + ;; Tell qb to open primarily on the secondary monitor { :rule_any { :class [ @@ -45,6 +65,7 @@ :screen (screen.count) } } + ;; floating windows { :rule_any { :class [ diff --git a/fish/config.fish b/fish/config.fish index 627fe79..c4078d3 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -1,6 +1,6 @@ #!/usr/bin/env fish -set -U fish_user_paths $fish_user_paths $HOME/.local/bin $HOME/scripts +set -U fish_user_paths $fish_user_paths $HOME/.local/bin $HOME/scripts $HOME/.doom-emacs/bin set TERM "xterm-256color" set EDITOR "emacsclient -t -a" set VISUAL "emacsclient -c -a emacs" diff --git a/mpv/mpv.conf b/mpv/mpv.conf index 4aa8847..b6c247e 100644 --- a/mpv/mpv.conf +++ b/mpv/mpv.conf @@ -4,3 +4,6 @@ af=scaletempo2 speed=2 autofit=70% geometry=50%:50% + +[ytdl] +ytdl-format="bestvideo[height<=720]+bestaudio/best" diff --git a/mpv/scripts/youtube-quality.lua b/mpv/scripts/youtube-quality.lua new file mode 100644 index 0000000..dabd4f2 --- /dev/null +++ b/mpv/scripts/youtube-quality.lua @@ -0,0 +1,275 @@ +-- youtube-quality.lua +-- +-- Change youtube video quality on the fly. +-- +-- Diplays a menu that lets you switch to different ytdl-format settings while +-- you're in the middle of a video (just like you were using the web player). +-- +-- Bound to ctrl-f by default. + +local mp = require 'mp' +local utils = require 'mp.utils' +local msg = require 'mp.msg' +local assdraw = require 'mp.assdraw' + +local opts = { + --key bindings + toggle_menu_binding = "ctrl+f", + up_binding = "k", + down_binding = "j", + select_binding = "ENTER", + + --formatting / cursors + selected_and_active = "▶ - ", + selected_and_inactive = "● - ", + unselected_and_active = "▷ - ", + unselected_and_inactive = "○ - ", + + --font size scales by window, if false requires larger font and padding sizes + scale_playlist_by_window=false, + + --playlist ass style overrides inside curly brackets, \keyvalue is one field, extra \ for escape in lua + --example {\\fnUbuntu\\fs10\\b0\\bord1} equals: font=Ubuntu, size=10, bold=no, border=1 + --read http://docs.aegisub.org/3.2/ASS_Tags/ for reference of tags + --undeclared tags will use default osd settings + --these styles will be used for the whole playlist. More specific styling will need to be hacked in + -- + --(a monospaced font is recommended but not required) + style_ass_tags = "{\\fnmonospace}", + + --paddings for top left corner + text_padding_x = 5, + text_padding_y = 5, + + --other + menu_timeout = 10, + + --use youtube-dl to fetch a list of available formats (overrides quality_strings) + fetch_formats = true, + + --default menu entries + quality_strings=[[ + [ + {"4320p" : "bestvideo[height<=?4320p]+bestaudio/best"}, + {"2160p" : "bestvideo[height<=?2160]+bestaudio/best"}, + {"1440p" : "bestvideo[height<=?1440]+bestaudio/best"}, + {"1080p" : "bestvideo[height<=?1080]+bestaudio/best"}, + {"720p" : "bestvideo[height<=?720]+bestaudio/best"}, + {"480p" : "bestvideo[height<=?480]+bestaudio/best"}, + {"360p" : "bestvideo[height<=?360]+bestaudio/best"}, + {"240p" : "bestvideo[height<=?240]+bestaudio/best"}, + {"144p" : "bestvideo[height<=?144]+bestaudio/best"} + ] + ]], +} +(require 'mp.options').read_options(opts, "youtube-quality") +opts.quality_strings = utils.parse_json(opts.quality_strings) + +local destroyer = nil + + +function show_menu() + local selected = 1 + local active = 0 + local current_ytdl_format = mp.get_property("ytdl-format") + msg.verbose("current ytdl-format: "..current_ytdl_format) + local num_options = 0 + local options = {} + + + if opts.fetch_formats then + options, num_options = download_formats() + end + + if next(options) == nil then + for i,v in ipairs(opts.quality_strings) do + num_options = num_options + 1 + for k,v2 in pairs(v) do + options[i] = {label = k, format=v2} + if v2 == current_ytdl_format then + active = i + selected = active + end + end + end + end + + --set the cursor to the currently format + for i,v in ipairs(options) do + if v.format == current_ytdl_format then + active = i + selected = active + break + end + end + + function selected_move(amt) + selected = selected + amt + if selected < 1 then selected = num_options + elseif selected > num_options then selected = 1 end + timeout:kill() + timeout:resume() + draw_menu() + end + function choose_prefix(i) + if i == selected and i == active then return opts.selected_and_active + elseif i == selected then return opts.selected_and_inactive end + + if i ~= selected and i == active then return opts.unselected_and_active + elseif i ~= selected then return opts.unselected_and_inactive end + return "> " --shouldn't get here. + end + + function draw_menu() + local ass = assdraw.ass_new() + + ass:pos(opts.text_padding_x, opts.text_padding_y) + ass:append(opts.style_ass_tags) + + for i,v in ipairs(options) do + ass:append(choose_prefix(i)..v.label.."\\N") + end + + local w, h = mp.get_osd_size() + if opts.scale_playlist_by_window then w,h = 0, 0 end + mp.set_osd_ass(w, h, ass.text) + end + + function destroy() + timeout:kill() + mp.set_osd_ass(0,0,"") + mp.remove_key_binding("move_up") + mp.remove_key_binding("move_down") + mp.remove_key_binding("select") + mp.remove_key_binding("escape") + destroyer = nil + end + timeout = mp.add_periodic_timer(opts.menu_timeout, destroy) + destroyer = destroy + + mp.add_forced_key_binding(opts.up_binding, "move_up", function() selected_move(-1) end, {repeatable=true}) + mp.add_forced_key_binding(opts.down_binding, "move_down", function() selected_move(1) end, {repeatable=true}) + mp.add_forced_key_binding(opts.select_binding, "select", function() + destroy() + mp.set_property("ytdl-format", options[selected].format) + reload_resume() + end) + mp.add_forced_key_binding(opts.toggle_menu_binding, "escape", destroy) + + draw_menu() + return +end + +local ytdl = { + path = "youtube-dl", + searched = false, + blacklisted = {} +} + +format_cache={} +function download_formats() + local function exec(args) + local ret = utils.subprocess({args = args}) + return ret.status, ret.stdout, ret + end + + local function table_size(t) + s = 0 + for i,v in ipairs(t) do + s = s+1 + end + return s + end + + local url = mp.get_property("path") + + url = string.gsub(url, "ytdl://", "") -- Strip possible ytdl:// prefix. + + -- don't fetch the format list if we already have it + if format_cache[url] ~= nil then + local res = format_cache[url] + return res, table_size(res) + end + mp.osd_message("fetching available formats with youtube-dl...", 60) + + if not (ytdl.searched) then + local ytdl_mcd = mp.find_config_file("youtube-dl") + if not (ytdl_mcd == nil) then + msg.verbose("found youtube-dl at: " .. ytdl_mcd) + ytdl.path = ytdl_mcd + end + ytdl.searched = true + end + + local command = {ytdl.path, "--no-warnings", "--no-playlist", "-J"} + table.insert(command, url) + local es, json, result = exec(command) + + if (es < 0) or (json == nil) or (json == "") then + mp.osd_message("fetching formats failed...", 1) + msg.error("failed to get format list: " .. err) + return {}, 0 + end + + local json, err = utils.parse_json(json) + + if (json == nil) then + mp.osd_message("fetching formats failed...", 1) + msg.error("failed to parse JSON data: " .. err) + return {}, 0 + end + + res = {} + msg.verbose("youtube-dl succeeded!") + for i,v in ipairs(json.formats) do + if v.vcodec ~= "none" then + local fps = v.fps and v.fps.."fps" or "" + local resolution = string.format("%sx%s", v.width, v.height) + local l = string.format("%-9s %-5s (%-4s / %s)", resolution, fps, v.ext, v.vcodec) + local f = string.format("%s+bestaudio/best", v.format_id) + table.insert(res, {label=l, format=f, width=v.width }) + end + end + + table.sort(res, function(a, b) return a.width > b.width end) + + mp.osd_message("", 0) + format_cache[url] = res + return res, table_size(res) +end + + +-- register script message to show menu +mp.register_script_message("toggle-quality-menu", +function() + if destroyer ~= nil then + destroyer() + else + show_menu() + end +end) + +-- keybind to launch menu +mp.add_key_binding(opts.toggle_menu_binding, "quality-menu", show_menu) + +-- special thanks to reload.lua (https://github.com/4e6/mpv-reload/) +function reload_resume() + local playlist_pos = mp.get_property_number("playlist-pos") + local reload_duration = mp.get_property_native("duration") + local time_pos = mp.get_property("time-pos") + + mp.set_property_number("playlist-pos", playlist_pos) + + -- Tries to determine live stream vs. pre-recordered VOD. VOD has non-zero + -- duration property. When reloading VOD, to keep the current time position + -- we should provide offset from the start. Stream doesn't have fixed start. + -- Decent choice would be to reload stream from it's current 'live' positon. + -- That's the reason we don't pass the offset when reloading streams. + if reload_duration and reload_duration > 0 then + local function seeker() + mp.commandv("seek", time_pos, "absolute") + mp.unregister_event(seeker) + end + mp.register_event("file-loaded", seeker) + end +end diff --git a/picom.conf b/picom.conf index 4b28c04..cad3681 100644 --- a/picom.conf +++ b/picom.conf @@ -150,11 +150,11 @@ fade-exclude = [ # Opacity of inactive windows. (0.1 - 1.0, defaults to 1.0) # inactive-opacity = 1 -inactive-opacity = 0.7; +inactive-opacity = 0.5; # Opacity of window titlebars and borders. (0.1 - 1.0, disabled by default) # frame-opacity = 1.0 -frame-opacity = 0.8; +frame-opacity = 0.75; # Default opacity for dropdown menus and popup menus. (0.0 - 1.0, defaults to 1.0) # menu-opacity = 1.0 @@ -164,7 +164,7 @@ frame-opacity = 0.8; inactive-opacity-override = false; # Default opacity for active windows. (0.0 - 1.0, defaults to 1.0) -active-opacity = 0.8; +active-opacity = 0.75; # Dim inactive windows. (0.0 - 1.0, defaults to 0.0) # inactive-dim = 0.0 diff --git a/qutebrowser/config.py b/qutebrowser/config.py index e65ee40..59969b3 100644 --- a/qutebrowser/config.py +++ b/qutebrowser/config.py @@ -2079,6 +2079,9 @@ c.url.searchengines = {'DEFAULT': 'https://duckduckgo.com/?q={}', 'yt': 'https://yewtu.be/search?q={}', 'mel': 'https://melpa.org/#/?q={}', 'y': 'https://www.youtube.com/results?search_query={}', + 'ama': 'https://smile.amazon.com/s?k={}', + 'aur': 'https://aur.archlinux.org/packages/?O=0&K={}', + 'od': 'https://odysee.com/$/search?q={}', 'aw': 'https://wiki.archlinux.org/index.php?search={}'} ## Page(s) to open at the start. diff --git a/qutebrowser/quickmarks b/qutebrowser/quickmarks index 0b9db87..4023614 100644 --- a/qutebrowser/quickmarks +++ b/qutebrowser/quickmarks @@ -11,3 +11,4 @@ od https://odysee.com/$/following tml https://outlook.office.com/mail/inbox oned https://tfcconnection-my.sharepoint.com/personal/chris_tfcconnection_org/_layouts/15/onedrive.aspx bw https://bitwarden.tfcconnection.org/#/ +coin https://www.coinbase.com/dashboard diff --git a/rofi/launchers-git/emoji.sh b/rofi/launchers-git/emoji.sh index 637d59c..45cc84b 100755 --- a/rofi/launchers-git/emoji.sh +++ b/rofi/launchers-git/emoji.sh @@ -1,17 +1,11 @@ #!/usr/bin/env bash -## Author : Aditya Shakya (adi1090x) -## Mail : adi1090x@gmail.com -## Github : @adi1090x -## Reddit : @adi1090x +if [ $(hostname) = "chris-linuxlaptop" ]; then + style="laptop" + #echo "this is hidpi" +else + style="desktop" + #echo "this is not hidpi" +fi -# Available Styles -# >> Styles Below Only Works With "rofi-git(AUR)", Current Version: 1.5.4-76-gca067234 -# -# blurry blurry_full kde_simplemenu kde_krunner launchpad -# gnome_do slingshot appdrawer appfolder column -# row row_center screen row_dock row_dropdown - -style="blurry" - -rofi -no-lazy-grab -show emoji -theme launchers-git/"$style".rasi +rofi -no-lazy-grab -show emoji -modi emoji -theme launchers-git/"$style".rasi diff --git a/rofi/launchers-git/launcher.sh b/rofi/launchers-git/launcher.sh index c112d9d..a1d9fd5 100755 --- a/rofi/launchers-git/launcher.sh +++ b/rofi/launchers-git/launcher.sh @@ -1,18 +1,5 @@ #!/usr/bin/env bash -## Author : Aditya Shakya (adi1090x) -## Mail : adi1090x@gmail.com -## Github : @adi1090x -## Reddit : @adi1090x - -# Available Styles -# >> Styles Below Only Works With "rofi-git(AUR)", Current Version: 1.5.4-76-gca067234 -# -# blurry blurry_full kde_simplemenu kde_krunner launchpad -# gnome_do slingshot appdrawer appfolder column -# row row_center screen row_dock row_dropdown - - if [ $(hostname) = "chris-linuxlaptop" ]; then style="laptop" #echo "this is hidpi" @@ -21,4 +8,4 @@ else #echo "this is not hidpi" fi -rofi -no-lazy-grab -show drun -modi drun,window,calc,ssh,run,emoji -theme launchers-git/"$style".rasi +rofi -no-lazy-grab -show drun -modi drun -theme launchers-git/"$style".rasi diff --git a/rofi/launchers-git/run.sh b/rofi/launchers-git/run.sh new file mode 100755 index 0000000..f7b7d9c --- /dev/null +++ b/rofi/launchers-git/run.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +if [ $(hostname) = "chris-linuxlaptop" ]; then + style="laptop" + #echo "this is hidpi" +else + style="desktop" + #echo "this is not hidpi" +fi + +rofi -no-lazy-grab -show run -modi run -theme launchers-git/"$style".rasi diff --git a/rofi/launchers-git/windows.sh b/rofi/launchers-git/windows.sh index cd1d8ce..f4af3e1 100755 --- a/rofi/launchers-git/windows.sh +++ b/rofi/launchers-git/windows.sh @@ -1,17 +1,11 @@ #!/usr/bin/env bash -## Author : Aditya Shakya (adi1090x) -## Mail : adi1090x@gmail.com -## Github : @adi1090x -## Reddit : @adi1090x +if [ $(hostname) = "chris-linuxlaptop" ]; then + style="laptop" + #echo "this is hidpi" +else + style="desktop" + #echo "this is not hidpi" +fi -# Available Styles -# >> Styles Below Only Works With "rofi-git(AUR)", Current Version: 1.5.4-76-gca067234 -# -# blurry blurry_full kde_simplemenu kde_krunner launchpad -# gnome_do slingshot appdrawer appfolder column -# row row_center screen row_dock row_dropdown - -style="blurry" - -rofi -no-lazy-grab -show window -modi drun,window,calc,ssh,run,emoji -theme launchers-git/"$style".rasi +rofi -no-lazy-grab -show window -modi window -theme launchers-git/"$style".rasi diff --git a/scripts/lfgimg.fish b/scripts/lfgimg.fish new file mode 100755 index 0000000..3294cfd --- /dev/null +++ b/scripts/lfgimg.fish @@ -0,0 +1,10 @@ +#!/usr/bin/env fish + +for i in [1-10] + set url (curl https://www.lfg.co/page/$i | + rg 'images.txt + curl -o $i.gif $url +end +#wget -O $i diff --git a/scripts/pacprev.sh b/scripts/pacprev.sh new file mode 100755 index 0000000..f96544a --- /dev/null +++ b/scripts/pacprev.sh @@ -0,0 +1,2 @@ +#!/usr/bin/sh +pacman -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)' diff --git a/scripts/rifle-sxiv.sh b/scripts/rifle-sxiv.sh new file mode 100755 index 0000000..0bdd892 --- /dev/null +++ b/scripts/rifle-sxiv.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# Compatible with ranger 1.6.0 through 1.7.* +# +# This script searches image files in a directory, opens them all with sxiv and +# sets the first argument to the first image displayed by sxiv. +# +# This is supposed to be used in rifle.conf as a workaround for the fact that +# sxiv takes no file name arguments for the first image, just the number. Copy +# this file somewhere into your $PATH and add this at the top of rifle.conf: +# +# mime ^image, has sxiv, X, flag f = path/to/this/script -- "$@" +# +# Implementation notes: this script is quite slow because of POSIX limitations +# and portability concerns. First calling the shell function 'abspath' is +# quicker than calling 'realpath' because it would fork a whole process, which +# is slow. Second, we need to append a file list to sxiv, which can only be done +# properly in two ways: arrays (which are not POSIX) or \0 sperated +# strings. Unfortunately, assigning \0 to a variable is not POSIX either (will +# not work in dash and others), so we cannot store the result of listfiles to a +# variable. + +if [ $# -eq 0 ]; then + echo "Usage: ${0##*/} PICTURES" + exit +fi + +[ "$1" = '--' ] && shift + +abspath () { + case "$1" in + /*) printf "%s\n" "$1";; + *) printf "%s\n" "$PWD/$1";; + esac +} + +listfiles () { + find -L "$(dirname "$target")" -maxdepth 1 -type f -iregex \ + '.*\(jpe?g\|bmp\|png\|gif\)$' -print0 | sort -z +} + +target="$(abspath "$1")" +count="$(listfiles | grep -m 1 -ZznF "$target" | cut -d: -f1)" + +if [ -n "$count" ]; then + listfiles | xargs -0 sxiv -n "$count" -- +else + sxiv -- "$@" # fallback +fi diff --git a/todo.org b/todo.org deleted file mode 100644 index 31369cd..0000000 --- a/todo.org +++ /dev/null @@ -1 +0,0 @@ -* Inbox diff --git a/tridactyl/tridactylrc b/tridactyl/tridactylrc index 627ad39..9d61a79 100644 --- a/tridactyl/tridactylrc +++ b/tridactyl/tridactylrc @@ -36,14 +36,23 @@ set searchurls.osm https://www.openstreetmap.org/search?query= set searchurls.mdn https://developer.mozilla.org/en-US/search?q= set searchurls.gentoo_wiki https://wiki.gentoo.org/index.php?title=Special%3ASearch&profile=default&fulltext=Search&search= set searchurls.qwant https://www.qwant.com/?q= -set searchengine ser +set searchengine d " For syntax highlighting see https://github.com/tridactyl/vim-tridactyl " vim: set filetype=tridactyl +" Org Capture +command org-capture js -p tri.excmds.exclaim_quiet('org-capture ' + JS_ARG) + +" Adding my own bindings bind v hint -W mpvsafe bind F hint -w bind gy hint -y bind gc composite get_current_url | org-capture bind gC hint -W org-capture -command org-capture js -p tri.excmds.exclaim_quiet('org-capture ' + JS_ARG) + +" buffers show as windows +bind b bufferall + +" Smoothscroll +set smoothscroll true