chore: cleanup

This commit is contained in:
max_richter 2022-05-04 18:55:48 +02:00
parent 7acbafb7fe
commit 29eed372ff
36 changed files with 172 additions and 1138 deletions

View File

@ -62,6 +62,10 @@ lsp.jsonls.setup {
}
}
lsp.svelte.setup {}
lsp.tsserver.setup {}
lsp.ltex.setup {
cmd = { os.getenv("HOME") .. '/.local/share/nvim/lsp_servers/ltex/ltex-ls/bin/ltex-ls' },
settings = {

View File

@ -1,39 +0,0 @@
#!/bin/bash
set -e
# FEATURES
# - Doesn't show the sink that is already the default
# - Automatically switches all running input sinks when switching the default sink
# Get the current default sink
SINK_DEFAULT=$(pactl info | ag "Default Sink" | ag -o "(?!.*:)[^\s].*")
# Get the audio sink names
SINK_NAMES=$(pactl list sinks | ag Name | cut --complement -c 1-7)
# Get the index of the default sink
DEFAULT_INDEX=$(printf "%s" "$SINK_NAMES" | ag --number "$SINK_DEFAULT" | sed 's/:.*//' )
# Get the audio sink descriptions
SINK_DESCRIPTIONS=$(pactl list sinks | ag Description | cut --complement -c 1-13 | sed 's/^ \+//' | sed 's/ \+$//')
# Get all the programs that revieve the audio from the sinks
SINK_INPUTS=$(pactl list sink-inputs | ag "Sink Input #")
# Get the descriptions from the sinks without the default sink to display to the user and have the user pick a sink
SINK_DESCRIPTION=$(printf "%s" "$SINK_DESCRIPTIONS" | sed "${DEFAULT_INDEX}d" | dmenu -i -fn "Roboto Mono for Powerline-11" -p "Select sink:")
SINK_DESCRIPTION=$(printf "%s" "$SINK_DESCRIPTION" | sed 's/(/\\(/' | sed 's/)/\\)/')
# Get the index for the answer that the user wrote
DESCRIPTION_INDEX=$(printf "%s\n" "$SINK_DESCRIPTIONS" | ag --number "$SINK_DESCRIPTION" | sed 's/:.*//')
DESCRIPTION_INDEX=$((DESCRIPTION_INDEX - 1)) # Correct the index hihi
# Set the default sink
pactl set-default-sink $DESCRIPTION_INDEX
# Change all the ouputs for the programs that are using the default sink
printf "%s\n" "$SINK_INPUTS" | while read -r SINK_INPUT
do
# Get the index for the program
SINK_INPUT_INDEX=$(printf "%s" "$SINK_INPUT" | ag -o "(?!Sink Input#)[0-9]+")
pactl move-sink-input "$SINK_INPUT_INDEX" "$DESCRIPTION_INDEX"
done

View File

@ -1,246 +0,0 @@
#!/usr/bin/env bash
# This script defines just a mode for rofi instead of being a self-contained
# executable that launches rofi by itself. This makes it more flexible than
# running rofi inside this script as now the user can call rofi as one pleases.
# For instance:
#
# rofi -show powermenu -modi powermenu:./rofi-power-menu
#
# See README.md for more information.
set -e
set -u
# All supported choices
all=(shutdown reboot suspend hibernate logout lockscreen)
# By default, show all (i.e., just copy the array)
show=("${all[@]}")
declare -A texts
texts[lockscreen]="lock screen"
texts[switchuser]="switch user"
texts[logout]="log out"
texts[suspend]="suspend"
texts[hibernate]="hibernate"
texts[reboot]="reboot"
texts[shutdown]="shut down"
declare -A icons
icons[lockscreen]="\uf023"
icons[switchuser]="\uf518"
icons[logout]="\uf842"
icons[suspend]="\uf9b1"
icons[hibernate]="\uf7c9"
icons[reboot]="\ufc07"
icons[shutdown]="\uf011"
icons[cancel]="\u00d7"
declare -A actions
actions[lockscreen]="loginctl lock-session ${XDG_SESSION_ID-}"
#actions[switchuser]="???"
actions[logout]="loginctl terminate-session ${XDG_SESSION_ID-}"
actions[suspend]="systemctl suspend"
actions[hibernate]="systemctl hibernate"
actions[reboot]="systemctl reboot"
actions[shutdown]="systemctl poweroff"
# By default, ask for confirmation for actions that are irreversible
confirmations=(reboot shutdown logout)
# By default, no dry run
dryrun=false
showsymbols=true
function check_valid {
option="$1"
shift 1
for entry in "${@}"
do
if [ -z "${actions[$entry]+x}" ]
then
echo "Invalid choice in $1: $entry" >&2
exit 1
fi
done
}
# Parse command-line options
parsed=$(getopt --options=h --longoptions=help,dry-run,confirm:,choices:,choose:,symbols,no-symbols --name "$0" -- "$@")
if [ $? -ne 0 ]; then
echo 'Terminating...' >&2
exit 1
fi
eval set -- "$parsed"
unset parsed
while true; do
case "$1" in
"-h"|"--help")
echo "rofi-power-menu - a power menu mode for Rofi"
echo
echo "Usage: rofi-power-menu [--choices CHOICES] [--confirm CHOICES]"
echo " [--choose CHOICE] [--dry-run] [--symbols|--no-symbols]"
echo
echo "Use with Rofi in script mode. For instance, to ask for shutdown or reboot:"
echo
echo " rofi -show menu -modi \"menu:rofi-power-menu --choices=shutdown/reboot\""
echo
echo "Available options:"
echo " --dry-run Don't perform the selected action but print it to stderr."
echo " --choices CHOICES Show only the selected choices in the given order. Use / "
echo " as the separator. Available choices are lockscreen, logout,"
echo " suspend, hibernate, reboot and shutdown. By default, all"
echo " available choices are shown."
echo " --confirm CHOICES Require confirmation for the gives choices only. Use / as"
echo " the separator. Available choices are lockscreen, logout,"
echo " suspend, hibernate, reboot and shutdown. By default, only"
echo " irreversible actions logout, reboot and shutdown require"
echo " confirmation."
echo " --choose CHOICE Preselect the given choice and only ask for a confirmation"
echo " (if confirmation is set to be requested). It is strongly"
echo " recommended to combine this option with --confirm=CHOICE"
echo " if the choice wouldn't require confirmation by default."
echo " Available choices are lockscreen, logout, suspend,"
echo " hibernate, reboot and shutdown."
echo " --[no-]symbols Show Unicode symbols or not. Requires a font with support"
echo " for the symbols. Use, for instance, fonts from the"
echo " Nerdfonts collection. By default, they are shown"
echo " -h,--help Show this help text."
exit 0
;;
"--dry-run")
dryrun=true
shift 1
;;
"--confirm")
IFS='/' read -ra confirmations <<< "$2"
check_valid "$1" "${confirmations[@]}"
shift 2
;;
"--choices")
IFS='/' read -ra show <<< "$2"
check_valid "$1" "${show[@]}"
shift 2
;;
"--choose")
# Check that the choice is valid
check_valid "$1" "$2"
selectionID="$2"
shift 2
;;
"--symbols")
showsymbols=true
shift 1
;;
"--no-symbols")
showsymbols=false
shift 1
;;
"--")
shift
break
;;
*)
echo "Internal error" >&2
exit 1
;;
esac
done
# Define the messages after parsing the CLI options so that it is possible to
# configure them in the future.
function write_message {
icon="<span font_size=\"medium\">$1</span>"
text="<span font_size=\"medium\">$2</span>"
if [ "$showsymbols" = "true" ]
then
echo -n "\u200e$icon \u2068$text\u2069"
else
echo -n "$text"
fi
}
function print_selection {
echo -e "$1" | $(read -r -d '' entry; echo "echo $entry")
}
declare -A messages
declare -A confirmationMessages
for entry in "${all[@]}"
do
messages[$entry]=$(write_message "${icons[$entry]}" "${texts[$entry]^}")
done
for entry in "${all[@]}"
do
confirmationMessages[$entry]=$(write_message "${icons[$entry]}" "Yes, ${texts[$entry]}")
done
confirmationMessages[cancel]=$(write_message "${icons[cancel]}" "No, cancel")
if [ $# -gt 0 ]
then
# If arguments given, use those as the selection
selection="${@}"
else
# Otherwise, use the CLI passed choice if given
if [ -n "${selectionID+x}" ]
then
selection="${messages[$selectionID]}"
fi
fi
# Don't allow custom entries
echo -e "\0no-custom\x1ftrue"
# Use markup
echo -e "\0markup-rows\x1ftrue"
if [ -z "${selection+x}" ]
then
echo -e "\0prompt\x1fPower menu"
for entry in "${show[@]}"
do
echo -e "${messages[$entry]}\0icon\x1f${icons[$entry]}"
done
else
for entry in "${show[@]}"
do
if [ "$selection" = "$(print_selection "${messages[$entry]}")" ]
then
# Check if the selected entry is listed in confirmation requirements
for confirmation in "${confirmations[@]}"
do
if [ "$entry" = "$confirmation" ]
then
# Ask for confirmation
echo -e "\0prompt\x1fAre you sure"
echo -e "${confirmationMessages[$entry]}\0icon\x1f${icons[$entry]}"
echo -e "${confirmationMessages[cancel]}\0icon\x1f${icons[cancel]}"
exit 0
fi
done
# If not, then no confirmation is required, so mark confirmed
selection=$(print_selection "${confirmationMessages[$entry]}")
fi
if [ "$selection" = "$(print_selection "${confirmationMessages[$entry]}")" ]
then
if [ $dryrun = true ]
then
# Tell what would have been done
echo "Selected: $entry" >&2
else
# Perform the action
${actions[$entry]}
fi
exit 0
fi
if [ "$selection" = "$(print_selection "${confirmationMessages[cancel]}")" ]
then
# Do nothing
exit 0
fi
done
# The selection didn't match anything, so raise an error
echo "Invalid selection: $selection" >&2
exit 1
fi

View File

@ -20,12 +20,11 @@ set $up k
set $right l
# Some menus
set $wofi_scripts ~/.config/wofi
set $quickmenu wofi --show drun
# Screenshot section
set $screenshot_dir ~/Pictures/Screenshots/
set $grimshot ~/.config/sway/grimshot.sh
set $grimshot $sway_scripts/grimshot
set $screenclip wl-copy < "$($grimshot --notify save area $screenshot_dir/scrn-$(date +"%Y-%m-%d-%H-%M-%S").png)"
set $screenshot wl-copy < "$($grimshot --notify save screen $screenshot_dir/scrn-$(date +"%Y-%m-%d-%H-%M-%S").png)"
set $windowshot wl-copy < "$($grimshot --notify save window $screenshot_dir/scrn-$(date +"%Y-%m-%d-%H-%M-%S").png)"
@ -41,20 +40,23 @@ set $bluetooth_mngr blueman-manager
set $calculator flatpak run io.github.Qalculate
set $photo_editor gtk-launch ~/.local/share/applications/photopea.desktop
set $translator com.github.gi_lom.dialect
set $settings gnome-control-center
# Scripts
set $config_editor ~/.config/sway/config_editor.sh
set $debug_window ~/.config/sway/debug_window.sh
set $settings gnome-control-center
set $toggle_layout ~/.config/sway/toggle_layout.sh
set $create_floating ~/.config/sway/create_floating.sh
set $toggle_gaps ~/.config/sway/toggle_gaps.sh
set $toggle_bar ~/.config/sway/toggle_bar.sh
set $web_search $wofi_scripts/web-search.sh
set $select_window ~/.config/sway/select_window.sh
set $lock_screen ~/.config/sway/lock_screen.sh
set $select_emoji $wofi_scripts/wofi-emoji
set $wofi_scripts ~/.config/wofi/scripts/
set $sway_scripts ~/.config/sway/scripts/
set $debug_window $sway_scripts/debug-window
set $toggle_layout $sway_scripts/toggle-layout
set $create_floating $sway_scripts/create-floating
set $toggle_gaps $sway_scripts/toggle-gaps
set $toggle_bar $sway_scripts/toggle-bar
set $select_window $sway_scripts/select-window
set $lock_screen $sway_scripts/lock-screen
set $select_emoji $wofi_scripts/select-emoji
set $open_localhost $wofi_scripts/open-localhost
set $select_wifi $wofi_scripts/select-wifi
# Input configuration
input * {
@ -76,7 +78,7 @@ output * bg `find $wallpapers_path -type f | shuf -n 1` fill
#
# Example configuration:
#
# output HDMI-A-1 resolution 1920x1080 position 1920,0
# output eDP-1 resolution 1920x1080
#
# You can get the names of your outputs by running: swaymsg -t get_outputs
@ -89,8 +91,7 @@ exec swayidle -w \
timeout 600 'swaymsg "output * dpms off"' \
timeout 660 'systemctl suspend' \
resume 'swaymsg "output * dpms on"' \
before-sleep '~/.config/sway/lock_screen.sh'
before-sleep $lock_screen
#
# This will lock your screen after 300 seconds of inactivity, then turn off
@ -118,12 +119,13 @@ input "1739:24385:Synaptics_TM2438-005" {
bindsym $mod+d exec $quickmenu
bindsym $mod+t exec $translator
bindsym $mod+q kill
bindsym $mod+Shift+q exec $wofi_scripts/wofi-power-menu.sh
bindsym $mod+Shift+q exec $wofi_scripts/power-menu
bindsym $mod+Return exec $term
bindsym $mod+Shift+Return exec $create_floating $term
bindsym $mod+e exec $explorer
bindsym $mod+Comma exec $settings
bindsym $mod+b exec $browser
bindsym $mod+Shift+w exec $select_wifi
bindsym $mod+Shift+b exec $bluetooth_mngr
bindsym $mod+Shift+Comma exec $config_editor
bindsym $mod+a exec $web_search
@ -187,7 +189,6 @@ input "1739:24385:Synaptics_TM2438-005" {
for_window [title="Zoom Meeting.*"] inhibit_idle visible
for_window [app_id="firefox" title="^Picture-in-Picture$"] floating enable, move position 1300 600, sticky enable, resize set 600 450
set $ws1 "1:  Code"
assign [app_id="Alacritty"] $ws1
assign [app_id="Kitty"] $ws1
@ -270,7 +271,7 @@ input "1739:24385:Synaptics_TM2438-005" {
bindsym $mod+o exec $open_localhost
bindsym $mod+Control+l exec $lock_screen
bindsym $mod+c exec $calculator
bindsym Alt+Tab exec $select_window
bindsym $mod+Tab exec $select_window
bindsym $mod+m exec $mail
#
# Scratchpad:
@ -315,8 +316,6 @@ mode "resize" {
}
bindsym $mod+r mode "resize"
# Do we need that?
# Handles notifications
exec_always mako
# Start Audio
@ -331,7 +330,6 @@ exec wl-paste -t text --watch clipman store --no-persist
#
# Status Bar:
#
# Read `man 5 sway-bar` for more information about this section.
bar {
swaybar_command waybar
mode dock
@ -339,5 +337,4 @@ bar {
}
include @sysconfdir@/sway/config.d/*
exec "systemctl --user import-environment SWAYSOCK XDG_CURRENT_DESKTOP WAYLAND_DISPLAY";

View File

@ -1,2 +0,0 @@
#!/bin/zsh
alacritty -e zsh -c "/home/jim/.asdf/shims/nvim ~/.dotfiles"

View File

@ -1,4 +1,3 @@
#!/bin/sh
# ------Get available windows:

View File

@ -1,20 +0,0 @@
#!/bin/bash
cd "$(dirname "$0")"
arecord -f cd -t raw -d 4 -q | lame -r -q - output.mp3 2>/dev/null
if [ ! -f "./output.mp3" ]; then
exit 0
fi
JSON=$(songrec audio-file-to-recognized-song output.mp3)
RETRYMS=$(echo $JSON | jq '.retryms')
if [ $RETRYMS != null ]; then
echo $(expr $RETRYMS / 1000)
else
SONG=$(echo $JSON | tr '\r\n' ' ' | jq '.track.share.subject')
echo $SONG
rm -rf output.mp3
fi

View File

@ -5,110 +5,44 @@
"ipc": true,
"mode": "hide",
"hidden_state": "show",
"modules-left": ["custom/clock", "custom/waybar-mpris"],
"modules-center": ["sway/workspaces", "sway/mode"],
"modules-right": ["custom/theme","pulseaudio", "network", "battery"],
"modules-left": [
"clock",
"custom/waybar-mpris"
],
"modules-center": [
"sway/workspaces",
"sway/mode"
],
"modules-right": [
"custom/dpi",
"custom/theme",
"pulseaudio",
"network",
"battery"
],
"sway/workspaces": {
"disable-scroll": true,
"all-outputs": false,
"format": "{name}",
"format-icons": {
"urgent": "",
"focused": "",
"default": ""
}
},
"keyboard-state": {
"numlock": true,
"capslock": true,
"format": "{name} {icon}",
"format-icons": {
"locked": "",
"unlocked": ""
}
"format": "{name}"
},
"custom/theme": {
"exec": "~/.config/waybar/theme.sh",
"on-click": "~/.config/waybar/theme.sh --toggle",
"restart-interval": 1,
"exec": "~/.config/waybar/scripts/toggle-theme",
"on-click": "~/.config/waybar/scripts/toggle-theme --toggle",
"restart-interval": 1
},
"custom/spotify": {
"exec": "/usr/bin/python3 /home/jim/.config/waybar/mediaplayer.py --player spotify",
"format": "{} ",
"return-type": "json",
"on-click": "playerctl play-pause",
"on-scroll-up": "playerctl next",
"on-scroll-down": "playerctl previous"
"custom/dpi": {
"exec": "~/.config/waybar/scripts/toggle-hdpi",
"on-click": "~/.config/waybar/scripts/toggle-hdpi --toggle",
"restart-interval": 1
},
"sway/mode": {
"format": "<span style=\"italic\">{}</span>"
},
"mpd": {
"format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}% ",
"format-disconnected": "",
"format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ",
"unknown-tag": "N/A",
"interval": 2,
"consume-icons": {
"on": " "
},
"random-icons": {
"off": "<span color=\"#f53c3c\"></span> ",
"on": " "
},
"repeat-icons": {
"on": " "
},
"single-icons": {
"on": "1 "
},
"state-icons": {
"paused": "",
"playing": ""
},
"tooltip-format": "MPD (connected)",
"tooltip-format-disconnected": "MPD (disconnected)"
},
"idle_inhibitor": {
"format": "{icon}",
"format-icons": {
"activated": "",
"deactivated": ""
}
},
"tray": {
"spacing": 10
},
"clock": {
"interval": 60,
"format": "{:%H:%M}",
"max-length": 25
},
"custom/clock": {
"exec": "date +'%H:%M'",
"interval": 10,
"on-click": "nm-applet"
},
"cpu": {
"format": "{usage}% ",
"tooltip": false
},
"memory": {
"format": "{}% "
},
"temperature": {
// "thermal-zone": 2,media
// "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input",
"critical-threshold": 80,
// "format-critical": "{temperatureC}°C {icon}",
"format": "{temperatureC}°C {icon}",
"format-icons": ["", "", ""]
},
"backlight": {
// "device": "acpi_video1",
"format": "{percent}% {icon}",
"format-icons": ["", ""]
},
"battery": {
"states": {
"warning": 30,
@ -118,12 +52,13 @@
"format-charging": "{capacity}% ",
"format-plugged": "{capacity}% ",
"format-alt": "{time} {icon}",
// "format-good": "", // An empty format will hide the module
// "format-full": "",
"format-icons": ["", "", "", "", ""]
},
"battery#bat2": {
"bat": "BAT2"
"format-icons": [
"",
"",
"",
"",
""
]
},
"network": {
// "interface": "wlp2*", // (Optional) To force the use of this interface
@ -135,7 +70,6 @@
"format-alt": "{ifname}: {ipaddr}/{cidr}"
},
"pulseaudio": {
// "scroll-step": 1, // %, can be a float
"format": "{volume}% {icon} {format_source}",
"format-bluetooth": "{volume}% {icon} {format_source}",
"format-bluetooth-muted": " {icon} {format_source}",
@ -149,19 +83,14 @@
"phone": "",
"portable": "",
"car": "",
"default": ["", "", ""]
"default": [
"",
"",
""
]
},
"on-click": "pavucontrol"
},
"custom/cpu_speed": {
"interval": 10,
"return-type": "json",
"exec": "~/.config/waybar/cpu_speed.sh",
"format": "<span font='Font Awesome 5 Free 11'>{icon}</span> {}",
"format-icons": [""],
"escape": true,
"on-click": "kitty -e htop"
},
"custom/waybar-mpris": {
"max-length": 30,
"return-type": "json",
@ -176,17 +105,5 @@
// "on-scroll-up": "waybar-mpris --send next",
// "on-scroll-down": "waybar-mpris --send prev",
"escape": true
},
"custom/media": {
"format": "{icon} {}",
"return-type": "json",
"max-length": 40,
"format-icons": {
"spotify": "",
"default": "🎜"
},
"escape": true,
"exec": "$HOME/.config/waybar/mediaplayer.py 2> /dev/null" // Script in resources folder
}
}

View File

@ -1,14 +0,0 @@
#!/bin/bash
class=cpu_speed
speed_mhz=$(lscpu | grep "CPU MHz" | sed --expression "s/CPU MHz:[[:space:]]*//g" | xargs printf "%.*f\n" 0)
# speed_ghz=`echo $(($speed_mhz / 1000))`
speed_ghz=`bc -l <<< "$speed_mhz / 1000"`
info=$(echo $speed_ghz | xargs printf "%.*f\n" 2)
echo -e "{\"text\":\""$info GHz"\", \"class\":\""$class"\"}"

View File

@ -1,13 +0,0 @@
#!/bin/bash
CONFIG_FILES="$HOME/.config/waybar/config $HOME/.config/waybar/*.css $HOME/.config/waybar/*.sh"
killall waybar;
trap "killall waybar" EXIT
while true; do
waybar &
inotifywait -e create,modify $CONFIG_FILES
killall waybar
done

View File

@ -1,130 +0,0 @@
#!/usr/bin/env python3
import argparse
import logging
import sys
import signal
import gi
import json
from os.path import expanduser
gi.require_version('Playerctl', '2.0')
from gi.repository import Playerctl, GLib
logger = logging.getLogger(__name__)
def write_output(text, player):
logger.info('Writing output')
output = {'text': text.replace("\n", " ").strip(),
'class': 'custom-' + player.props.player_name,
'alt': player.props.player_name}
sys.stdout.write(json.dumps(output) + '\n')
sys.stdout.flush()
def on_play(player, _, manager):
logger.info('Received new playback status')
on_metadata(player, player.props.metadata, manager)
def on_metadata(player, metadata, _):
logger.info('Received new metadata')
track_info = ''
if player.props.player_name == 'spotify' and \
'mpris:trackid' in metadata.keys() and \
':ad:' in player.props.metadata['mpris:trackid']:
track_info = 'AD PLAYING'
elif player.get_artist() != '' and player.get_title() != '':
track_info = '{artist} - {title}'.format(artist=player.get_artist(),
title=player.get_title())
else:
track_info = player.get_title()
if player.props.status != 'Playing' and track_info:
track_info = '' + track_info
write_output(track_info, player)
def on_player_appeared(manager, player, selected_player=None):
if player is not None and (selected_player is None or player.name == selected_player):
init_player(manager, player)
else:
logger.debug("New player appeared, but it's not the selected player, skipping")
def on_player_vanished(manager, player):
logger.info('Player has vanished')
sys.stdout.write('\n')
sys.stdout.flush()
def init_player(manager, name):
logger.debug('Initialize player: {player}'.format(player=name.name))
player = Playerctl.Player.new_from_name(name)
player.connect('playback-status', on_play, manager)
player.connect('metadata', on_metadata, manager)
manager.manage_player(player)
on_metadata(player, player.props.metadata, manager)
def signal_handler(sig, frame):
logger.debug('Received signal to stop, exiting')
sys.stdout.write('\n')
sys.stdout.flush()
# loop.quit()
sys.exit(0)
def parse_arguments():
parser = argparse.ArgumentParser()
# Increase verbosity with every occurrence of -v
parser.add_argument('-v', '--verbose', action='count', default=0)
# Define for which player we're listening
parser.add_argument('--player')
return parser.parse_args()
def main():
arguments = parse_arguments()
# Initialize logging
# LOG=expanduser("~")+"/.dotfiles/configs/waybar/media.log"
# logging.basicConfig(level=logging.DEBUG, filename=LOG,
# format='%(name)s %(levelname)s %(message)s')
# Logging is set by default to WARN and higher.
# With every occurrence of -v it's lowered by one
logger.setLevel(max((3 - arguments.verbose) * 10, 0))
logger.setLevel(0)
# Log the sent command line arguments
logger.debug('Arguments received {}'.format(vars(arguments)))
manager = Playerctl.PlayerManager()
loop = GLib.MainLoop()
manager.connect('name-appeared', lambda *args: on_player_appeared(*args, arguments.player))
manager.connect('player-vanished', on_player_vanished)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
for player in manager.props.player_names:
if arguments.player is not None and arguments.player != player.name:
logger.debug('{player} is not the filtered player, skipping it'
.format(player=player.name)
)
continue
init_player(manager, player)
loop.run()
if __name__ == '__main__':
main()

View File

@ -1,146 +0,0 @@
#!/usr/bin/env python3
import argparse
import logging
import sys
import signal
import time
import gi
import json
gi.require_version('Playerctl', '2.0')
from gi.repository import Playerctl, GLib
import subprocess
from os.path import expanduser
home = expanduser("~")
logger = logging.getLogger(__name__)
playerVisible = False
def write_output(text, player_name):
logger.info('Writing output')
output = {'text': text.replace("&", "&amp;"),
'class': 'custom-' + player_name,
'alt': player_name}
sys.stdout.write(json.dumps(output) + '\n')
sys.stdout.flush()
def on_play(player, status, manager):
logger.info('Received new playback status')
on_metadata(player, player.props.metadata, manager)
def on_metadata(player, metadata, manager):
logger.info('Received new metadata')
track_info = ''
if player.props.player_name == 'spotify' and \
'mpris:trackid' in metadata.keys() and \
':ad:' in player.props.metadata['mpris:trackid']:
track_info = 'AD PLAYING'
elif player.get_artist() != '' and player.get_title() != '':
track_info = '{artist} - {title}'.format(artist=player.get_artist(),
title=player.get_title())
else:
track_info = player.get_title()
if player.props.status != 'Playing' and track_info:
track_info = '' + track_info
write_output(track_info, player.props.player_name)
def update_song():
global playerVisible
while not playerVisible:
result = subprocess.run("./capture_mp3.sh",stdout=subprocess.PIPE)
resultString = result.stdout.decode("utf-8")
logger.debug(resultString);
write_output(resultString, "Spotify")
time.sleep(6)
def on_player_appeared(manager, player, selected_player=None):
global playerVisible
if player is not None and (selected_player is None or player.name == selected_player):
playerVisible = True
init_player(manager, player)
else:
logger.debug("New player appeared, but it's not the selected player, skipping")
def on_player_vanished(manager, player):
global playerVisible
logger.info('Player has vanished')
playerVisible = False
update_song()
sys.stdout.write('\n')
sys.stdout.flush()
def init_player(manager, name):
logger.debug('Initialize player: {player}'.format(player=name.name))
player = Playerctl.Player.new_from_name(name)
player.connect('playback-status', on_play, manager)
player.connect('metadata', on_metadata, manager)
update_song()
manager.manage_player(player)
on_metadata(player, player.props.metadata, manager)
def signal_handler(sig, frame):
logger.debug('Received signal to stop, exiting')
sys.stdout.write('\n')
sys.stdout.flush()
loop.quit()
sys.exit(0)
def parse_arguments():
parser = argparse.ArgumentParser()
# Increase verbosity with every occurrence of -v
parser.add_argument('-v', '--verbose', action='count', default=0)
# Define for which player we're listening
parser.add_argument('--player')
return parser.parse_args()
def main():
arguments = parse_arguments()
# Initialize logging
LOG = home+"/.dotfiles/configs/waybar/media.log" logger.setLevel(max((3 - arguments.verbose) * 10, 0))
logging.basicConfig(stream=sys.stderr, filename=LOG, level=logging.DEBUG,
format='%(name)s %(levelname)s %(message)s')
logger.setLevel(0)
# Log the sent command line arguments
logger.debug('Arguments received {}'.format(vars(arguments)))
manager = Playerctl.PlayerManager()
loop = GLib.MainLoop()
manager.connect('name-appeared', lambda *args: on_player_appeared(*args, arguments.player))
manager.connect('player-vanished', on_player_vanished)
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
for player in manager.props.player_names:
if arguments.player is not None and arguments.player != player.name:
logger.debug('{player} is not the filtered player, skipping it'
.format(player=player.name)
)
continue
init_player(manager, player)
update_song()
loop.run()
if __name__ == '__main__':
main()

Binary file not shown.

View File

@ -1,3 +0,0 @@
MAX_FREQ=$(lscpu | grep "CPU max MHz" | sed --expression "s/CPU max MHz:[[:space:]]*//g" | xargs printf "%.*f\n" 0)
CURRENT_MAX_FREG=$(cpufreq-info | grep "c")

View File

@ -1,2 +0,0 @@
#!/bin/bash

View File

@ -0,0 +1,22 @@
#!/bin/sh
CURRENT=$(swaymsg -t get_outputs --raw | jq '.[] | [.current_mode.width, .current_mode.height] | join("x")')
HIGH="ﳍ"
STANDARD="ﳭ"
if [ "$CURRENT" = '"3840x2160"' ]; then
if [ "$1" = "--toggle" ]; then
swaymsg "output eDP-1 mode --custom 1920x1080@60Hz"
killall waybar
nohup waybar
fi
echo $HIGH
elif [ "$CURRENT" = '"1920x1080"' ]; then
if [ "$1" = "--toggle" ]; then
swaymsg "output eDP-1 mode --custom 3840x2160@60Hz"
killall waybar
nohup waybar
fi
echo $STANDARD
fi

View File

@ -3,17 +3,14 @@
DARK_MODE_STATUS_FILE=~/.cache/dark-mode
CURRENT_DARK_MODE=$( cat $DARK_MODE_STATUS_FILE )
LIGHT="☀️"
DARK="🌙"
echo "\$1 $1"
echo "MODE: $CURRENT_DARK_MODE"
LIGHT="盛"
DARK=""
if [ "$1" == "--toggle" ]; then
if [ $CURRENT_DARK_MODE == "light" ]; then
~/.config/waybar/dark-mode.sh dark
~/.config/waybar/scripts/set-theme dark
else
~/.config/waybar/dark-mode.sh light
~/.config/waybar/scripts/set-theme light
fi
fi

View File

@ -4,3 +4,4 @@ width=500
dynamic_lines=true
term=kitty
insensitive=true
layer=overlay

View File

@ -1,8 +1,8 @@
#!/bin/bash
entries="⏻ Shutdown\n Reboot\n⇠ Logout\n⏾ Suspend"
entries="⏻ Shutdown\n Reboot\n⇠ Logout\n⏾ Suspend"
selected=$(echo -e $entries|wofi --width 250 --height 210 --dmenu --cache-file /dev/null | awk '{print tolower($2)}')
selected=$(echo -e $entries|wofi --width 250 --height 150 --dmenu --cache-file /dev/null | awk '{print tolower($2)}')
case $selected in
logout)

View File

@ -1,25 +0,0 @@
#!/usr/bin/env bash
swaymsg -t get_tree | jq -r '
# descend to workspace or scratchpad
.nodes[].nodes[].nodes[]
# save workspace name as .w
| {"w": .name} + (
if .nodes then # workspace
[recurse(.nodes[])]
else # scratchpad
[]
end
+ .floating_nodes
| .[]
# select nodes with no children (windows)
| select(.nodes==[])
)
| ((.id | tostring) + "\t "
# remove markup and index from workspace name, replace scratch with "[S]"
+ (.w | gsub("^[^:]*:|<[^>]*>"; "") | sub("__i3_scratch"; "[S]"))
+ "\t " + .name)
' | wofi --show dmenu| {
read -r id name
swaymsg "[con_id=$id]" focus
}

View File

@ -1,122 +0,0 @@
#!/bin/bash
# Swytch is a script providing a window switcher for sway using rofi, awk and jq.
# The script is based on:
# https://www.reddit.com/r/swaywm/comments/aolf3u/quick_script_for_rofi_alttabbing_window_switcher/
# Copyright (C) 2019 Björn Sonnenschein
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# todo: first, query all existing workspaces from sway and build color dict, so that
# all workspaces always get the same color, even if no windows at some workspace in between exists.
# obtain command to execute with swaymsg for selected window
if [ -z "$1" ]
then
command_=focus
else
command_=$1
fi
# Obtain the avaliable windows' workspaces, names and IDs as strings
mapfile -t windows < <(
swaymsg -t get_tree | jq -r '[
recurse(.nodes[]?)
|recurse(.floating_nodes[]?)
|select(.type=="workspace")
| . as $workspace | recurse(.nodes[]?)
|select(.type=="con" and .name!=null)
|{workspace: $workspace.name, name: .name, id: .id, focused: .focused, app_id: .app_id}]
|sort_by(.workspace, .name)[]
|.workspace + if .focused then "* " else " " end + .app_id + " - " + .name + " " + (.id|tostring)'
)
rm $HOME/.cache/wofi-dmenu
windows_separators=()
colors=(blue green orange red magenta)
workspace_previous=''
index_workspace_active=0
num_separators=0
index_color=0
bold=-1
for index_window in "${!windows[@]}"
do
window="${windows[$index_window]}"
# todo: consider arbitraty workspace name length by separating by space instead of simply taking first argument.
workspace=${window:0:1}
# obtain index of the active window
if [ "${window:1:1}" == "*" ]
then
index_workspace_active=$(($index_window))
fi
# if window has different workspace than previous, use next color. Cycle through colors
if [ "$workspace" != "$workspace_previous" ] && [ ! -z "$workspace_previous" ]
then
index_color=$index_color+1
fi
if (($index_color == ${#colors[@]}))
then
index_color=0
fi
if (( $bold == 1))
then
windows_separators+=("<b><span foreground=\"${colors[$index_color]}\">[${workspace}]</span>${window:1}</b>")
else
windows_separators+=("<span foreground=\"${colors[$index_color]}\">[${workspace}]</span>${window:1}")
fi
workspace_previous=$workspace
done
HEIGHT=$(( $(printf '%s\n' "${windows_separators[@]}" | wc -l) * 30 ))
echo $HEIGHT
# Select window with rofi, obtaining ID of selected window
idx_selected=$(printf '%s\n' "${windows_separators[@]}" | wofi -d -p "$command_" -m -H $HEIGHT )
selected=${windows[$idx_selected]}
id_selected=$(echo $selected | awk '{print $NF}')
workspace_selected=${selected:0:1}
### unmaximize all maximized windows on the workspace of the selected window
# Obtain the avaliable windows' workspaces, names and IDs as strings
mapfile -t ids_windows_maximized < <(
swaymsg -t get_tree | jq -r '[
recurse(.nodes[]?)
|recurse(.floating_nodes[]?)
|select(.type=="workspace")
| . as $workspace | recurse(.nodes[]?)
|select(.type=="con" and .name!=null and .fullscreen_mode==1 and $workspace.name=="'"$workspace_selected"'")
|{workspace: $workspace.name, name: .name, id: .id, focused: .focused, app_id: .app_id}]
|sort_by(.workspace, .name)[]
|(.id|tostring)'
)
# unmaximize the maximized windows that are not the selected one
for id_window_maximized in "${ids_windows_maximized[@]}"
do
if [ "$id_window_maximized" != "$id_selected" ]
then
swaymsg "[con_id=$id_window_maximized] fullscreen disable"
fi
done
# Tell sway to focus said window
# todo: do not execute if selected is the separator
if [ ! -z "$id_selected" ]
then
swaymsg "[con_id=$id_selected] $command_"
fi

View File

@ -1,3 +0,0 @@
#!/bin/bash
rofimoji

View File

@ -1,138 +0,0 @@
#!/usr/bin/env bash
# Source: https://gist.github.com/NearHuscarl/5d366e1a3b788814bcbea62c1f66241d
#
# Use wofi to pick emoji because that's what this
# century is about apparently...
#
# Requirements:
# wofi, wlroots based compositor
#
# Usage:
# 1. Download all emoji
# $ wofi-emoji --download
#
# 2. Run it!
# $ wofi-emoji
#
# Notes:
# * You'll need a emoji font like "Noto Emoji" or "EmojiOne".
# * Confirming an item will automatically paste it WITHOUT
# writing it to your clipboard.
# * Ctrl+C will copy it to your clipboard WITHOUT pasting it.
#
# Where to save the emojis file.
EMOJI_FILE="$HOME/.cache/emojis.txt"
# Urls of emoji to download.
# You can remove what you don't need.
URLS=(
'https://emojipedia.org/people/'
'https://emojipedia.org/nature/'
'https://emojipedia.org/food-drink/'
'https://emojipedia.org/activity/'
'https://emojipedia.org/travel-places/'
'https://emojipedia.org/objects/'
'https://emojipedia.org/symbols/'
'https://emojipedia.org/flags/'
)
function notify() {
if [ "$(command -v notify-send)" ]; then
notify-send "$1" "$2"
fi
}
function download() {
notify "$(basename "$0")" 'Downloading all emoji for your pleasure'
echo "" > "$EMOJI_FILE"
for url in "${URLS[@]}"; do
echo "Downloading: $url"
# Download the list of emoji and remove all the junk around it
emojis=$(curl -s "$url" | \
xmllint --html \
--xpath '//ul[@class="emoji-list"]' - 2>/dev/null)
# Get rid of starting/closing ul tags
emojis=$(echo "$emojis" | head -n -1 | tail -n +1)
# Extract the emoji and its description
emojis=$(echo "$emojis" | \
sed -rn 's/.*<span class="emoji">(.*)<\/span> (.*)<\/a><\/li>/\1 \2/p')
echo "$emojis" >> "$EMOJI_FILE"
done
notify "$(basename "$0")" "We're all set!"
}
function wofi_menu() { # {{{
wofi -width 25 -lines 7 -dmenu -i -p 'emoji: ' \
-kb-row-tab '' \
-kb-row-select Tab \
-kb-custom-1 Ctrl+c
}
# }}}
function repeat() { # {{{
local rplc str="$1" count="$2"
rplc="$(printf "%${count}s")"
echo "${rplc// /"$str"}"
}
# }}}
function toclipboard() { # {{{
wl-copy
}
# }}}
function pastedirectly() { #{{{
wtype -
}
# }}}
function display() {
local emoji line exit_code quantifier
emoji=$(cat "$EMOJI_FILE" | grep -v '#' | grep -v '^[[:space:]]*$')
line="$(echo "$emoji" | wofi_menu)"
exit_code=$?
line=($line)
last=${line[${#line[@]}-1]}
quantifier="${last:${#last}-1:1}"
if [[ ! "$quantifier" =~ [0-9] ]]; then
quantifier=1
fi
emoijs="$(repeat "${line[0]}" "$quantifier")"
if [ $exit_code == 0 ]; then
echo -n "$emoijs" | pastedirectly
elif [ $exit_code == 10 ]; then
echo -n "$emoijs" | toclipboard
fi
}
# Some simple argparsing
if [[ "$1" =~ -D|--download ]]; then
download
exit 0
elif [[ "$1" =~ -h|--help ]]; then
echo "usage: $0 [-D|--download]"
exit 0
fi
# Download all emoji if they don't exist yet
if [ ! -f "$EMOJI_FILE" ]; then
download
fi
# display displays :)
display