From f2b18aab5a84d04a36f4194473680ad70bdb5578 Mon Sep 17 00:00:00 2001 From: Peter Son Struschka Date: Sun, 2 Feb 2020 12:50:32 +0800 Subject: script to find and edit config files --- i3wm/.bin/rofiworkspace | 4 - i3wm/.bin/spotifycl | 207 --------------------------------- i3wm/.config/i3/config | 10 +- i3wm/.config/polybar/config | 10 +- i3wm/.local/bin/lock.sh | 15 +++ i3wm/.local/bin/rofi_goto_workspace | 4 + i3wm/.local/bin/rofi_moveto_workspace | 4 + i3wm/.local/bin/rofi_workspace_prompt | 3 + i3wm/.local/bin/spotifycl | 207 +++++++++++++++++++++++++++++++++ i3wm/.local/share/config-files/i3 | 1 + i3wm/.local/share/config-files/polybar | 1 + i3wm/.local/share/images/lock.png | Bin 0 -> 3959 bytes i3wm/.local/share/images/rick_lock.png | Bin 0 -> 113100 bytes i3wm/.local/share/images/wallpaper.jpg | Bin 0 -> 651668 bytes i3wm/.lock.png | Bin 3959 -> 0 bytes i3wm/.lock.sh | 15 --- i3wm/.rick_lock.png | Bin 113100 -> 0 bytes i3wm/.wallpaper.jpg | Bin 651668 -> 0 bytes 18 files changed, 246 insertions(+), 235 deletions(-) delete mode 100755 i3wm/.bin/rofiworkspace delete mode 100755 i3wm/.bin/spotifycl create mode 100755 i3wm/.local/bin/lock.sh create mode 100755 i3wm/.local/bin/rofi_goto_workspace create mode 100755 i3wm/.local/bin/rofi_moveto_workspace create mode 100755 i3wm/.local/bin/rofi_workspace_prompt create mode 100755 i3wm/.local/bin/spotifycl create mode 120000 i3wm/.local/share/config-files/i3 create mode 120000 i3wm/.local/share/config-files/polybar create mode 100644 i3wm/.local/share/images/lock.png create mode 100644 i3wm/.local/share/images/rick_lock.png create mode 100644 i3wm/.local/share/images/wallpaper.jpg delete mode 100644 i3wm/.lock.png delete mode 100755 i3wm/.lock.sh delete mode 100644 i3wm/.rick_lock.png delete mode 100644 i3wm/.wallpaper.jpg (limited to 'i3wm') diff --git a/i3wm/.bin/rofiworkspace b/i3wm/.bin/rofiworkspace deleted file mode 100755 index 2b808e9..0000000 --- a/i3wm/.bin/rofiworkspace +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -NAME=`rofi -dmenu` -i3-msg workspace $NAME \ No newline at end of file diff --git a/i3wm/.bin/spotifycl b/i3wm/.bin/spotifycl deleted file mode 100755 index ffee9f0..0000000 --- a/i3wm/.bin/spotifycl +++ /dev/null @@ -1,207 +0,0 @@ -#!/usr/bin/env python - -# MIT License -# -# Copyright (c) 2018 Andreas Backx -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. - - -import os -import socket -import sys -import time -import traceback -from concurrent.futures import ThreadPoolExecutor - -import click -import dbus -import dbus.mainloop.glib -import spotipy -import spotipy.util as util -from dbus.mainloop.glib import DBusGMainLoop -from gi.repository import GLib -from spotipy import SpotifyException -from spotipy.oauth2 import SpotifyClientCredentials - -inactive_color = '%{F#6E6E6E}' -active_color = '%{F#CECECE}' -default_color = '%{F-}' - -server_address = '/tmp/spotifycl-socket' - - -class Spotify: - - SPOTIFY_BUS = 'org.mpris.MediaPlayer2.spotify' - SPOTIFYD_BUS = 'org.mpris.MediaPlayer2.spotifyd' - SPOTIFY_OBJECT_PATH = '/org/mpris/MediaPlayer2' - - PLAYER_INTERFACE = 'org.mpris.MediaPlayer2.Player' - PROPERTIES_INTERFACE = 'org.freedesktop.DBus.Properties' - - SAVE_REMOVE = b'save' - - def __init__(self): - DBusGMainLoop(set_as_default=True) - self.session_bus = dbus.SessionBus() - self.last_output = '' - self.empty_output = True - - # Last shown metadata - self.last_title = None - # Whether the current song is added to the library - self.saved_track = False - # Whether to ignore the update - self.ignore = False - - def monitor(self): - self.setup_properties_changed() - self.freedesktop = self.session_bus.get_object( - "org.freedesktop.DBus", - "/org/freedesktop/DBus" - ) - self.freedesktop.connect_to_signal( - "NameOwnerChanged", - self.on_name_owner_changed, - arg0=self.SPOTIFYD_BUS - ) - - executor = ThreadPoolExecutor(max_workers=2) - executor.submit(self._start_glib_loop) - executor.submit(self._start_server) - - def _start_glib_loop(self): - loop = GLib.MainLoop() - loop.run() - - def _start_server(self): - try: - os.unlink(server_address) - except OSError: - if os.path.exists(server_address): - raise - sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - sock.bind(server_address) - sock.listen(5) - - @property - def metadata_status(self): - spotify_properties = dbus.Interface( - self.spotify, - dbus_interface=Spotify.PROPERTIES_INTERFACE - ) - metadata = spotify_properties.Get( - Spotify.PLAYER_INTERFACE, - 'Metadata' - ) - playback_status = spotify_properties.Get( - Spotify.PLAYER_INTERFACE, - 'PlaybackStatus' - ) - return metadata, playback_status - - def output(self, line): - if not line: - self.empty_output = True - if line != self.last_output: - print(line, flush=True) - self.last_output = line - - def setup_spotify(self): - try: - self.spotify = self.session_bus.get_object( - Spotify.SPOTIFY_BUS, - Spotify.SPOTIFY_OBJECT_PATH - ) - except dbus.DBusException: - self.spotify = self.session_bus.get_object(Spotify.SPOTIFYD_BUS, Spotify.SPOTIFY_OBJECT_PATH) - - def setup_properties_changed(self): - try: - self.setup_spotify() - self.spotify.connect_to_signal( - 'PropertiesChanged', - self.on_properties_changed - ) - - if self.empty_output: - metadata, playback_status = self.metadata_status - self.output_playback_status( - data={ - 'Metadata': metadata, - 'PlaybackStatus': playback_status, - } - ) - - except dbus.DBusException: - self.output('') - - def output_playback_status(self, data, retry=False): - if self.ignore: - return - - metadata = data['Metadata'] - artists = metadata['xesam:artist'] - artist = artists[0] if artists else None - - if not artist: - self.output('') - return - - title = metadata['xesam:title'] - playback_status = data['PlaybackStatus'] - same_song = title == self.last_title - - color = active_color if playback_status == 'Playing' else inactive_color - # divider = '+' if same_song and self.saved_track else '-' - self.output(f'{color}{artist} - {title}{default_color}') - - if not same_song: - self.last_title = title - - def on_properties_changed(self, interface, data, *args, **kwargs): - self.output_playback_status(data) - - def on_name_owner_changed(self, name, old_owner, new_owner): - if name == self.SPOTIFY_BUS: - if new_owner: - # Spotify was opened. - self.setup_properties_changed() - else: - # Spotify was closed. - self.spotify = None - self.output('') - - -@click.group() -def cli(): - """Script for listening to Spotify over dbus and adding tracks to your library.""" - pass - - -@cli.command() -def status(): - """Follow the status of the currently playing song on Spotify.""" - spotify = Spotify() - spotify.monitor() - - -if __name__ == '__main__': - cli() diff --git a/i3wm/.config/i3/config b/i3wm/.config/i3/config index 29e90c2..21635b8 100644 --- a/i3wm/.config/i3/config +++ b/i3wm/.config/i3/config @@ -10,12 +10,12 @@ # Please see https://i3wm.org/docs/userguide.html for a complete reference! exec_always --no-startup-id $HOME/.config/polybar/launch.sh -exec_always --no-startup-id xautolock -locker "~/.lock.sh" -time 60 -detectsleep -notify 10 +exec_always --no-startup-id xautolock -locker "$HOME/.local/bin/lock.sh" -time 60 -detectsleep -notify 10 exec --no-startup-id nm-applet exec --no-startup-id compton set $mod Mod4 -exec_always --no-startup-id feh --bg-scale ~/.wallpaper.jpg +exec_always --no-startup-id feh --bg-scale $HOME/.local/share/images/wallpaper.jpg new_window 1pixel # Font for window titles. Will also be used by the bar unless a different font @@ -37,7 +37,7 @@ font pango:DejaVu Sans Mono 8 floating_modifier $mod # start a terminal -bindsym $mod+Return exec kitty #i3-sensible-terminal +bindsym $mod+Return exec alacritty #kitty #i3-sensible-terminal # kill focused window bindsym $mod+Shift+q kill @@ -74,7 +74,8 @@ bindsym $mod+Shift+Control+Right move workspace to output right bindsym $mod+b workspace back_and_forth bindsym $mod+Shift+b move container to workspace back_and_forth -bindsym $mod+n exec --no-startup-id rofiworkspace +bindsym $mod+n exec --no-startup-id rofi_goto_workspace +bindsym $mod+m exec --no-startup-id rofi_moveto_workspace # move focused window bindsym $mod+Control+j move left @@ -257,3 +258,4 @@ for_window [class="Spotify"] move to workspace Spotify assign [class="Firefox"] → Browser assign [class="Zeal"] → Zeal assign [class="kitty"] → Term +assign [class="Alacritty"] → Term diff --git a/i3wm/.config/polybar/config b/i3wm/.config/polybar/config index 419ff49..0cda3cf 100644 --- a/i3wm/.config/polybar/config +++ b/i3wm/.config/polybar/config @@ -31,7 +31,7 @@ alert = #bd2c40 monitor = ${env:MONITOR:eDP-1} width = 100% height = 40 -dpi = 156 +dpi = 96 ;offset-x = 1% ;offset-y = 1% radius = 6.0 @@ -82,9 +82,9 @@ modules-right = filesystem backlight pulseaudio xkeyboard memory cpu wlan eth et monitor = ${env:MONITOR:eDP-1} width = 100% height = 40 -dpi = 156 +dpi = 96 ;offset-x = 1% -;offset-y = 0 +offset-y = 50 radius = 6.0 fixed-center = true @@ -335,14 +335,14 @@ label = %percentage_used%% [module/wlan] type = internal/network -interface = wlp13s0 +interface = wlp3s0 interval = 3.0 accumulate-stats = true format-connected-prefix = " " format-connected = format-connected-underline = #9f78e1 -label-connected = %essid% %local_ip% ↓%downspeed% ↑%upspeed% +label-connected = %essid% %local_ip% ↓%downspeed% ↑%upspeed% (%signal%) format-disconnected = ;format-disconnected = diff --git a/i3wm/.local/bin/lock.sh b/i3wm/.local/bin/lock.sh new file mode 100755 index 0000000..a3ddc2c --- /dev/null +++ b/i3wm/.local/bin/lock.sh @@ -0,0 +1,15 @@ +#!/bin/bash +revert() { + rm /tmp/*screen*.png + xset dpms 0 0 0 +} +trap revert HUP INT TERM +xset +dpms dpms 0 0 5 + +ffmpeg -loglevel quiet -y -f x11grab -video_size `xdpyinfo | grep 'dimensions' | awk '{print $2}'` -i $DISPLAY -i ~/.local/share/images/rick_lock.png -filter_complex "boxblur=5:1,overlay=(main_w-overlay_w-400):(main_h-overlay_h-5)" -vframes 1 /tmp/screen.png + +#scrot -d 1 /tmp/locking_screen.png +#convert -blur 0x8 /tmp/locking_screen.png /tmp/screen_blur.png +#convert -composite /tmp/screen_blur.png ~/.rick_lock.png -gravity South -geometry -20x1200 /tmp/screen.png +i3lock -eui /tmp/screen.png +revert diff --git a/i3wm/.local/bin/rofi_goto_workspace b/i3wm/.local/bin/rofi_goto_workspace new file mode 100755 index 0000000..35e8762 --- /dev/null +++ b/i3wm/.local/bin/rofi_goto_workspace @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +NAME=`rofi_workspace_prompt` +i3-msg workspace $NAME diff --git a/i3wm/.local/bin/rofi_moveto_workspace b/i3wm/.local/bin/rofi_moveto_workspace new file mode 100755 index 0000000..9cc0b9d --- /dev/null +++ b/i3wm/.local/bin/rofi_moveto_workspace @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +NAME=`rofi_workspace_prompt` +i3-msg move container to workspace $NAME diff --git a/i3wm/.local/bin/rofi_workspace_prompt b/i3wm/.local/bin/rofi_workspace_prompt new file mode 100755 index 0000000..f59d1fa --- /dev/null +++ b/i3wm/.local/bin/rofi_workspace_prompt @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +echo `i3-msg -t get_workspaces | jq '.[].name' | sed 's/\"//g' | rofi -dmenu` diff --git a/i3wm/.local/bin/spotifycl b/i3wm/.local/bin/spotifycl new file mode 100755 index 0000000..ffee9f0 --- /dev/null +++ b/i3wm/.local/bin/spotifycl @@ -0,0 +1,207 @@ +#!/usr/bin/env python + +# MIT License +# +# Copyright (c) 2018 Andreas Backx +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + + +import os +import socket +import sys +import time +import traceback +from concurrent.futures import ThreadPoolExecutor + +import click +import dbus +import dbus.mainloop.glib +import spotipy +import spotipy.util as util +from dbus.mainloop.glib import DBusGMainLoop +from gi.repository import GLib +from spotipy import SpotifyException +from spotipy.oauth2 import SpotifyClientCredentials + +inactive_color = '%{F#6E6E6E}' +active_color = '%{F#CECECE}' +default_color = '%{F-}' + +server_address = '/tmp/spotifycl-socket' + + +class Spotify: + + SPOTIFY_BUS = 'org.mpris.MediaPlayer2.spotify' + SPOTIFYD_BUS = 'org.mpris.MediaPlayer2.spotifyd' + SPOTIFY_OBJECT_PATH = '/org/mpris/MediaPlayer2' + + PLAYER_INTERFACE = 'org.mpris.MediaPlayer2.Player' + PROPERTIES_INTERFACE = 'org.freedesktop.DBus.Properties' + + SAVE_REMOVE = b'save' + + def __init__(self): + DBusGMainLoop(set_as_default=True) + self.session_bus = dbus.SessionBus() + self.last_output = '' + self.empty_output = True + + # Last shown metadata + self.last_title = None + # Whether the current song is added to the library + self.saved_track = False + # Whether to ignore the update + self.ignore = False + + def monitor(self): + self.setup_properties_changed() + self.freedesktop = self.session_bus.get_object( + "org.freedesktop.DBus", + "/org/freedesktop/DBus" + ) + self.freedesktop.connect_to_signal( + "NameOwnerChanged", + self.on_name_owner_changed, + arg0=self.SPOTIFYD_BUS + ) + + executor = ThreadPoolExecutor(max_workers=2) + executor.submit(self._start_glib_loop) + executor.submit(self._start_server) + + def _start_glib_loop(self): + loop = GLib.MainLoop() + loop.run() + + def _start_server(self): + try: + os.unlink(server_address) + except OSError: + if os.path.exists(server_address): + raise + sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + sock.bind(server_address) + sock.listen(5) + + @property + def metadata_status(self): + spotify_properties = dbus.Interface( + self.spotify, + dbus_interface=Spotify.PROPERTIES_INTERFACE + ) + metadata = spotify_properties.Get( + Spotify.PLAYER_INTERFACE, + 'Metadata' + ) + playback_status = spotify_properties.Get( + Spotify.PLAYER_INTERFACE, + 'PlaybackStatus' + ) + return metadata, playback_status + + def output(self, line): + if not line: + self.empty_output = True + if line != self.last_output: + print(line, flush=True) + self.last_output = line + + def setup_spotify(self): + try: + self.spotify = self.session_bus.get_object( + Spotify.SPOTIFY_BUS, + Spotify.SPOTIFY_OBJECT_PATH + ) + except dbus.DBusException: + self.spotify = self.session_bus.get_object(Spotify.SPOTIFYD_BUS, Spotify.SPOTIFY_OBJECT_PATH) + + def setup_properties_changed(self): + try: + self.setup_spotify() + self.spotify.connect_to_signal( + 'PropertiesChanged', + self.on_properties_changed + ) + + if self.empty_output: + metadata, playback_status = self.metadata_status + self.output_playback_status( + data={ + 'Metadata': metadata, + 'PlaybackStatus': playback_status, + } + ) + + except dbus.DBusException: + self.output('') + + def output_playback_status(self, data, retry=False): + if self.ignore: + return + + metadata = data['Metadata'] + artists = metadata['xesam:artist'] + artist = artists[0] if artists else None + + if not artist: + self.output('') + return + + title = metadata['xesam:title'] + playback_status = data['PlaybackStatus'] + same_song = title == self.last_title + + color = active_color if playback_status == 'Playing' else inactive_color + # divider = '+' if same_song and self.saved_track else '-' + self.output(f'{color}{artist} - {title}{default_color}') + + if not same_song: + self.last_title = title + + def on_properties_changed(self, interface, data, *args, **kwargs): + self.output_playback_status(data) + + def on_name_owner_changed(self, name, old_owner, new_owner): + if name == self.SPOTIFY_BUS: + if new_owner: + # Spotify was opened. + self.setup_properties_changed() + else: + # Spotify was closed. + self.spotify = None + self.output('') + + +@click.group() +def cli(): + """Script for listening to Spotify over dbus and adding tracks to your library.""" + pass + + +@cli.command() +def status(): + """Follow the status of the currently playing song on Spotify.""" + spotify = Spotify() + spotify.monitor() + + +if __name__ == '__main__': + cli() diff --git a/i3wm/.local/share/config-files/i3 b/i3wm/.local/share/config-files/i3 new file mode 120000 index 0000000..97ca8a9 --- /dev/null +++ b/i3wm/.local/share/config-files/i3 @@ -0,0 +1 @@ +../../../.config/i3/config \ No newline at end of file diff --git a/i3wm/.local/share/config-files/polybar b/i3wm/.local/share/config-files/polybar new file mode 120000 index 0000000..87fad9e --- /dev/null +++ b/i3wm/.local/share/config-files/polybar @@ -0,0 +1 @@ +../../../.config/polybar/config \ No newline at end of file diff --git a/i3wm/.local/share/images/lock.png b/i3wm/.local/share/images/lock.png new file mode 100644 index 0000000..7759b82 Binary files /dev/null and b/i3wm/.local/share/images/lock.png differ diff --git a/i3wm/.local/share/images/rick_lock.png b/i3wm/.local/share/images/rick_lock.png new file mode 100644 index 0000000..4037c32 Binary files /dev/null and b/i3wm/.local/share/images/rick_lock.png differ diff --git a/i3wm/.local/share/images/wallpaper.jpg b/i3wm/.local/share/images/wallpaper.jpg new file mode 100644 index 0000000..cc1ff0e Binary files /dev/null and b/i3wm/.local/share/images/wallpaper.jpg differ diff --git a/i3wm/.lock.png b/i3wm/.lock.png deleted file mode 100644 index 7759b82..0000000 Binary files a/i3wm/.lock.png and /dev/null differ diff --git a/i3wm/.lock.sh b/i3wm/.lock.sh deleted file mode 100755 index 927b168..0000000 --- a/i3wm/.lock.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -revert() { - rm /tmp/*screen*.png - xset dpms 0 0 0 -} -trap revert HUP INT TERM -xset +dpms dpms 0 0 5 - -ffmpeg -loglevel quiet -y -f x11grab -video_size `xdpyinfo | grep 'dimensions' | awk '{print $2}'` -i $DISPLAY -i ~/.rick_lock.png -filter_complex "boxblur=5:1,overlay=(main_w-overlay_w-400):(main_h-overlay_h-5)" -vframes 1 /tmp/screen.png - -#scrot -d 1 /tmp/locking_screen.png -#convert -blur 0x8 /tmp/locking_screen.png /tmp/screen_blur.png -#convert -composite /tmp/screen_blur.png ~/.rick_lock.png -gravity South -geometry -20x1200 /tmp/screen.png -i3lock -eui /tmp/screen.png -revert diff --git a/i3wm/.rick_lock.png b/i3wm/.rick_lock.png deleted file mode 100644 index 4037c32..0000000 Binary files a/i3wm/.rick_lock.png and /dev/null differ diff --git a/i3wm/.wallpaper.jpg b/i3wm/.wallpaper.jpg deleted file mode 100644 index cc1ff0e..0000000 Binary files a/i3wm/.wallpaper.jpg and /dev/null differ -- cgit v1.2.3