Compare commits

...

10 Commits

Author SHA1 Message Date
7084f45067
update profile 2021-02-11 17:07:37 +01:00
d93a1b62db
add .xinitrc 2021-02-10 22:42:41 +01:00
35c42caf4d
workspace switcher overhaul 2020-12-09 00:20:37 +01:00
d4db40e2e8
mediaplayer: do not show artist tag if not present 2020-09-08 18:22:41 +02:00
4ab5d0a4aa
update zshrc 2020-09-07 17:49:27 +02:00
a2f420b929
update lockscreen script, add media player script 2020-09-07 15:29:28 +02:00
2f8f009291
update profile 2020-09-07 15:26:57 +02:00
6cea9ad7db profile: add environment variables, switch to swaywm 2020-05-27 21:15:55 +02:00
b5b5c9b056 Merge branch 'anor-londo'
merge desktop config into master
2020-05-26 19:11:16 +02:00
abde6bb8f3 ws switcher script: reflect changes in workspace naming 2020-05-26 13:52:58 +02:00
6 changed files with 294 additions and 30 deletions

@ -1,24 +1,33 @@
#!/bin/sh
#:clean temp dir
rm -Rf $HOME/.tmp/lscreen
#:make temp dir
mkdir -p $HOME/.tmp/lscreen
##:clean temp dir
#rm -Rf $HOME/.tmp/lscreen
##:make temp dir
#mkdir -p $HOME/.tmp/lscreen
#:define paths as variables
screen=$HOME/.tmp/lscreen/screen.png
lbg=$HOME/.tmp/lscreen/lbg.png
##:define paths as variables
#screen=$HOME/.tmp/lscreen/screen.png
#lbg=$HOME/.tmp/lscreen/lbg.png
#:take screenshot
grim $screen
##:take screenshot
#grim $screen
#:stretch the screenshot to pixelate - fast
convert $screen -scale 10% -scale 1000% $lbg
#:simple bidirectional blur - slow
#convert $screen -blur 0x8 $lbg
#:remove original screenshot
rm $screen
##:stretch the screenshot to pixelate - fast
#convert $screen -scale 10% -scale 1000% $lbg
##:simple bidirectional blur - slow
##convert $screen -blur 0x8 $lbg
##:remove original screenshot
#rm $screen
#:execute lock with created background
swaylock -f -e -i "$lbg"
##:execute lock with created background
#swaylock -f -e -i "$lbg"
revert() {
killall swayidle
}
trap revert HUP INT TERM
swayidle -w \
timeout 5 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' &
swaylock --screenshots --clock --indicator --indicator-radius 100 --indicator-thickness 10 --effect-blur 7x5 --effect-vignette 0.4:0.4 --ring-color bb00cc --key-hl-color 880033 --line-color 00000000 --inside-color 00000088 --separator-color 00000000 --grace 2 --fade-in 0.2
revert

133
.local/bin/mediaplayer.py Executable file

@ -0,0 +1,133 @@
#!/usr/bin/env python3
import argparse
import logging
import sys
import signal
import gi
import json
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,
'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, 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() == None and player.get_title() != '':
track_info = player.get_title()
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
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 occurence 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
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG,
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))
# 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()

@ -1,12 +1,70 @@
#!/usr/bin/python
import json,sys,subprocess
import sys
from i3ipc import Connection
args = sys.argv
msg = json.loads(subprocess.run(["swaymsg", "-t", "get_workspaces"], stdout=subprocess.PIPE).stdout.decode('utf-8'))
for i in range(len(msg)):
if msg[i]["focused"] == True:
if msg[i]["output"] == "DP-1":
subprocess.run(["swaymsg", "workspace", str(args[1])])
if msg[i]["output"] == "DVI-D-1":
subprocess.run(["swaymsg", "workspace", "P" + str(args[1])])
PRIMARY = "eDP-1"
class Switcher():
def __init__(self, connection):
self.sway = connection
if len(sys.argv) > 1:
self.ws = sys.argv[1]
else:
raise TypeError("At least one argument is required")
def find_focused_out(self):
outputs = self.sway.get_outputs()
for output in outputs:
if output.focused:
focused_out = output.name
return focused_out
def move_to_next(self):
focused_out = self.find_focused_out()
if focused_out == PRIMARY:
self.sway.command("move container to workspace {}".format(self.ws + "s"))
else:
self.sway.command("move container to workspace {}".format(self.ws))
def move_to(self):
focused_out = self.find_focused_out()
if focused_out == PRIMARY:
self.sway.command("move container to workspace {}".format(self.ws))
else:
self.sway.command("move container to workspace {}".format(self.ws + "s"))
def switch_ws(self):
focused_out = self.find_focused_out()
if focused_out == PRIMARY:
self.sway.command("workspace {}".format(self.ws))
else:
self.sway.command("workspace {}".format(self.ws + "s"))
def switch_other_ws(self):
focused_out = self.find_focused_out()
if focused_out == PRIMARY:
self.sway.command("workspace {}".format(self.ws + "s"))
else:
self.sway.command("workspace {}".format(self.ws))
def main():
switcher = Switcher(Connection())
if len(sys.argv) > 2:
flag = sys.argv[2]
else:
flag = None
if not flag:
switcher.switch_ws()
if flag == "-m":
switcher.move_to()
if flag == "-n":
switcher.move_to_next()
if flag == "-o":
switcher.switch_other_ws()
else:
raise ValueError("Unknown operation")
if __name__ == "__main__":
main()

30
.xinitrc Normal file

@ -0,0 +1,30 @@
#!/bin/sh
#
# ~/.xinitrc
#
# Executed by startx (run your window manager from here)
userresources=$HOME/.Xresources
#usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
#sysmodmap=/etc/X11/xinit/.Xmodmap
export XDG_SESSION_TYPE=x11
export XDG_CURRENT_DESKTOP=X-cinnamon
export XDG_SESSION_DESKTOP=X-cinnamon
export CLUTTER_BACKEND=x11
export ECORE_EVAS_ENGINE=x11
export ELM_ENGINE=x11
export SDL_VIDEODRIVER=x11
export QT_QPA_PLATFORMTHEME="qt5ct"
#export QT_STYLE_OVERRIDE=gtk2
export QT_QPA_PLATFORM=xcb
export QT_AUTO_SCREEN_SCALE_FACTOR=0
#export QT_SCREEN_SCALE_FACTORS=1
export EDITOR=/usr/bin/nvim
#export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
eval $(/usr/bin/gnome-keyring-daemon --start --components=pkcs11,secrets,ssh)
export SSH_AUTH_SOCK
exec cinnamon-session

@ -1,16 +1,36 @@
# Adds `~/.local/bin` to $PATH
export PATH="$PATH:$(du "$HOME/.local/bin/" | cut -f2 | tr '\n' ':' | sed 's/:*$//')"
# Session
export XDG_SESSION_TYPE=wayland
export XDG_SESSION_DESKTOP=sway
export XDG_CURRENT_DESKTOP=sway
# Default programs:
export EDITOR="nvim"
export TERMINAL="gnome-terminal"
export BROWSER="brave"
export READER="xreader"
export TERMINAL="kitty"
export BROWSER="chromium --enable-features=UseOzonePlatform --ozone-platform=wayland"
export READER="zathura"
# Env vars
export CLUTTER_BACKEND=wayland
export QT_QPA_PLATFORM=wayland-egl
export ECORE_EVAS_ENGINE=wayland-egl
export ELM_ENGINE=wayland_egl
export SDL_VIDEODRIVER=wayland
export NO_AT_BRIDGE=1
export QT_QPA_PLATFORMTHEME="qt5ct"
export _JAVA_AWT_WM_NONREPARENTING=1
export MOZ_ENABLE_WAYLAND=1
export MOZ_DBUS_REMOTE=1
export TDESKTOP_USE_PORTAL=1
# ~/ Clean-up:
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_RUNTIME_DIR="$HOME/.local/temp"
# Start graphical server on tty1 if not already running.
[ "$(tty)" = "/dev/tty1" ] && ! ps -e | grep -qw Xorg && exec startx
[ "$(tty)" = "/dev/tty1" ] && ! ps -e | grep -qw Xorg && exec sway
[ "$(tty)" = "/dev/tty2" ] && ! ps -e | grep -qw sway && exec startx

14
.zshrc

@ -71,6 +71,20 @@ export LANG=en_US.UTF-8
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# ssh auth stuffs
if [ ! -S ~/.ssh/ssh_auth_sock ]; then
eval `ssh-agent` > /dev/null
ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock
fi
export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock
ssh-add -l > /dev/null || ssh-add > /dev/null
if [ -n "$DESKTOP_SESSION" ];then
eval $(gnome-keyring-daemon --start --components=ssh)
export SSH_AUTH_SOCK
fi
# Lines configured by zsh-newuser-install
HISTFILE=~/.histfile
HISTSIZE=10000