From 7e1032434d90db737e319d3eb21721b7fed388be Mon Sep 17 00:00:00 2001 From: marcellus Date: Tue, 2 May 2023 18:30:47 +0200 Subject: add: scripts from ratakor's repo --- scripts/dmenuhandler | 40 ++++++++++++++++++ scripts/dmenuoff | 15 +++++++ scripts/music | 30 +++++++++++++ scripts/musiccmd | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/screenshot | 11 +++++ scripts/test | 1 + scripts/ytdl | 33 +++++++++++++++ 7 files changed, 246 insertions(+) create mode 100755 scripts/dmenuhandler create mode 100755 scripts/dmenuoff create mode 100755 scripts/music create mode 100755 scripts/musiccmd create mode 100755 scripts/screenshot create mode 100644 scripts/test create mode 100755 scripts/ytdl (limited to 'scripts') diff --git a/scripts/dmenuhandler b/scripts/dmenuhandler new file mode 100755 index 0000000..b3eb9c8 --- /dev/null +++ b/scripts/dmenuhandler @@ -0,0 +1,40 @@ +#!/bin/sh +# Feed this script a link and it will give dmenu +# some choice programs to use to open it. + +FEED="${1:-$(printf "" | dmenu -p 'Paste URL or file path')}" + +[ -z "$FEED" ] && exit + +case "$(printf '%s\nbrowser\nmusic\nmpv\nmpv loop\nnsxiv\nPDF\nvim\nyt-dlp\nmusic-dlp' "$FEED" | dmenu -i -p "Open with ")" in + "$FEED") + printf '%s\n' "$FEED" | xclip -selection clipboard ;; # Copy URL + browser) + setsid -f "$BROWSER" "$FEED" >/dev/null 2>&1 ;; + music) + setsid -f music "$FEED" >/dev/null 2>&1 ;; + mpv) + setsid -f mpv --quiet --ytdl-format="bv,ba" "$FEED" >/dev/null 2>&1 ;; + "mpv loop") + setsid -f mpv --quiet --ytdl-format="bv,ba" --loop "$FEED" >/dev/null 2>&1 ;; + nsxiv) + curl -sL "$FEED" > "/tmp/$(echo "$FEED" | sed "s/.*\///;s/%20/ /g")" && + nsxiv -a "/tmp/$(echo "$FEED" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;; + PDF) + curl -sL "$FEED" > "/tmp/$(echo "$FEED" | sed "s/.*\///;s/%20/ /g")" && + zathura "/tmp/$(echo "$FEED" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;; + vim) + curl -sL "$FEED" > "/tmp/$(echo "$FEED" | sed "s/.*\///;s/%20/ /g")" && + setsid -f "$TERMINAL" -e "$EDITOR" "/tmp/$(echo "$FEED" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 ;; + yt-dlp) + setsid -f ytdl v "$FEED" >/dev/null 2>&1 ;; + music-dlp) + if [ "$(printf 'no\nyes' | dmenu -i -p 'Playlist?')" = "yes" ]; then + setsid -f ytdl p "$FEED" >/dev/null 2>&1 + else + setsid -f ytdl m "$FEED" >/dev/null 2>&1 + fi + #setbg) + # curl -sL "$FEED" > "$XDG_CACHE_HOME/pic" && + # hsetroot -cover "$XDG_CACHE_HOME/pic" >/dev/null 2>&1 ;; +esac \ No newline at end of file diff --git a/scripts/dmenuoff b/scripts/dmenuoff new file mode 100755 index 0000000..e278c8a --- /dev/null +++ b/scripts/dmenuoff @@ -0,0 +1,15 @@ +#!/bin/sh +# menu for shutdown or lock +# require nopass for poweroff and reboot and my build of dmenu for -hf + +QUERY=$(printf 'no\nlock\npoweroff\nreboot' | dmenu -i -sb '#cc241d' -hf '#689d6a' -p 'Shutdown?') +ROOTCMD="${ROOTCMD:-$(command -v doas || command -v sudo)}" + +case "$QUERY" in +"lock") + slock ;; +"poweroff") + "$ROOTCMD" poweroff ;; +"reboot") + "$ROOTCMD" reboot ;; +esac \ No newline at end of file diff --git a/scripts/music b/scripts/music new file mode 100755 index 0000000..42ceeeb --- /dev/null +++ b/scripts/music @@ -0,0 +1,30 @@ +#!/bin/sh +# simple music selector with dmenu that uses and interacts with mpv +# have a look at musiccmd, dwmblocks/sb_music and .local/etc/mpv/music +# shellcheck disable=SC2012 + +MUSICDIR="${XDG_MUSIC_DIR:-$HOME/music}" + +if [ "$1" = "--shuffle" ]; then + SHUFFLE=yes + shift +fi + +MUSIC="${1:-$MUSICDIR/$(ls "$MUSICDIR" | dmenu -i -p "Play ")}" +SCRIPT="$XDG_CONFIG_HOME/mpv/music/local.lua" + +if [ "$MUSIC" = "$MUSICDIR/urls" ]; then + MUSIC="$(cat "$MUSICDIR/urls/$(ls "$MUSICDIR/urls" | dmenu -i -p "Play ")")" + SCRIPT="$XDG_CONFIG_HOME/mpv/music/online.lua" +fi + +[ "$MUSIC" = "$MUSICDIR/" ] || [ -z "$MUSIC" ] && exit 1 + +if [ -z "$SHUFFLE" ] && [ -d "$MUSIC" ] || printf '%s' "$MUSIC" | grep -q playlist; then + SHUFFLE="$(printf 'yes\nno' | dmenu -i -p 'Shuffle?')" + [ -z "$SHUFFLE" ] && exit 1 +fi + +printf 'stop\n' | socat - /tmp/mpvsocket 2> /dev/null +mpv --vid=no --input-ipc-server=/tmp/mpvsocket --loop-playlist --volume=75\ + --ytdl-format="wv*+ba" --script="$SCRIPT" --shuffle="$SHUFFLE" "$MUSIC" diff --git a/scripts/musiccmd b/scripts/musiccmd new file mode 100755 index 0000000..73c961b --- /dev/null +++ b/scripts/musiccmd @@ -0,0 +1,116 @@ +#!/bin/sh +# helper for the music script +# dependencies: music, mpv, socat, yt-dlp, ffmpeg, imagemagick +# optional dependencies: dwmblocks, libnotify, herbe + +FAVDIR="${XDG_MUSIC_DIR:-$HOME/Music}/favorite" +DLDIR="${XDG_MUSIC_DIR:-$HOME/Music}/download" +CACHE="${XDG_CACHE_HOME:-$HOME/.cache}" +IMG="nsxiv" + +getpath() { + tmp="$(printf '{ "command": ["get_property", "path"] }\n'\ + | socat - /tmp/mpvsocket)" + tmp="${tmp#{\"data\":\"}" + path="${tmp%\",\"request_id\":0,\"error\":\"success\"\}}" +} + +getvol() { + tmp="$(printf '{ "command": ["get_property", "volume"] }\n'\ + | socat - /tmp/mpvsocket)" + tmp="${tmp#{\"data\":}" + printf '%s\n' "${tmp%.000000,\"request_id\":0,\"error\":\"success\"\}}" +} + +download() { + mkdir -p "$1" + notify-send "Downloading '$path' to '$1'" + if yt-dlp -f "ba" -x --embed-thumbnail --audio-format mp3\ + -o"%(title)s [%(id)s].%(ext)s" -P "$1" "$path"; then + notify-send "'$path' successfuly downloaded to '$2'" + return 0 + else + notify-send "Error: '$path' couldn't be downloaded" + return 1 + fi +} + +addtofav() { + case $path in + *youtube.com*) + download "$FAVDIR" ;; + *) + mkdir -p "$FAVDIR" + if cp "$path" "$FAVDIR"; then + notify-send "'$path' was copied to '$FAVDIR'" + return 0 + else + notify-send "'$path' couldn't be copied to '$FAVDIR'" + return 1 + fi ;; + esac +} + +getthumbnail() { + mkdir -p "$CACHE" + case $path in + *youtube.com*) + yt-dlp --skip-download --force-overwrites --write-thumbnail\ + -o "$CACHE/thumbnail" "$path" > /dev/null 2>&1 &&\ + magick "$CACHE/thumbnail.webp" "$CACHE/thumbnail.jpg" ;; + *) + ffmpeg -y -i "$path" "$CACHE/thumbnail.jpg" 2> /dev/null ;; + esac +} + + +main() { + if ! pgrep -x music >/dev/null; then + kill -35 "$(pidof dwmblocks)" + herbe "Error: There is no music playing"\ + "Do you want to play some ?" && + music + return 1 + fi + + cmd="${1:-$(printf '⏯️pause/play\n⏭️next\n⏮️prev\n📢volume\n🔳stop +⭐favorite\n⬇️download\n🖼️thumbnail' | dmenu -i -p "musiccmd")}" + + case "$cmd" in + cycle|*pause|*play) + printf 'cycle pause\n' | socat - /tmp/mpvsocket + kill -35 "$(pidof dwmblocks)" ;; + *next) + printf 'playlist-next\n' | socat - /tmp/mpvsocket ;; + *prev) + printf 'playlist-prev\n' | socat - /tmp/mpvsocket ;; + *volume) + printf '{ "command": ["set_property", "volume", %s] }\n'\ + "${2:-$(true | dmenu -p "Current volume: $(getvol)")}"\ + | socat - /tmp/mpvsocket 1> /dev/null ;; + *stop) + printf 'stop\n' | socat - /tmp/mpvsocket + kill -35 "$(pidof dwmblocks)" ;; + *favorite|fav) + getpath + addtofav ;; + *download) + getpath + download "$DLDIR" ;; + *thumbnail) + getpath + if getthumbnail; then + $IMG "$CACHE/thumbnail.jpg" + else + notify-send "Error: can't get thumbnail" + return 1 + fi ;; + path) + getpath + printf '%s\n' "$path" ;; + vol) + getvol ;; + esac +} + +main "$@" \ No newline at end of file diff --git a/scripts/screenshot b/scripts/screenshot new file mode 100755 index 0000000..8226205 --- /dev/null +++ b/scripts/screenshot @@ -0,0 +1,11 @@ +#!/bin/sh + +OUTPUT="$XDG_PICTURES_DIR/screenshots/$(date '+%Y-%m-%d_%H:%M:%S').png" +XCLIPCMD="xclip -sel clip -t image/png" + +case "$(printf "save select\nsave screen\ncopy select\ncopy screen" | dmenu -i -p "Screenshot")" in + "copy screen") maim -q -u -d 0.5 | $XCLIPCMD ;; + "save select") maim -u -s "$OUTPUT" ;; + "save screen") maim -q -u -d 0.5 "$OUTPUT" ;; + "copy select") maim -u -s | $XCLIPCMD ;; +esac diff --git a/scripts/test b/scripts/test new file mode 100644 index 0000000..999bef1 --- /dev/null +++ b/scripts/test @@ -0,0 +1 @@ +fzdlfhzdk \ No newline at end of file diff --git a/scripts/ytdl b/scripts/ytdl new file mode 100755 index 0000000..e69cf26 --- /dev/null +++ b/scripts/ytdl @@ -0,0 +1,33 @@ +#!/bin/sh +# wrapper for yt-dlp + +MUSICDIR="${XDG_MUSIC_DIR:-$HOME/Music}" +VIDEODIR="${XDG_VIDEOS_DIR:-$HOME/Videos}" + +case $1 in +v) + mkdir -p "$VIDEODIR" + notify-send "Video download started" + yt-dlp -f 'bv,ba' -o '%(title)s [%(id)s].%(ext)s'\ + -P "$VIDEODIR" "$2" && + notify-send "Video downloaded" || + (notify-send "Error: No internet connection" && exit 1) ;; +m) + mkdir -p "$MUSICDIR/download" + notify-send "Music download started" + yt-dlp -f 'ba' -x --embed-thumbnail --audio-format mp3\ + -o '%(title)s [%(id)s].%(ext)s' -P "$MUSICDIR/download" "$2" && + notify-send "Music downloaded" || + (notify-send "Error: No internet connection" && exit 1) ;; +p) + NAME=$(printf '' | dmenu -p 'Name ') + mkdir -p "$MUSICDIR/$NAME" + notify-send "Playlist download started" + yt-dlp -f 'ba' -x --embed-thumbnail --audio-format mp3\ + -o '%(playlist_index)s - %(title)s [%(id)s].%(ext)s'\ + -P "$MUSICDIR/$NAME" "$2" && + notify-send "Playlist downloaded" || + (notify-send "Error: No internet connection" && exit 1) ;; +*) + exit 1 ;; +esac \ No newline at end of file -- cgit v1.2.3 From 13535011bb12163a4f9035cf2f231e856565e950 Mon Sep 17 00:00:00 2001 From: marcellus Date: Thu, 4 May 2023 00:13:20 +0200 Subject: fix: overall patches --- .gitignore | 4 + dwmblocks/config | 6 +- fontconfig/fonts.conf | 2 +- mpv/input.conf | 6 ++ mpv/music/local.lua | 30 ++++++++ mpv/music/online.lua | 9 +++ mpv/scripts/sponsorblock_minimal.lua | 145 +++++++++++++++++++++++++++++++++++ scripts/musiccmd | 6 +- sxhkd/sxhkdrc | 6 +- zsh/.zshenv | 7 +- 10 files changed, 210 insertions(+), 11 deletions(-) create mode 100644 mpv/input.conf create mode 100644 mpv/music/local.lua create mode 100644 mpv/music/online.lua create mode 100644 mpv/scripts/sponsorblock_minimal.lua (limited to 'scripts') diff --git a/.gitignore b/.gitignore index d9840c3..6b195dd 100644 --- a/.gitignore +++ b/.gitignore @@ -8,10 +8,14 @@ gtk-3.0/ procps/ dconf/ Tracktion/ +qBittorrent/ +vlc/ +MuseScore/ ## trashfiles .zcompdump *~ +QtProject.conf ## other stuff scummvm/ diff --git a/dwmblocks/config b/dwmblocks/config index a0112c5..613e2de 100644 --- a/dwmblocks/config +++ b/dwmblocks/config @@ -1,8 +1,8 @@ /*Name State Update Signal + 34*/ -music = false // 35 +music = true // 35 cputemp = false // 36 fanspeed = false // 37 -memory = true // 38 +memory = false // 38 battery = true // 39 wifi = true // 40 ethernet = false // 41 @@ -13,6 +13,6 @@ mic = false // 45 news = false // 46 mail = false // 47 weather = false // 48 -daypercent = true // 49 +daypercent = false // 49 date = true // 50 time = true // 51 diff --git a/fontconfig/fonts.conf b/fontconfig/fonts.conf index 6867100..903102f 100644 --- a/fontconfig/fonts.conf +++ b/fontconfig/fonts.conf @@ -25,7 +25,7 @@ monospace - Cousine Nerd Font + Cousine Nerd Font Noto Emoji diff --git a/mpv/input.conf b/mpv/input.conf new file mode 100644 index 0000000..c5065c7 --- /dev/null +++ b/mpv/input.conf @@ -0,0 +1,6 @@ +WHEEL_UP add volume 2 +WHEEL_DOWN add volume -2 +l seek 5 +h seek -5 +j seek 60 +k seek -60 \ No newline at end of file diff --git a/mpv/music/local.lua b/mpv/music/local.lua new file mode 100644 index 0000000..dfb9e2d --- /dev/null +++ b/mpv/music/local.lua @@ -0,0 +1,30 @@ +local utils = require "mp.utils" + +function notify_current_media() + local path = mp.get_property_native("path") + local origin, title = utils.split_path(path) + + local metadata = mp.get_property_native("metadata") + if metadata then + function tag(name) + return metadata[string.upper(name)] or metadata[name] + end + + title = tag("title") or title + origin = tag("artist_credit") or tag("artist") or "" + + local album = tag("album") + if album then + origin = string.format("%s — %s", origin, album) + end + + local year = tag("original_year") or tag("year") + if year then + origin = string.format("%s (%s)", origin, year) + end + end + mp.command_native({"run", "pkill", "-RTMIN+1", "dwmblocks"}) + return mp.command_native({"run", "env", "HERBE_ID=/music", "herbe", title, origin}) +end + +mp.register_event("file-loaded", notify_current_media) \ No newline at end of file diff --git a/mpv/music/online.lua b/mpv/music/online.lua new file mode 100644 index 0000000..bcd5d18 --- /dev/null +++ b/mpv/music/online.lua @@ -0,0 +1,9 @@ +local utils = require "mp.utils" + +function notify_current_media(key) + local title = mp.get_property(key) + mp.command_native({"run", "pkill", "-RTMIN+1", "dwmblocks"}) + return mp.command_native({"run", "env", "HERBE_ID=/music", "herbe", title}) +end + +mp.observe_property("media-title", string, notify_current_media) \ No newline at end of file diff --git a/mpv/scripts/sponsorblock_minimal.lua b/mpv/scripts/sponsorblock_minimal.lua new file mode 100644 index 0000000..8ac0cca --- /dev/null +++ b/mpv/scripts/sponsorblock_minimal.lua @@ -0,0 +1,145 @@ +-- sponsorblock_minimal.lua +-- https://codeberg.org/jouni/mpv_sponsorblock_minimal +-- LICENSE: GPLv3 +-- +-- b toggles between on/off +-- +-- This script skips sponsored segments of YouTube videos +-- using data from https://github.com/ajayyy/SponsorBlock + +local opt = require 'mp.options' +local utils = require 'mp.utils' + +local options = { + server = "https://sponsor.ajay.app/api/skipSegments", + + -- Categories to fetch and skip + categories = '"sponsor"', + + -- Set this to "true" to use sha256HashPrefix instead of videoID + hash = "" +} + +opt.read_options(options) + +function getranges(url) + local luacurl_available, cURL = pcall(require,'cURL') + + local res = "" + if not(luacurl_available) then -- if Lua-cURL is not available on this system + local sponsors = mp.command_native{ + name = "subprocess", + capture_stdout = true, + playback_only = false, + args = {"curl", "-L", "-s", "-g", url} + } + res = sponsors.stdout + else -- otherwise use Lua-cURL (binding to libcurl) + local buf={} + local c = cURL.easy_init() + c:setopt_followlocation(1) + c:setopt_url(url) + c:setopt_writefunction(function(chunk) table.insert(buf,chunk); return true; end) + c:perform() + res = table.concat(buf) + end + + local json = utils.parse_json(res) + if options.hash == "true" and json ~= nil then + for _, i in pairs(json) do + if i.videoID == youtube_id then + return i.segments + end + end + else + return json + end + + return nil +end + +function skip_ads(name,pos) + if pos ~= nil then + for _, i in pairs(ranges) do + v = i.segment[2] + if i.segment[1] <= pos and v > pos then + --this message may sometimes be wrong + --it only seems to be a visual thing though + mp.osd_message(("[sponsorblock] skipping forward %ds"):format(math.floor(v-mp.get_property("time-pos")))) + --need to do the +0.01 otherwise mpv will start spamming skip sometimes + --example: https://www.youtube.com/watch?v=4ypMJzeNooo + mp.set_property("time-pos",v+0.01) + return + end + end + end + return +end + +function file_loaded() + local video_path = mp.get_property("path", "") + local video_referer = string.match(mp.get_property("http-header-fields", ""), "Referer:([^,]+)") or "" + + local urls = { + "ytdl://youtu%.be/([%w-_]+).*", + "ytdl://w?w?w?%.?youtube%.com/v/([%w-_]+).*", + "https?://youtu%.be/([%w-_]+).*", + "https?://w?w?w?%.?youtube%.com/v/([%w-_]+).*", + "/watch.*[?&]v=([%w-_]+).*", + "/embed/([%w-_]+).*", + "^ytdl://([%w-_]+)$", + "-([%w-_]+)%." + } + youtube_id = nil + local purl = mp.get_property("metadata/by-key/PURL", "") + for i,url in ipairs(urls) do + youtube_id = youtube_id or string.match(video_path, url) or string.match(video_referer, url) or string.match(purl, url) + end + + if not youtube_id or string.len(youtube_id) < 11 then return end + youtube_id = string.sub(youtube_id, 1, 11) + + local url = "" + if options.hash == "true" then + local sha = mp.command_native{ + name = "subprocess", + capture_stdout = true, + args = {"sha256sum"}, + stdin_data = youtube_id + } + url = ("%s/%s?categories=[%s]"):format(options.server, string.sub(sha.stdout, 0, 4), options.categories) + else + url = ("%s?videoID=%s&categories=[%s]"):format(options.server, youtube_id, options.categories) + end + + ranges = getranges(url) + if ranges ~= nil then + ON = true + mp.add_key_binding("b","sponsorblock",toggle) + mp.observe_property("time-pos", "native", skip_ads) + end + return +end + +function end_file() + if not ON then return end + mp.unobserve_property(skip_ads) + ranges = nil + ON = false +end + +function toggle() + if ON then + mp.unobserve_property(skip_ads) + mp.osd_message("[sponsorblock] off") + ON = false + return + end + mp.observe_property("time-pos", "native", skip_ads) + mp.osd_message("[sponsorblock] on") + ON = true + return +end + +mp.register_event("file-loaded", file_loaded) +mp.register_event("end-file", end_file) \ No newline at end of file diff --git a/scripts/musiccmd b/scripts/musiccmd index 73c961b..ecaf437 100755 --- a/scripts/musiccmd +++ b/scripts/musiccmd @@ -3,8 +3,8 @@ # dependencies: music, mpv, socat, yt-dlp, ffmpeg, imagemagick # optional dependencies: dwmblocks, libnotify, herbe -FAVDIR="${XDG_MUSIC_DIR:-$HOME/Music}/favorite" -DLDIR="${XDG_MUSIC_DIR:-$HOME/Music}/download" +FAVDIR="${XDG_MUSIC_DIR:-$HOME/music}/favorite" +DLDIR="${XDG_MUSIC_DIR:-$HOME/music}/download" CACHE="${XDG_CACHE_HOME:-$HOME/.cache}" IMG="nsxiv" @@ -113,4 +113,4 @@ main() { esac } -main "$@" \ No newline at end of file +main "$@" diff --git a/sxhkd/sxhkdrc b/sxhkd/sxhkdrc index 83ee55a..b20942c 100644 --- a/sxhkd/sxhkdrc +++ b/sxhkd/sxhkdrc @@ -17,8 +17,10 @@ XF86AudioMute pamixer -t; kill {F7,super + n,super + shift + n} $TERMINAL -e {dmenurecord,lfub "$XDG_DATA_HOME/notes",newsboat} -super + {m, shift + m} - {music,musiccmd} +{super + m, XF86Tools} + music +super + shift + m + musiccmd XF86Audio{Prev,Next,Play,Stop} musiccmd {prev,next,cycle,stop} super + {s,a,y,w,e} diff --git a/zsh/.zshenv b/zsh/.zshenv index 5ff4c81..c168554 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -1,2 +1,5 @@ -PATH="$HOME/.config/scripts:$PATH" -TERMINAL="st" +export PATH="$HOME/.config/scripts:$PATH" +export TERMINAL="st" +export EDITOR="emacs" + +export XDG_CONFIG_HOME="$HOME/.config" -- cgit v1.2.3 From 8ce30a9db3677de3f90c3f404bb6c93a4f64936a Mon Sep 17 00:00:00 2001 From: marcellus Date: Thu, 4 May 2023 19:38:38 +0200 Subject: feat: added script to select either music or musiccmd depending on whether mpv is already running or not --- scripts/selectopt | 5 +++++ sxhkd/sxhkdrc | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100755 scripts/selectopt (limited to 'scripts') diff --git a/scripts/selectopt b/scripts/selectopt new file mode 100755 index 0000000..eff605f --- /dev/null +++ b/scripts/selectopt @@ -0,0 +1,5 @@ +# !/bin/sh +# a script to select whether music or musiccmd should be called, +# depending on whether mpv is already running or not + +pidof mpv >/dev/null && musiccmd || music \ No newline at end of file diff --git a/sxhkd/sxhkdrc b/sxhkd/sxhkdrc index b20942c..199ad3c 100644 --- a/sxhkd/sxhkdrc +++ b/sxhkd/sxhkdrc @@ -17,10 +17,12 @@ XF86AudioMute pamixer -t; kill {F7,super + n,super + shift + n} $TERMINAL -e {dmenurecord,lfub "$XDG_DATA_HOME/notes",newsboat} -{super + m, XF86Tools} +super + m music super + shift + m musiccmd +XF86Tools + selectopt XF86Audio{Prev,Next,Play,Stop} musiccmd {prev,next,cycle,stop} super + {s,a,y,w,e} -- cgit v1.2.3 From e3ac37b99035567aedbb6d44a1151049a572f9ee Mon Sep 17 00:00:00 2001 From: marcellus Date: Wed, 10 May 2023 20:34:08 +0200 Subject: fix: minor changes --- .gitignore | 1 + dwmblocks/config | 2 +- htop/htoprc | 8 ++--- mpv/mpv.conf | 1 + scripts/dmenusearch | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++ sxhkd/sxhkdrc | 4 +-- zsh/.zshenv | 2 ++ zsh/.zshrc | 1 + 8 files changed, 112 insertions(+), 7 deletions(-) create mode 100644 mpv/mpv.conf create mode 100755 scripts/dmenusearch (limited to 'scripts') diff --git a/.gitignore b/.gitignore index 6b195dd..436061f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ JetBrains/ discord/ github-copilot/ gtk-3.0/ +gtk-2.0/ procps/ dconf/ Tracktion/ diff --git a/dwmblocks/config b/dwmblocks/config index 613e2de..ad869c2 100644 --- a/dwmblocks/config +++ b/dwmblocks/config @@ -1,6 +1,6 @@ /*Name State Update Signal + 34*/ music = true // 35 -cputemp = false // 36 +cputemp = true // 36 fanspeed = false // 37 memory = false // 38 battery = true // 39 diff --git a/htop/htoprc b/htop/htoprc index d23d23f..21bd0a1 100644 --- a/htop/htoprc +++ b/htop/htoprc @@ -40,18 +40,18 @@ column_meters_1=Tasks LoadAverage Uptime column_meter_modes_1=2 2 2 tree_view=1 sort_key=46 -tree_sort_key=49 +tree_sort_key=1 sort_direction=-1 -tree_sort_direction=-1 +tree_sort_direction=1 tree_view_always_by_pid=0 all_branches_collapsed=0 screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command .sort_key=PERCENT_CPU -.tree_sort_key=TIME +.tree_sort_key=Command .tree_view=1 .tree_view_always_by_pid=0 .sort_direction=-1 -.tree_sort_direction=-1 +.tree_sort_direction=1 .all_branches_collapsed=0 screen:I/O=PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command .sort_key=IO_RATE diff --git a/mpv/mpv.conf b/mpv/mpv.conf new file mode 100644 index 0000000..f7d945c --- /dev/null +++ b/mpv/mpv.conf @@ -0,0 +1 @@ +stop-screensaver = "no" \ No newline at end of file diff --git a/scripts/dmenusearch b/scripts/dmenusearch new file mode 100755 index 0000000..b1ed9d6 --- /dev/null +++ b/scripts/dmenusearch @@ -0,0 +1,100 @@ +#!/bin/sh +# search web, arch wiki, aur, youtube man pages or emoji with dmenu +# websearch dependencies : shuf, curl, /tmp needs to be temporary +# wiki dependency: arch-wiki-docs +# youtube dependency: ytfzf +# man dependencies: man-db, zathura +# emoji dependency: xclip + +set -e + +web() { + NETWORK=clearnet # clearnet, tor or i2p + if [ ! -f "/tmp/instances" ]; then + curl -s "https://librex.ratakor.com/instances.json" > /tmp/instances.json || + (notify-send "No internet connection"; exit 1) + + strip() { + tmp="${1##" \"$NETWORK\": \""}" + printf '%s\n' "${tmp%%"\","}" + } + + while IFS= read -r line || [ -n "$line" ]; do + case $line in + *"$NETWORK"*null,) + continue ;; + *"$NETWORK"*) + strip "$line" >> /tmp/instances ;; + esac + done < /tmp/instances.json + fi + + instance="$(shuf -n 1 /tmp/instances)" + query="${instance}search.php?q=${1:-$(printf "" | dmenu -p "Search:" -l 0)}&t=0" +} + +wiki() { + WIKIDIR="/usr/share/doc/arch-wiki/html/en" + + strip() { + tmp="${1##"$WIKIDIR/"}" + printf '\n%s' "${tmp%%".html"}" + } + + for file in "$WIKIDIR"/*.html; do + [ -f "$file" ] || continue + wikidocs="$wikidocs$(strip "$file")" + done + + wikidocs="${wikidocs#* +}" # remove a trailing newline + + query="$WIKIDIR/$(printf '%s\n' "$wikidocs" | sed -e 's/_/ /g' | sort |\ + dmenu -i -l 10 -p 'Search Wiki: ').html" + query="$(printf '%s\n' "$query" | sed 's/ /_/g')" # separate otherwise set -e fails +} + +aur() { + AURSITE="https://aur.archlinux.org/packages?O=0&K=" + query="$AURSITE$(printf "" | dmenu -p "AUR:" -l 0)" +} + +manpdf() { + INPUT=${1:-$(/usr/bin/man -k . | dmenu -i -l 20 | awk '{print $1}')} + [ -n "$INPUT" ] && /usr/bin/man -Tpdf "$INPUT" | zathura - +} + +emoji() { + CHOSEN=$(cut -d ';' -f1 "$XDG_DATA_HOME/emoji" | dmenu -i -l 30 | sed "s/ .*//") + + [ -z "$CHOSEN" ] && return 1 + + printf '%s' "$CHOSEN" | xclip -selection clipboard + # notify-send "'$CHOSEN' copied to clipboard." +} + +main() { + case ${1:-$(printf 'web\naur\nyoutube\nman\nemoji' | dmenu -i)} in + web) + web "$2" ;; + #wiki) + # wiki ;; + aur) + aur ;; + youtube) + ytfzf -D + return ;; + man) + manpdf "$2" + return ;; + emoji) + emoji + return ;; + *) + return 1 ;; + esac + + "$BROWSER" "$query" 2> /dev/null +} + +main "$@" \ No newline at end of file diff --git a/sxhkd/sxhkdrc b/sxhkd/sxhkdrc index 199ad3c..97e3410 100644 --- a/sxhkd/sxhkdrc +++ b/sxhkd/sxhkdrc @@ -15,8 +15,8 @@ XF86AudioLowerVolume pamixer -d 5; kill -44 $(pidof dwmblocks) XF86AudioMute pamixer -t; kill -{F7,super + n,super + shift + n} - $TERMINAL -e {dmenurecord,lfub "$XDG_DATA_HOME/notes",newsboat} +{super + n,super + shift + n} + $TERMINAL -e {lfub "$XDG_DATA_HOME/notes",newsboat} super + m music super + shift + m diff --git a/zsh/.zshenv b/zsh/.zshenv index c168554..d0d02ef 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -1,5 +1,7 @@ export PATH="$HOME/.config/scripts:$PATH" export TERMINAL="st" export EDITOR="emacs" +export BROWSER="librewolf" export XDG_CONFIG_HOME="$HOME/.config" +export XDG_DATA_HOME="$HOME/data" diff --git a/zsh/.zshrc b/zsh/.zshrc index f8c830d..efbfb96 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -22,6 +22,7 @@ alias ascii="ascii -d" alias cf="$HOME/.config/" alias cspt="$HOME/.config/scripts" alias cz="$HOME/.config/zsh" +alias gs="git status" autoload -U compinit zstyle ':completion:*' menu select -- cgit v1.2.3 From d9bcc3bf93ff3192818c20770dec6b9198cf0ae7 Mon Sep 17 00:00:00 2001 From: marcellus Date: Thu, 11 May 2023 23:16:00 +0200 Subject: feat/fix: minor adjustments and addition of a new dmenu script --- dwmblocks/config | 4 ++-- htop/htoprc | 8 ++++---- scripts/dmenutimer | 6 ++++++ scripts/speedtest | 8 ++++++++ sxhkd/sxhkdrc | 4 +++- zsh/.zshenv | 2 ++ zsh/.zshrc | 2 ++ 7 files changed, 27 insertions(+), 7 deletions(-) create mode 100755 scripts/dmenutimer create mode 100755 scripts/speedtest (limited to 'scripts') diff --git a/dwmblocks/config b/dwmblocks/config index ad869c2..a75740d 100644 --- a/dwmblocks/config +++ b/dwmblocks/config @@ -1,8 +1,8 @@ /*Name State Update Signal + 34*/ music = true // 35 -cputemp = true // 36 +cputemp = false // 36 fanspeed = false // 37 -memory = false // 38 +memory = true // 38 battery = true // 39 wifi = true // 40 ethernet = false // 41 diff --git a/htop/htoprc b/htop/htoprc index 21bd0a1..dff7b74 100644 --- a/htop/htoprc +++ b/htop/htoprc @@ -40,24 +40,24 @@ column_meters_1=Tasks LoadAverage Uptime column_meter_modes_1=2 2 2 tree_view=1 sort_key=46 -tree_sort_key=1 +tree_sort_key=46 sort_direction=-1 tree_sort_direction=1 tree_view_always_by_pid=0 all_branches_collapsed=0 screen:Main=PID USER PRIORITY NICE M_VIRT M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command .sort_key=PERCENT_CPU -.tree_sort_key=Command +.tree_sort_key=PERCENT_CPU .tree_view=1 .tree_view_always_by_pid=0 .sort_direction=-1 .tree_sort_direction=1 .all_branches_collapsed=0 screen:I/O=PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command -.sort_key=IO_RATE +.sort_key=IO_PRIORITY .tree_sort_key=PID .tree_view=0 .tree_view_always_by_pid=0 -.sort_direction=-1 +.sort_direction=1 .tree_sort_direction=1 .all_branches_collapsed=0 diff --git a/scripts/dmenutimer b/scripts/dmenutimer new file mode 100755 index 0000000..0def2e1 --- /dev/null +++ b/scripts/dmenutimer @@ -0,0 +1,6 @@ +#!/bin/sh +# dmenu script for an arttime timer + +TIME=$(printf '' | dmenu -i -sb '#FCFBF4' -nb "#000000" -p 'New timer: ') + +st -e arttime --nolearn --random all --style 1 -t "Timer" -g $TIME diff --git a/scripts/speedtest b/scripts/speedtest new file mode 100755 index 0000000..a93b63a --- /dev/null +++ b/scripts/speedtest @@ -0,0 +1,8 @@ +#!/bin/sh +# usage: time speedtest cmd + +i=0 +while [ $i -lt 100000 ]; do + "$@" + i=$((i+1)) +done diff --git a/sxhkd/sxhkdrc b/sxhkd/sxhkdrc index 97e3410..705c75c 100644 --- a/sxhkd/sxhkdrc +++ b/sxhkd/sxhkdrc @@ -33,5 +33,7 @@ super + u dmenuhandler "$(xclip -o)" {super + shift + u,button2} plumber --sel +super + t + dmenutimer button9 - xdo kill \ No newline at end of file + xdo kill diff --git a/zsh/.zshenv b/zsh/.zshenv index d0d02ef..1075e19 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -5,3 +5,5 @@ export BROWSER="librewolf" export XDG_CONFIG_HOME="$HOME/.config" export XDG_DATA_HOME="$HOME/data" +# Following line was automatically added by arttime installer +export PATH="$HOME/.local/bin:$PATH" diff --git a/zsh/.zshrc b/zsh/.zshrc index efbfb96..6c7e5c9 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -23,6 +23,8 @@ alias cf="$HOME/.config/" alias cspt="$HOME/.config/scripts" alias cz="$HOME/.config/zsh" alias gs="git status" +alias rps="echo help | nc ratakor.com 9998" +alias nv="nvim" autoload -U compinit zstyle ':completion:*' menu select -- cgit v1.2.3 From 7796cbf9687b8355755f3002372e8fe86c06616a Mon Sep 17 00:00:00 2001 From: marcellus Date: Fri, 12 May 2023 00:31:43 +0200 Subject: fix: minor fixes on dmenutimer, it's now floating and spawns at the center of your screen --- scripts/dmenutimer | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/dmenutimer b/scripts/dmenutimer index 0def2e1..9a28f04 100755 --- a/scripts/dmenutimer +++ b/scripts/dmenutimer @@ -1,6 +1,6 @@ #!/bin/sh # dmenu script for an arttime timer -TIME=$(printf '' | dmenu -i -sb '#FCFBF4' -nb "#000000" -p 'New timer: ') +TIME=$(printf '' | dmenu -i -sb '#4E3524' -p 'New timer: ') -st -e arttime --nolearn --random all --style 1 -t "Timer" -g $TIME +st -c "arttime" -e arttime --nolearn --random all --style 1 -t "Timer" -g $TIME -- cgit v1.2.3 From 13673af51e280878478940148971717491822ffc Mon Sep 17 00:00:00 2001 From: marcellus Date: Fri, 12 May 2023 17:49:56 +0200 Subject: fix: small patch of dmenutimer --- scripts/dmenutimer | 2 +- zsh/.zshrc | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/dmenutimer b/scripts/dmenutimer index 9a28f04..00ccb4e 100755 --- a/scripts/dmenutimer +++ b/scripts/dmenutimer @@ -3,4 +3,4 @@ TIME=$(printf '' | dmenu -i -sb '#4E3524' -p 'New timer: ') -st -c "arttime" -e arttime --nolearn --random all --style 1 -t "Timer" -g $TIME +st -c "arttime" -o - -e arttime --nolearn --random all --style 1 -t "Timer" -g $TIME 2>/dev/null | grep goal diff --git a/zsh/.zshrc b/zsh/.zshrc index 6c7e5c9..6f2b0b5 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -25,6 +25,7 @@ alias cz="$HOME/.config/zsh" alias gs="git status" alias rps="echo help | nc ratakor.com 9998" alias nv="nvim" +alias cdmnt="sudo mount -t iso9660 -o ro /dev/sr0 $HOME/cdrom" autoload -U compinit zstyle ':completion:*' menu select -- cgit v1.2.3