From 4c15bd89f528fcb7f9039511cdebd19d2169cf1e Mon Sep 17 00:00:00 2001 From: tmu Date: Sun, 1 Jan 2023 16:02:16 -0700 Subject: start --- .bash_aliases | 13 +++ .bashrc | 136 +++++++++++++++++++++++ init.el | 241 +++++++++++++++++++++++++++++++++++++++++ sway/config | 295 ++++++++++++++++++++++++++++++++++++++++++++++++++ sway/config~ | 295 ++++++++++++++++++++++++++++++++++++++++++++++++++ sway/otherwindow | 81 ++++++++++++++ sway/otherwindow~ | 60 ++++++++++ sway/switch.sh | 11 ++ sway/switch.sh~ | 10 ++ sway/toEmacs.sh | 12 ++ sway/toEmacs.sh~ | 11 ++ waybar/config | 163 ++++++++++++++++++++++++++++ waybar/config~ | 163 ++++++++++++++++++++++++++++ waybar/mediaplayer.py | 128 ++++++++++++++++++++++ waybar/style.css | 259 ++++++++++++++++++++++++++++++++++++++++++++ waybar/style.css~ | 254 +++++++++++++++++++++++++++++++++++++++++++ 16 files changed, 2132 insertions(+) create mode 100644 .bash_aliases create mode 100644 .bashrc create mode 100644 init.el create mode 100644 sway/config create mode 100644 sway/config~ create mode 100755 sway/otherwindow create mode 100755 sway/otherwindow~ create mode 100755 sway/switch.sh create mode 100755 sway/switch.sh~ create mode 100755 sway/toEmacs.sh create mode 100755 sway/toEmacs.sh~ create mode 100644 waybar/config create mode 100644 waybar/config~ create mode 100755 waybar/mediaplayer.py create mode 100644 waybar/style.css create mode 100644 waybar/style.css~ diff --git a/.bash_aliases b/.bash_aliases new file mode 100644 index 0000000..a89f9a1 --- /dev/null +++ b/.bash_aliases @@ -0,0 +1,13 @@ +#aliases for bash +alias cb="xclip -selection clipboard" +alias br="xrandr --output eDP1 --brightness" +alias desert="blugon -o -S 2500" +alias recolor="blugon -o -S 6600" +alias bctl="bluetoothctl" +alias make="make -j4" +alias less="less -i" +alias e="emacs" +alias a="emacs -nw" +alias demacs="emacs --daemon" +alias ta="tmux attach" +alias starte="startx -- -config egpu.conf" \ No newline at end of file diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..93fa496 --- /dev/null +++ b/.bashrc @@ -0,0 +1,136 @@ +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=1000 +HISTFILESIZE=2000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in + xterm-color|*-256color) color_prompt=yes;; +esac + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm*|rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) + ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + #alias dir='dir --color=auto' + #alias vdir='vdir --color=auto' + + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion + elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion + fi +fi + +export WLC_REPEAT_RATE=35 +export WLC_REPEAT_DELAY=210 +export ALTERNATE_EDITOR="" + +alias ecn="emacsclient -n" + +export EDITOR=ecn +export VISUAL=ecn + +# I want to be able to toggle ibus languages easily +function ibus_toggle { + current=$(ibus engine) + if [ $current = xkb:us::eng ]; then + ibus engine rime + else + ibus engine xkb:us::eng + fi +} diff --git a/init.el b/init.el new file mode 100644 index 0000000..fccabbc --- /dev/null +++ b/init.el @@ -0,0 +1,241 @@ +;;; -*- lexical-binding: t -*- + +(custom-set-variables + ;; custom-set-variables was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(bongo-custom-backend-matchers '((vlc (local-file) . "opus"))) + '(bongo-enabled-backends '(vlc)) + '(bongo-insert-intermediate-headers t) + '(custom-enabled-themes '(tsdh-dark)) + '(display-time-24hr-format t) + '(display-time-day-and-date t) + '(display-time-mode nil) + '(inhibit-startup-screen t) + '(menu-bar-mode nil) + '(package-archives + '(("gnu" . "https://elpa.gnu.org/packages/") + ("nongnu" . "https://elpa.nongnu.org/nongnu/") + ("melpa" . "https://melpa.org/packages/"))) + '(package-selected-packages + '(moe-theme ample-theme monokai-theme zenburn-theme edit-server simple-httpd melancholy-theme volume selectrum origami imenu-anywhere hydra highlight gdscript-mode free-keys folding fold-this f dumb-jump bongo)) + '(scroll-bar-mode nil) + '(tool-bar-mode nil) + '(transient-mark-mode nil)) +(custom-set-faces + ;; custom-set-faces was added by Custom. + ;; If you edit it by hand, you could mess it up, so be careful. + ;; Your init file should contain only one such instance. + ;; If there is more than one, they won't work right. + '(header-line ((t (:inverse-video t :box (:line-width (1 . -1) :color "red" :style released-button)))))) + + +;; stuff I will always want +(electric-pair-mode 1) +(global-hl-line-mode 1) + +;; common hooks +(add-hook 'text-mode-hook (lambda () (flyspell-mode 1))) +(add-hook 'prog-mode-hook (lambda () (hs-minor-mode 1))) + +;; transparancy +(add-to-list 'default-frame-alist '(alpha-background . 90)) ; For all new frames +(defun toggle-frame-transparency () + "Toggle transparency." + (interactive) + (let ((alpha-transparency 90)) + (if (eq alpha-transparency (frame-parameter nil 'alpha-background)) + (set-frame-parameter nil 'alpha-background 100) + (set-frame-parameter nil 'alpha-background alpha-transparency)))) + +;; mode line stuff +(require 'battery) +(defun with-face (str &rest face-plist) + (propertize str 'face face-plist)) +(defun make-mode-line-info-string () + "generates the mode line string that contains all the info to the right" + (concat (format-time-string "%a, %b %+4Y-%0m-%0d ") + (with-face (format-time-string "%R ") + :weight 'bold) + (with-face (format "<%03.2f> " (car (load-average 1))) + :foreground "#da70d6") + (with-face (let* ((mi (memory-info)) + (tm (float (car mi))) + (fm (float (car (cdr mi)))) + (ts (float (car (cdr (cdr mi))))) + (fs (float (car (cdr (cdr (cdr mi))))))) + (format "{%.2f %.2f} " (- 1 (/ fm tm)) (- 1 (/ fs ts)))) + :foreground "#00ced1") + (with-face (battery-format "[%b%p%%%%] " (and battery-status-function (funcall battery-status-function))) + :weight 'bold))) +(setq global-mode-string '("" (:eval (make-mode-line-info-string)))) + +;; custom func keybinds +(global-unset-key (kbd "M-w")) +(global-set-key (kbd "M-w") 'copy-region-as-kill) ;;make copying not flash cursor +(defun zap-whitespace () + "zaps the whitespace around the point in both directions" + (interactive) + (push-mark) + (skip-chars-backward " \t\n") + (push-mark) + (skip-chars-forward " \t\n") + (delete-region (mark) (point)) + (pop-mark) + (goto-char (mark)) + (pop-mark)) +(global-unset-key (kbd "M-z")) +(global-set-key (kbd "M-z") 'zap-whitespace) +(defun wrap-sexp (&optional arg) + "Wraps the following sexp in a pair of parens and places inside the new pair, with prefix arg do the same backwards, pushing the mark" + (interactive "P") + (message "%s" arg) + (if arg + (progn + (push-mark) + (insert-pair -1 ?\( ?\))) + (insert-pair 1 ?\( ?\)))) +(global-set-key (kbd "C-M-z") 'wrap-sexp) + +;;move buffers between windows in a convient way +(defun swap-buffer () + "Cycles the assignment of buffers to windows" + (interactive) + (cond ((one-window-p) (display-buffer (other-buffer))) + ((let* ((buffer-a (current-buffer)) + (window-b (cadr (window-list))) + (buffer-b (window-buffer window-b))) + (set-window-buffer window-b buffer-a) + (switch-to-buffer buffer-b) + (other-window 1))))) +;;replace shrink window +(global-unset-key (kbd "C-x -")) +(global-set-key (kbd "C-x -") 'swap-buffer) + +;; quick window switching +(global-set-key (kbd "M-o") 'other-window) +(global-set-key (kbd "M-W") 'switch-to-buffer) + +;; save/restore window config +(setq current-saved-layout ?0) +(seq-do (lambda (number) + (let* ((string (int-to-string number)) + (char (string-to-char string)) + (key (kbd (concat "M-" string)))) + (global-unset-key key) + (global-set-key key (lambda () + (interactive) + (window-configuration-to-register current-saved-layout) + (unless (window-configuration-p (car (get-register char))) + (window-configuration-to-register char)) + (jump-to-register char) + (setq current-saved-layout char))))) + '(0 1 2 3 4 5 6 7 8 9)) + +;; get me a calculator +(global-unset-key (kbd "M-c")) +(global-set-key (kbd "M-c") 'calc) + +;; compilation stuff +(global-unset-key (kbd "M-n")) +(global-set-key (kbd "M-n") 'compile) +(global-unset-key (kbd "M-m")) +(global-set-key (kbd "M-m") 'recompile) + +;; latex stuff +(require 'tex-mode) +(define-key latex-mode-map (kbd "C-c m") (lambda () (interactive) + (insert "\\[\n\n\\]") + (backward-char 3))) + +;; region folding +(require 'fold-this) + +;; folding keybinds +(defun fold-this-fold-forward (&optional arg) + (interactive "p") + (push-mark) + (forward-sexp arg) + (fold-this (mark) (point)) + (pop-mark)) +(defun fold-this-fold-backward (&optional arg) + (interactive "p") + (push-mark) + (backward-sexp arg) + (fold-this (point) (mark)) + (pop-mark)) + +(define-prefix-command 'fold-map) +(global-set-key (kbd "M-F") 'fold-map) + +(define-key fold-map (kbd "d") 'fold-this) +;; (global-set-key (kbd "M-F d") 'fold-this) +(define-key fold-map (kbd "e") 'fold-this-unfold-at-point) +;; (global-set-key (kbd "M-F e") 'fold-this-unfold-at-point) +(define-key fold-map (kbd "t") 'hs-toggle-hiding) +;; (global-set-key (kbd "M-F t") 'hs-toggle-hiding) +(define-key fold-map (kbd "f") 'fold-this-fold-forward) +(define-key fold-map (kbd "b") 'fold-this-fold-backward) + +;; better minibuffer complete +(selectrum-mode 1) +(savehist-mode) +(setq selectrum-display-style '(horizontal)) +(setq selectrum-display-action '(display-buffer-in-side-window (side . bottom) (slot . -1))) +(use-package orderless + :ensure t + :custom + (completion-styles '(orderless basic)) + (orderless-matching-styles '(orderless-literal orderless-regexp orderless-prefixes)) + (orderless-skip-highlighting (lambda () selectrum-is-active)) + (selectrum-highlight-candidates-function #'orderless-highlight-matches)) + +;; better in-buffer completion +(require 'company) +(add-hook 'prog-mode-hook (lambda () + (company-mode 1))) +(global-unset-key (kbd "M-/")) +(global-set-key (kbd "M-/") 'company-complete) + +;; exwm stuff +;;(load "~/.emacs.d/exwm-pref.el") + +;; mail stuff +;; (load "~/.emacs.d/mail.el") + +;; music +;; (load "~/.emacs.d/bongo.el") +;; (load "~/.emacs.d/youtube-dl.el") +;; (load "~/.emacs.d/bongo-populate.el") + +;; allow using emacsclient +(server-start) + +;; don't ask about killing buffers +(setq kill-buffer-query-functions (delq 'process-kill-buffer-query-function kill-buffer-query-functions)) + +;; allow doing webpage startup +;; (use-package edit-server +;; :ensure t +;; :commands edit-server-start +;; :init (if after-init-time +;; (edit-server-start) +;; (add-hook 'after-init-hook +;; #'(lambda() (edit-server-start)))) +;; :config (setq edit-server-new-frame-alist +;; '((name . "Edit with Emacs FRAME") +;; (top . 200) +;; (left . 200) +;; (width . 80) +;; (height . 25) +;; (minibuffer . t) +;; (menu-bar-lines . t)))) + +;; (load-file "~/.emacs.d/async-eval.el") + +(put 'dired-find-alternate-file 'disabled nil) +(put 'upcase-region 'disabled nil) +(put 'list-timers 'disabled nil) +(put 'narrow-to-region 'disabled nil) + diff --git a/sway/config b/sway/config new file mode 100644 index 0000000..d3f2c0a --- /dev/null +++ b/sway/config @@ -0,0 +1,295 @@ +# Default config for sway +# +# Copy this to ~/.config/sway/config and edit it to your liking. +# +# Read `man 5 sway` for a complete reference. + +### Variables +# +# Logo key. Use Mod1 for Alt. +set $mod Mod4 +# Your preferred terminal emulator +set $term foot +# Your preferred application launcher +# Note: pass the final command to swaymsg so that the resulting window can be opened +# on the original workspace that the command was run on. +set $menu exec wofi -G --show run,drun + +exec swayrd 1>/dev/null 2>/dev/null +#this think doesnt stop when sway dies + +#general preferences +focus_follows_mouse no +seat * hide_cursor when-typing enable + +input type:keyboard { + repeat_delay 210 + repeat_rate 35 +# xkb_file ~/.xkb/symbols/tmucustom.xkb + xkb_options compose:ralt +} +input type:touchpad { + dwt enabled + tap enabled + drag disabled + drag_lock disabled + middle_emulation disabled + tap_button_map lrm +} + +#specfically the little red one +#input "1739:52619:SYNA8006:00_06CB:CD8B_Mouse" { +# pointer_accel -1 +# accel_profile flat +# scroll_factor 0.25 +#} + + +#start language switcher +exec fcitx5 -d + +#handle monitors properly +exec_always bash -c 'if $(swaymsg -t get_outputs | grep -q -F "HDMI"); then swaymsg output eDP-1 disable; swaymsg output HDMI-A-1 enable; swaymsg output DP-2 enable; else swaymsg output eDP-1 enable; swaymsg output HDMI-A-1 disable; swaymsg output DP-2 disable; fi' + +#get me a background +#exec_always bash -c 'sleep 0.5s ;systemctl --user start background.service' +exec_always bash -c 'setwallpaper ~/Pictures/capture/aesthetic/turquoiseCity.jpg' + +output HDMI-A-1 { +# background ~/Pictures/tree.jpg fill + pos 0 0 + mode 1920x1080@60Hz +} + +output eDP-1 { +# background ~/Pictures/tree.jpg fill + pos 0 0 + mode 1920x1080@60Hz +} + +output DP-2 { +# background ~/Pictures/tree.jpg fill + pos 1920 0 + mode 1920x1080@60Hz +} + +#theming stuff +#titlebar_border_thickness 2 +#no extra padding +titlebar_padding 2 +#hide_edge_borders both +#smart_borders on +default_border none +font monospace 10 +workspace_layout stacking +focus_wrapping no +show_marks on + + +### I want to be able to open a bunch of stuff quickly on startup and have it go the right place +for_window [app_id="foot" title="terminal"] { + move container to workspace T + mark "t" + fullscreen +} + + + +exec foot -T "terminal" +#bindsym $mod+Shift+s exec vivaldi-stable; exec brave; exec foot -T "terminal" + + +# things I want to toggle +#bindsym $mod+m [title="Messages for web"] scratchpad show +#bindsym $mod+n [class="Spotify"] scratchpad show + + +### dedicated terminal +# I want a permanent terminal that is fullscreened +bindsym $mod+Shift+Return exec ~/.config/sway/switch.sh + +### marking +# using sway-marker +bindsym $mod+bracketright exec sway-marker mark +bindsym $mod+bracketleft exec sway-marker goto + +### Key bindings +# +# Basics: +# +# Start a terminal +bindsym $mod+Return exec $term + +# Kill focused window +bindsym $mod+Shift+q kill + +# Start your launcher +bindsym $mod+d exec $menu + +# get me to emacs +bindsym $mod+p exec ~/.config/sway/toEmacs.sh + +# make a new emacs frame here +bindsym $mod+Shift+p exec emacsclient -c + +# start throwaway browser +bindsym $mod+e exec MOZ_ENABLE_WAYLAND=1 BDK_BACKEND=wayland firefox + +# start quick-open menu +#bindsym $mod+o exec $term --title quicklauncher -e bash -c 'read line; eval $line | less -r' +#for_window [title="quicklauncher"] floating enable, resize set 30 ppt 35 ppt, border pixel 2 + +#other window swap +bindsym $mod+o exec swaymsg [con_id=$(~/.config/sway/otherwindow f)] focus + +# Drag floating windows by holding down $mod and left mouse button. +# Resize them with right mouse button + $mod. +# Despite the name, also works for non-floating windows. +# Change normal to inverse to use left mouse button for resizing and right +# mouse button for dragging. +floating_modifier $mod normal + +# Reload the configuration file +bindsym $mod+Shift+c reload + +# Exit sway (logs you out of your Wayland session) +bindsym $mod+Shift+e exit + +# media keys +bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% && $refresh_i3status +bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% && $refresh_i3status +bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status +bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status + +bindsym XF86MonBrightnessDown exec brightnessctl -e s 10%- +bindsym XF86MonBrightnessUp exec brightnessctl -e s +10% + +# other bindings +bindsym $mod+grave exec systemctl suspend +bindsym $mod+Escape exec sh -c 'swaylock -i /home/tmu/Pictures/capture/installsource.png -l -e -t --indicator-radius 100 & systemctl suspend' + +# +# Moving around: +# +# Or use $mod+[up|down|left|right] +bindsym $mod+Left focus left +bindsym $mod+Down focus down +bindsym $mod+Up focus up +bindsym $mod+Right focus right + +# Move the focused window with the same, but add Shift +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+Up move up +bindsym $mod+Shift+Right move right +# +# Workspaces: +# +# Switch to workspace +bindsym $mod+1 workspace number 1 +bindsym $mod+2 workspace number 2 +bindsym $mod+3 workspace number 3 +bindsym $mod+4 workspace number 4 +bindsym $mod+5 workspace number 5 +bindsym $mod+6 workspace number 6 +bindsym $mod+7 workspace number 7 +bindsym $mod+8 workspace number 8 +bindsym $mod+9 workspace number 9 +bindsym $mod+0 workspace number 10 +# Move focused container to workspace +bindsym $mod+Shift+1 move container to workspace number 1 +bindsym $mod+Shift+2 move container to workspace number 2 +bindsym $mod+Shift+3 move container to workspace number 3 +bindsym $mod+Shift+4 move container to workspace number 4 +bindsym $mod+Shift+5 move container to workspace number 5 +bindsym $mod+Shift+6 move container to workspace number 6 +bindsym $mod+Shift+7 move container to workspace number 7 +bindsym $mod+Shift+8 move container to workspace number 8 +bindsym $mod+Shift+9 move container to workspace number 9 +bindsym $mod+Shift+0 move container to workspace number 10 + +# move workspaces between monitors +bindsym $mod+Prior focus output left +bindsym $mod+Next focus output right +bindsym $mod+Shift+Prior move workspace output left +bindsym $mod+Shift+Next move workspace output right + +# Note: workspaces can have any name you want, not just numbers. +# We just use 1-10 as the default. +# +# Layout stuff: +# +# You can "split" the current object of your focus with +# $mod+b or $mod+v, for horizontal and vertical splits +# respectively. +bindsym $mod+b splith +bindsym $mod+v splitv + +# Switch the current container between different layout styles +bindsym $mod+s layout stacking #not sure I need, I'll leave it +bindsym $mod+w exec swayr switch-window +#bindsym $mod+e layout toggle split + +# Make the current focus fullscreen +bindsym $mod+f fullscreen + +# Toggle the current focus between tiling and floating mode +bindsym $mod+Shift+space floating toggle + +# Swap focus between the tiling area and the floating area +bindsym $mod+space focus mode_toggle + +# Move focus to the parent container +bindsym $mod+a focus parent +# +# Scratchpad: +# +# Sway has a "scratchpad", which is a bag of holding for windows. +# You can send windows there and get them back later. + +# Move the currently focused window to the scratchpad +bindsym $mod+Shift+minus move scratchpad + +# Show the next scratchpad window or hide the focused scratchpad window. +# If there are multiple scratchpad windows, this command cycles through them. +bindsym $mod+minus scratchpad show +# +# Resizing containers: +# +mode "resize" { + # left will shrink the containers width + # right will grow the containers width + # up will shrink the containers height + # down will grow the containers height + bindsym Left resize shrink width 10px + bindsym Down resize grow height 10px + bindsym Up resize shrink height 10px + bindsym Right resize grow width 10px + + # Return to default mode + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+r mode "resize" + +# +# Status Bar: +# +# Read `man 5 sway-bar` for more information about this section. +bar { + swaybar_command waybar +# position bottom +# height 20 + +# # When the status_command prints a new line to stdout, swaybar updates. +# # The default just shows the current date and time. +# # status_command while date +'%Y-%m-%d %I:%M:%S %p'; do sleep 1; done + +# # colors { +# # statusline #ffffff +# # background #323232 +# # inactive_workspace #32323200 #32323200 #d0d0d0 +# # } +} + +include /etc/sway/config.d/* diff --git a/sway/config~ b/sway/config~ new file mode 100644 index 0000000..80eeb46 --- /dev/null +++ b/sway/config~ @@ -0,0 +1,295 @@ +# Default config for sway +# +# Copy this to ~/.config/sway/config and edit it to your liking. +# +# Read `man 5 sway` for a complete reference. + +### Variables +# +# Logo key. Use Mod1 for Alt. +set $mod Mod4 +# Your preferred terminal emulator +set $term foot +# Your preferred application launcher +# Note: pass the final command to swaymsg so that the resulting window can be opened +# on the original workspace that the command was run on. +set $menu exec wofi -G --show run,drun + +exec swayrd 1>/dev/null 2>/dev/null +#this think doesnt stop when sway dies + +#general preferences +focus_follows_mouse no +seat * hide_cursor when-typing enable + +input type:keyboard { + repeat_delay 210 + repeat_rate 35 +# xkb_file ~/.xkb/symbols/tmucustom.xkb + xkb_options compose:ralt +} +input type:touchpad { + dwt enabled + tap enabled + drag disabled + drag_lock disabled + middle_emulation disabled + tap_button_map lrm +} + +#specfically the little red one +#input "1739:52619:SYNA8006:00_06CB:CD8B_Mouse" { +# pointer_accel -1 +# accel_profile flat +# scroll_factor 0.25 +#} + + +#start language switcher +exec fcitx5 -d + +#handle monitors properly +exec_always bash -c 'if $(swaymsg -t get_outputs | grep -q -F "HDMI"); then swaymsg output eDP-1 disable; swaymsg output HDMI-A-1 enable; swaymsg output DP-2 enable; else swaymsg output eDP-1 enable; swaymsg output HDMI-A-1 disable; swaymsg output DP-2 disable; fi' + +#get me a background +#exec_always bash -c 'sleep 0.5s ;systemctl --user start background.service' +exec_always bash -c 'setwallpaper ~/Pictures/capture/aesthetic/turquoiseCity.jpg' + +output HDMI-A-1 { +# background ~/Pictures/tree.jpg fill + pos 0 0 + mode 1920x1080@60Hz +} + +output eDP-1 { +# background ~/Pictures/tree.jpg fill + pos 0 0 + mode 1920x1080@60Hz +} + +output DP-2 { +# background ~/Pictures/tree.jpg fill + pos 1920 0 + mode 1920x1080@60Hz +} + +#theming stuff +#titlebar_border_thickness 2 +#no extra padding +titlebar_padding 2 +#hide_edge_borders both +#smart_borders on +default_border none +font monospace 10 +workspace_layout stacking +focus_wrapping no +show_marks on + + +### I want to be able to open a bunch of stuff quickly on startup and have it go the right place +for_window [app_id="foot" title="terminal"] { + move container to workspace T + mark "t" + fullscreen +} + + + +exec foot -T "terminal" +#bindsym $mod+Shift+s exec vivaldi-stable; exec brave; exec foot -T "terminal" + + +# things I want to toggle +#bindsym $mod+m [title="Messages for web"] scratchpad show +#bindsym $mod+n [class="Spotify"] scratchpad show + + +### dedicated terminal +# I want a permanent terminal that is fullscreened +bindsym $mod+Return exec ~/.config/sway/switch.sh + +### marking +# using sway-marker +bindsym $mod+bracketright exec sway-marker mark +bindsym $mod+bracketleft exec sway-marker goto + +### Key bindings +# +# Basics: +# +# Start a terminal +bindsym $mod+Shift+Return exec $term + +# Kill focused window +bindsym $mod+Shift+q kill + +# Start your launcher +bindsym $mod+d exec $menu + +# get me to emacs +bindsym $mod+p exec ~/.config/sway/toEmacs.sh + +# make a new emacs frame here +bindsym $mod+Shift+p exec emacsclient -c + +# start throwaway browser +bindsym $mod+e exec MOZ_ENABLE_WAYLAND=1 BDK_BACKEND=wayland firefox + +# start quick-open menu +#bindsym $mod+o exec $term --title quicklauncher -e bash -c 'read line; eval $line | less -r' +#for_window [title="quicklauncher"] floating enable, resize set 30 ppt 35 ppt, border pixel 2 + +#other window swap +bindsym $mod+o exec swaymsg [con_id=$(~/.config/sway/otherwindow f)] focus + +# Drag floating windows by holding down $mod and left mouse button. +# Resize them with right mouse button + $mod. +# Despite the name, also works for non-floating windows. +# Change normal to inverse to use left mouse button for resizing and right +# mouse button for dragging. +floating_modifier $mod normal + +# Reload the configuration file +bindsym $mod+Shift+c reload + +# Exit sway (logs you out of your Wayland session) +bindsym $mod+Shift+e exit + +# media keys +bindsym XF86AudioRaiseVolume exec pactl set-sink-volume @DEFAULT_SINK@ +5% && $refresh_i3status +bindsym XF86AudioLowerVolume exec pactl set-sink-volume @DEFAULT_SINK@ -5% && $refresh_i3status +bindsym XF86AudioMute exec pactl set-sink-mute @DEFAULT_SINK@ toggle && $refresh_i3status +bindsym XF86AudioMicMute exec pactl set-source-mute @DEFAULT_SOURCE@ toggle && $refresh_i3status + +bindsym XF86MonBrightnessDown exec brightnessctl -e s 10%- +bindsym XF86MonBrightnessUp exec brightnessctl -e s +10% + +# other bindings +bindsym $mod+grave exec systemctl suspend +bindsym $mod+Escape exec sh -c 'swaylock -i /home/tmu/Pictures/capture/installsource.png -l -e -t --indicator-radius 100 & systemctl suspend' + +# +# Moving around: +# +# Or use $mod+[up|down|left|right] +bindsym $mod+Left focus left +bindsym $mod+Down focus down +bindsym $mod+Up focus up +bindsym $mod+Right focus right + +# Move the focused window with the same, but add Shift +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+Up move up +bindsym $mod+Shift+Right move right +# +# Workspaces: +# +# Switch to workspace +bindsym $mod+1 workspace number 1 +bindsym $mod+2 workspace number 2 +bindsym $mod+3 workspace number 3 +bindsym $mod+4 workspace number 4 +bindsym $mod+5 workspace number 5 +bindsym $mod+6 workspace number 6 +bindsym $mod+7 workspace number 7 +bindsym $mod+8 workspace number 8 +bindsym $mod+9 workspace number 9 +bindsym $mod+0 workspace number 10 +# Move focused container to workspace +bindsym $mod+Shift+1 move container to workspace number 1 +bindsym $mod+Shift+2 move container to workspace number 2 +bindsym $mod+Shift+3 move container to workspace number 3 +bindsym $mod+Shift+4 move container to workspace number 4 +bindsym $mod+Shift+5 move container to workspace number 5 +bindsym $mod+Shift+6 move container to workspace number 6 +bindsym $mod+Shift+7 move container to workspace number 7 +bindsym $mod+Shift+8 move container to workspace number 8 +bindsym $mod+Shift+9 move container to workspace number 9 +bindsym $mod+Shift+0 move container to workspace number 10 + +# move workspaces between monitors +bindsym $mod+Prior focus output left +bindsym $mod+Next focus output right +bindsym $mod+Shift+Prior move workspace output left +bindsym $mod+Shift+Next move workspace output right + +# Note: workspaces can have any name you want, not just numbers. +# We just use 1-10 as the default. +# +# Layout stuff: +# +# You can "split" the current object of your focus with +# $mod+b or $mod+v, for horizontal and vertical splits +# respectively. +bindsym $mod+b splith +bindsym $mod+v splitv + +# Switch the current container between different layout styles +bindsym $mod+s layout stacking #not sure I need, I'll leave it +bindsym $mod+w exec swayr switch-window +#bindsym $mod+e layout toggle split + +# Make the current focus fullscreen +bindsym $mod+f fullscreen + +# Toggle the current focus between tiling and floating mode +bindsym $mod+Shift+space floating toggle + +# Swap focus between the tiling area and the floating area +bindsym $mod+space focus mode_toggle + +# Move focus to the parent container +bindsym $mod+a focus parent +# +# Scratchpad: +# +# Sway has a "scratchpad", which is a bag of holding for windows. +# You can send windows there and get them back later. + +# Move the currently focused window to the scratchpad +bindsym $mod+Shift+minus move scratchpad + +# Show the next scratchpad window or hide the focused scratchpad window. +# If there are multiple scratchpad windows, this command cycles through them. +bindsym $mod+minus scratchpad show +# +# Resizing containers: +# +mode "resize" { + # left will shrink the containers width + # right will grow the containers width + # up will shrink the containers height + # down will grow the containers height + bindsym Left resize shrink width 10px + bindsym Down resize grow height 10px + bindsym Up resize shrink height 10px + bindsym Right resize grow width 10px + + # Return to default mode + bindsym Return mode "default" + bindsym Escape mode "default" +} +bindsym $mod+r mode "resize" + +# +# Status Bar: +# +# Read `man 5 sway-bar` for more information about this section. +bar { + swaybar_command waybar +# position bottom +# height 20 + +# # When the status_command prints a new line to stdout, swaybar updates. +# # The default just shows the current date and time. +# # status_command while date +'%Y-%m-%d %I:%M:%S %p'; do sleep 1; done + +# # colors { +# # statusline #ffffff +# # background #323232 +# # inactive_workspace #32323200 #32323200 #d0d0d0 +# # } +} + +include /etc/sway/config.d/* diff --git a/sway/otherwindow b/sway/otherwindow new file mode 100755 index 0000000..e75c40d --- /dev/null +++ b/sway/otherwindow @@ -0,0 +1,81 @@ +#!/usr/bin/env python3 + +import sys +import json +import subprocess + +swaymsg = subprocess.run(['swaymsg', '-t', 'get_tree'], stdout=subprocess.PIPE) +data = json.loads(swaymsg.stdout) +current = data["nodes"][1]["current_workspace"] + +def iterdict(d, pred): + for sub in d["nodes"]: + # print("sub", sub) + if isinstance(sub, dict): + # print("check 1", sub) + if pred(sub): + # print("check 2", sub) + return sub + else: + rec = iterdict(sub, pred) + if rec != None: + return d + return None + +def focused(d): + # print("tested", d) + if "focused" in d: + return bool(d["focused"]) + return False + # return (("focused" in d) and d["focused"]) + +def getWorkspace(): + for output in data["nodes"]: + for workspace in output["nodes"]: + possible = iterdict(workspace, focused) + # print("pos", possible) + if possible != None: + #not None, must have been some focused + return possible + #maybe gives all the visible ones in multi monitor mode? + return None + + +#workspace = int(data["nodes"][1]["current_workspace"])-1 +#roi = data["nodes"][1]["nodes"][workspace] +#print(roi) +temp = getWorkspace() +windows = list() + +def getNextWindow(): + if focus < len(windows) - 1: + return focus+1 + else: + return 0 + +def getPrevWindow(): + if focus > 0: + return focus-1 + else: + return len(windows)-1 + +def makelist(temp): + for nodes in "floating_nodes", "nodes": + for i in range(len(temp[nodes])): + # print(temp[nodes][i]["name"]) + # print() + if temp[nodes][i]["name"] is None: + makelist(temp[nodes][i]) + elif temp[nodes][i]["visible"]: + windows.append(temp[nodes][i]) + +def focused(temp_win): + for i in range(len(temp_win)): + if temp_win[i]["focused"] == True: + return i + +makelist(temp) +#print(windows) +# print(len(windows)) +focus = focused(windows) +print(windows[getNextWindow()]["id"]) diff --git a/sway/otherwindow~ b/sway/otherwindow~ new file mode 100755 index 0000000..0a82e72 --- /dev/null +++ b/sway/otherwindow~ @@ -0,0 +1,60 @@ +#!/usr/bin/env python3 + +import sys +import json +import subprocess + +direction=bool(sys.argv[1] == 't' or sys.argv[1] == 'T') +swaymsg = subprocess.run(['swaymsg', '-t', 'get_tree'], stdout=subprocess.PIPE) +data = json.loads(swaymsg.stdout) +current = data["nodes"][1]["current_workspace"] + +for output in data["nodes"]: + if "current_workspace" in output: + for workspace in output["nodes"]: + if workspace["name"] == output["current_workspace"]: + #maybe gives all the visible ones in multi monitor mode? + roi = workspace + break + +#workspace = int(data["nodes"][1]["current_workspace"])-1 +#roi = data["nodes"][1]["nodes"][workspace] +#print(roi) +temp = roi +windows = list() + +def getNextWindow(): + if focus < len(windows) - 1: + return focus+1 + else: + return 0 + +def getPrevWindow(): + if focus > 0: + return focus-1 + else: + return len(windows)-1 + +def makelist(temp): + for nodes in "floating_nodes", "nodes": + for i in range(len(temp[nodes])): + # print(temp[nodes][i]["name"]) + # print() + if temp[nodes][i]["name"] is None: + makelist(temp[nodes][i]) + elif temp[nodes][i]["visible"]: + windows.append(temp[nodes][i]) + +def focused(temp_win): + for i in range(len(temp_win)): + if temp_win[i]["focused"] == True: + return i + +makelist(temp) +#print(windows) +# print(len(windows)) +focus = focused(windows) +if str(sys.argv[1]) == 't' or str(sys.argv[1]) == 'T': + print(windows[getNextWindow()]["id"]) +else: + print(windows[getPrevWindow()]["id"]) diff --git a/sway/switch.sh b/sway/switch.sh new file mode 100755 index 0000000..62751b8 --- /dev/null +++ b/sway/switch.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +a="$(swaymsg -t get_tree | jq '.. | objects | select(.type == "con") | select(.focused == true) | .marks | index("t") != null')" + +#echo $a +if [ $a = "true" ]; then + swaymsg '[con_mark="l"] focus' +else + swaymsg 'mark --add "l"; [con_mark="t"] focus' +fi + diff --git a/sway/switch.sh~ b/sway/switch.sh~ new file mode 100755 index 0000000..ccd1bf7 --- /dev/null +++ b/sway/switch.sh~ @@ -0,0 +1,10 @@ +#!/bin/bash + +a="$(swaymsg -t get_tree | jq '.. | objects | select(.type == "con") | select(.focused == true) | .marks | index("t") != null')" + +#echo $a +if [ $a = "true" ]; then + swaymsg '[con_mark="l"] focus' +else + swaymsg 'mark --add "l"; [con_mark="t"] focus' +fi diff --git a/sway/toEmacs.sh b/sway/toEmacs.sh new file mode 100755 index 0000000..aacf2c1 --- /dev/null +++ b/sway/toEmacs.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +#get be to emacs and back + +f=$(swaymsg -t get_tree | jq '.. | objects | select(.focused) | .app_id') + + +if [ $f = '"emacs"' ]; then + swaymsg '[con_mark="E"] focus' +else + swaymsg 'mark --add "E"; [app_id="emacs"] focus' +fi diff --git a/sway/toEmacs.sh~ b/sway/toEmacs.sh~ new file mode 100755 index 0000000..30d1dc3 --- /dev/null +++ b/sway/toEmacs.sh~ @@ -0,0 +1,11 @@ +#!/bin/bash + +#get be to emacs and back + +f=$(swaymsg -t get_tree | jq '.. | objects | select(.focused) | .app_id') + +if [ $f = "emacs" ]; then + swaymsg '[con_mark="E"] focus' +else + swaymsg 'mark --add "E", [app_id="emacs"] focus' +fi diff --git a/waybar/config b/waybar/config new file mode 100644 index 0000000..8951fa3 --- /dev/null +++ b/waybar/config @@ -0,0 +1,163 @@ +{ + "layer": "top", // Waybar at top layer + "position": "bottom", // Waybar position (top|bottom|left|right) + "height": 20, // Waybar height (to be removed for auto height) + // "width": 1280, // Waybar width + "spacing": 4, // Gaps between modules (4px) + // Choose the order of the modules + "modules-left": ["sway/workspaces", "sway/mode", "custom/media"], + "modules-center": ["sway/window"], + "modules-right": ["tray", "pulseaudio", "network", "cpu", "memory", "temperature", "backlight", "battery","clock"], + // Modules configuration + // "sway/workspaces": { + // "disable-scroll": true, + // "all-outputs": true, + // "format": "{name}: {icon}", + // "format-icons": { + // "1": "", + // "2": "", + // "3": "", + // "4": "", + // "5": "", + // "urgent": "", + // "focused": "", + // "default": "" + // } + // }, + //"keyboard-state": { + // "numlock": true, + // "capslock": true, + // "format": "{name} {icon}", + // "format-icons": { + // "locked": "", + // "unlocked": "" + // } + //}, + "sway/mode": { + "format": "{}" + }, +// "mpd": { +// "format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elap//sedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}% ", +// "format-disconnected": "Disconnected ", +// "format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ", +// "unknown-tag": "N/A", +// "interval": 2, +// "consume-icons": { +// "on": " " +// }, +// "random-icons": { +// "off": " ", +// "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": { + // "icon-size": 21, + "spacing": 10 + }, + "clock": { + // "timezone": "America/New_York", + //"tooltip-format": "{:%Y %B}\n{calendar}", + "format": "{:%Y-%m-%d\t%H:%M}", + "tooltop": false + }, + "cpu": { + "format": "CPU {usage}%", + "tooltip": false + }, + "memory": { + "format": "MEM {percentage}%" + }, + "temperature": { + // "thermal-zone": 2, + // "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input", + "critical-threshold": 80, + // "format-critical": "{temperatureC}°C {icon}", + "format": "TEMP {temperatureC}°C", + //"format-icons": ["", "", ""] + "tooltip": false + }, + "backlight": { + // "device": "acpi_video1", + "format": "BR {percent}%", + //"format-icons": ["", "", "", "", "", "", "", "", ""] + }, + "battery": { + "states": { + // "good": 95, + "warning": 30, + "critical": 15 + }, + //"format-time": "{H}:{M}", + "format": "BAT {capacity}%", + "tooltip": false + //these aren't in the man pages? + //"format-charging": "CHR {capacity}%", + //"format-plugged": "PLUG {capacity}%", + //"format-alt": "{time}", + // "format-good": "", // An empty format will hide the module + //"format-full": "FULL {capacity}%", + //"format-icons": ["", "", "", "", ""] + }, + //"battery#bat2": { + // "bat": "BAT2" + //}, + "network": { + // "interface": "wlp2*", // (Optional) To force the use of this interface + "format-wifi": "{essid} ({signalStrength}%)", + "format-ethernet": "{ipaddr}/{cidr}", + "tooltip-format": "{ifname} via {gwaddr}", + "format-linked": "{ifname} (No IP)", + "format-disconnected": "Disconnected", + "format-alt": "{ifname}: {ipaddr}/{cidr}" + }, + "pulseaudio": { + // "scroll-step": 1, // %, can be a float + "format": "VOL {volume}%", + //"format-bluetooth": "{volume}% {icon} {format_source}", + //"format-bluetooth-muted": " {icon} {format_source}", + //"format-muted": " {format_source}", + //"format-source": "{volume}% ", + //"format-source-muted": "", + //"format-icons": { + // "headphone": "", + // "hands-free": "", + // "headset": "", + // "phone": "", + // "portable": "", + // "car": "", + // "default": ["", "", ""] + //}, + "on-click": "pavucontrol" + }, + "custom/media": { + "format": "{icon} {}", + "return-type": "json", + "max-length": 40, + "format-icons": { + "spotify": "", + "default": "🎜" + }, + "escape": true, + "exec": "$HOME/.config/waybar/mediaplayer.py" // Script in resources folder + //"exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name + } +} \ No newline at end of file diff --git a/waybar/config~ b/waybar/config~ new file mode 100644 index 0000000..f6b084c --- /dev/null +++ b/waybar/config~ @@ -0,0 +1,163 @@ +{ + "layer": "top", // Waybar at top layer + "position": "bottom", // Waybar position (top|bottom|left|right) + "height": 20, // Waybar height (to be removed for auto height) + // "width": 1280, // Waybar width + "spacing": 4, // Gaps between modules (4px) + // Choose the order of the modules + "modules-left": ["sway/workspaces", "sway/mode"], + "modules-center": ["sway/window"], + "modules-right": ["tray", "pulseaudio", "network", "cpu", "memory", "temperature", "backlight", "battery","clock"], + // Modules configuration + // "sway/workspaces": { + // "disable-scroll": true, + // "all-outputs": true, + // "format": "{name}: {icon}", + // "format-icons": { + // "1": "", + // "2": "", + // "3": "", + // "4": "", + // "5": "", + // "urgent": "", + // "focused": "", + // "default": "" + // } + // }, + //"keyboard-state": { + // "numlock": true, + // "capslock": true, + // "format": "{name} {icon}", + // "format-icons": { + // "locked": "", + // "unlocked": "" + // } + //}, + "sway/mode": { + "format": "{}" + }, +// "mpd": { +// "format": "{stateIcon} {consumeIcon}{randomIcon}{repeatIcon}{singleIcon}{artist} - {album} - {title} ({elap//sedTime:%M:%S}/{totalTime:%M:%S}) ⸨{songPosition}|{queueLength}⸩ {volume}% ", +// "format-disconnected": "Disconnected ", +// "format-stopped": "{consumeIcon}{randomIcon}{repeatIcon}{singleIcon}Stopped ", +// "unknown-tag": "N/A", +// "interval": 2, +// "consume-icons": { +// "on": " " +// }, +// "random-icons": { +// "off": " ", +// "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": { + // "icon-size": 21, + "spacing": 10 + }, + "clock": { + // "timezone": "America/New_York", + //"tooltip-format": "{:%Y %B}\n{calendar}", + "format": "{:%Y-%m-%d\t%H:%M}", + "tooltop": false + }, + "cpu": { + "format": "CPU {usage}%", + "tooltip": false + }, + "memory": { + "format": "MEM {percentage}%" + }, + "temperature": { + // "thermal-zone": 2, + // "hwmon-path": "/sys/class/hwmon/hwmon2/temp1_input", + "critical-threshold": 80, + // "format-critical": "{temperatureC}°C {icon}", + "format": "TEMP {temperatureC}°C", + //"format-icons": ["", "", ""] + "tooltip": false + }, + "backlight": { + // "device": "acpi_video1", + "format": "BR {percent}%", + //"format-icons": ["", "", "", "", "", "", "", "", ""] + }, + "battery": { + "states": { + // "good": 95, + "warning": 30, + "critical": 15 + }, + //"format-time": "{H}:{M}", + "format": "BAT {capacity}%", + "tooltip": false + //these aren't in the man pages? + //"format-charging": "CHR {capacity}%", + //"format-plugged": "PLUG {capacity}%", + //"format-alt": "{time}", + // "format-good": "", // An empty format will hide the module + //"format-full": "FULL {capacity}%", + //"format-icons": ["", "", "", "", ""] + }, + //"battery#bat2": { + // "bat": "BAT2" + //}, + "network": { + // "interface": "wlp2*", // (Optional) To force the use of this interface + "format-wifi": "{essid} ({signalStrength}%)", + "format-ethernet": "{ipaddr}/{cidr}", + "tooltip-format": "{ifname} via {gwaddr}", + "format-linked": "{ifname} (No IP)", + "format-disconnected": "Disconnected", + "format-alt": "{ifname}: {ipaddr}/{cidr}" + }, + "pulseaudio": { + // "scroll-step": 1, // %, can be a float + "format": "VOL {volume}%", + //"format-bluetooth": "{volume}% {icon} {format_source}", + //"format-bluetooth-muted": " {icon} {format_source}", + //"format-muted": " {format_source}", + //"format-source": "{volume}% ", + //"format-source-muted": "", + //"format-icons": { + // "headphone": "", + // "hands-free": "", + // "headset": "", + // "phone": "", + // "portable": "", + // "car": "", + // "default": ["", "", ""] + //}, + "on-click": "pavucontrol" + }, +// "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 + // "exec": "$HOME/.config/waybar/mediaplayer.py --player spotify 2> /dev/null" // Filter player based on name +// } +} \ No newline at end of file diff --git a/waybar/mediaplayer.py b/waybar/mediaplayer.py new file mode 100755 index 0000000..1630d97 --- /dev/null +++ b/waybar/mediaplayer.py @@ -0,0 +1,128 @@ +#!/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() != '' 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 + 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) + signal.signal(signal.SIGPIPE, signal.SIG_DFL) + + 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() diff --git a/waybar/style.css b/waybar/style.css new file mode 100644 index 0000000..0a72916 --- /dev/null +++ b/waybar/style.css @@ -0,0 +1,259 @@ +* { + /* `otf-font-awesome` is required to be installed for icons */ + font-family: FontAwesome, Roboto, Helvetica, Arial, sans-serif; + font-size: 13px; +} + +window#waybar { + background-color: rgba(43, 48, 59, 1); + border-bottom: 3px solid rgba(100, 114, 125, 0.5); + color: #ffffff; + /* transition-property: background-color; */ + /* transition-duration: .5s; */ + padding: 0; + margin: 0; +} + +/* +window#waybar.hidden { + opacity: 1; +} +*/ + +/* +window#waybar.empty { + background-color: #005050; +} + +window#waybar.solo { + background-color: #FFFFFF; +} +*/ + +window#waybar.termite { + background-color: #3F3F3F; +} + +window#waybar.chromium { + background-color: #000000; + border: none; +} + +#workspaces button { + padding: 0 5px; + background-color: transparent; + color: #ffffff; + /* Use box-shadow instead of border so the text isn't offset */ + box-shadow: inset 0 -3px transparent; + /* Avoid rounded borders under each workspace name */ + border: none; + border-radius: 0; +} + +/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ +#workspaces button:hover { + background: rgba(0, 0, 0, 0.2); + box-shadow: inset 0 -3px #ffffff; +} + +#workspaces button.focused { + background-color: #64727D; + box-shadow: inset 0 -3px #ffffff; +} + +#workspaces button.urgent { + background-color: #eb4d4b; +} + +#mode { + background-color: #64727D; + border-bottom: 3px solid #ffffff; +} + +#clock, +#battery, +#cpu, +#memory, +#disk, +#temperature, +#backlight, +#network, +#pulseaudio, +#custom-media, +#tray, +#mode, +#idle_inhibitor, +#mpd { + padding: 0 10px; + color: #ffffff; +} + +#window, +#workspaces { + margin: 0 4px; +} + +/* If workspaces is the leftmost module, omit left margin */ +.modules-left > widget:first-child > #workspaces { + margin-left: 0; +} + +/* If workspaces is the rightmost module, omit right margin */ +.modules-right > widget:last-child > #workspaces { + margin-right: 0; +} + +#clock { + background-color: #64727D; +} + +#battery { + background-color: #ffffff; + color: #000000; +} + +#battery.charging, #battery.plugged { + color: #ffffff; + background-color: #26A65B; +} + +@keyframes blink { + to { + background-color: #ffffff; + color: #000000; + } +} + +#battery.critical:not(.charging) { + background-color: #f53c3c; + color: #ffffff; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +label:focus { + background-color: #000000; +} + +#cpu { + background-color: #2ecc71; + color: #000000; +} + +#memory { + background-color: #9b59b6; +} + +#disk { + background-color: #964B00; +} + +#backlight { + background-color: #90b1b1; +} + +#network { + background-color: #2980b9; +} + +#network.disconnected { + background-color: #f53c3c; +} + +#pulseaudio { + background-color: #f1c40f; + color: #000000; +} + +#pulseaudio.muted { + background-color: #90b1b1; + color: #2a5c45; +} + +#custom-media { + background-color: #66cc99; + color: #2a5c45; + min-width: 100px; +} + +#custom-media.custom-spotify { + background-color: #66cc99; +} + +#custom-media.custom-vlc { + background-color: #ffa000; +} + +#temperature { + background-color: #f0932b; +} + +#temperature.critical { + background-color: #eb4d4b; +} + +#tray { + background-color: #2980b9; +} + +#tray > .passive { + -gtk-icon-effect: dim; +} + +#tray > .needs-attention { + -gtk-icon-effect: highlight; + background-color: #eb4d4b; +} + +#idle_inhibitor { + background-color: #2d3436; +} + +#idle_inhibitor.activated { + background-color: #ecf0f1; + color: #2d3436; +} + +#mpd { + background-color: #66cc99; + color: #2a5c45; +} + +#mpd.disconnected { + background-color: #f53c3c; +} + +#mpd.stopped { + background-color: #90b1b1; +} + +#mpd.paused { + background-color: #51a37a; +} + +#language { + background: #00b093; + color: #740864; + padding: 0 5px; + margin: 0 5px; + min-width: 16px; +} + +#keyboard-state { + background: #97e1ad; + color: #000000; + padding: 0 0px; + margin: 0 5px; + min-width: 16px; +} + +#keyboard-state > label { + padding: 0 5px; +} + +#keyboard-state > label.locked { + background: rgba(0, 0, 0, 0.2); +} diff --git a/waybar/style.css~ b/waybar/style.css~ new file mode 100644 index 0000000..563ee0d --- /dev/null +++ b/waybar/style.css~ @@ -0,0 +1,254 @@ +* { + /* `otf-font-awesome` is required to be installed for icons */ + font-family: FontAwesome, Roboto, Helvetica, Arial, sans-serif; + font-size: 13px; +} + +window#waybar { + background-color: rgba(43, 48, 59, 0.5); + border-bottom: 3px solid rgba(100, 114, 125, 0.5); + color: #ffffff; + transition-property: background-color; + transition-duration: .5s; +} + +window#waybar.hidden { + opacity: 0.2; +} + +/* +window#waybar.empty { + background-color: transparent; +} +window#waybar.solo { + background-color: #FFFFFF; +} +*/ + +window#waybar.termite { + background-color: #3F3F3F; +} + +window#waybar.chromium { + background-color: #000000; + border: none; +} + +#workspaces button { + padding: 0 5px; + background-color: transparent; + color: #ffffff; + /* Use box-shadow instead of border so the text isn't offset */ + box-shadow: inset 0 -3px transparent; + /* Avoid rounded borders under each workspace name */ + border: none; + border-radius: 0; +} + +/* https://github.com/Alexays/Waybar/wiki/FAQ#the-workspace-buttons-have-a-strange-hover-effect */ +#workspaces button:hover { + background: rgba(0, 0, 0, 0.2); + box-shadow: inset 0 -3px #ffffff; +} + +#workspaces button.focused { + background-color: #64727D; + box-shadow: inset 0 -3px #ffffff; +} + +#workspaces button.urgent { + background-color: #eb4d4b; +} + +#mode { + background-color: #64727D; + border-bottom: 3px solid #ffffff; +} + +#clock, +#battery, +#cpu, +#memory, +#disk, +#temperature, +#backlight, +#network, +#pulseaudio, +#custom-media, +#tray, +#mode, +#idle_inhibitor, +#mpd { + padding: 0 10px; + color: #ffffff; +} + +#window, +#workspaces { + margin: 0 4px; +} + +/* If workspaces is the leftmost module, omit left margin */ +.modules-left > widget:first-child > #workspaces { + margin-left: 0; +} + +/* If workspaces is the rightmost module, omit right margin */ +.modules-right > widget:last-child > #workspaces { + margin-right: 0; +} + +#clock { + background-color: #64727D; +} + +#battery { + background-color: #ffffff; + color: #000000; +} + +#battery.charging, #battery.plugged { + color: #ffffff; + background-color: #26A65B; +} + +@keyframes blink { + to { + background-color: #ffffff; + color: #000000; + } +} + +#battery.critical:not(.charging) { + background-color: #f53c3c; + color: #ffffff; + animation-name: blink; + animation-duration: 0.5s; + animation-timing-function: linear; + animation-iteration-count: infinite; + animation-direction: alternate; +} + +label:focus { + background-color: #000000; +} + +#cpu { + background-color: #2ecc71; + color: #000000; +} + +#memory { + background-color: #9b59b6; +} + +#disk { + background-color: #964B00; +} + +#backlight { + background-color: #90b1b1; +} + +#network { + background-color: #2980b9; +} + +#network.disconnected { + background-color: #f53c3c; +} + +#pulseaudio { + background-color: #f1c40f; + color: #000000; +} + +#pulseaudio.muted { + background-color: #90b1b1; + color: #2a5c45; +} + +#custom-media { + background-color: #66cc99; + color: #2a5c45; + min-width: 100px; +} + +#custom-media.custom-spotify { + background-color: #66cc99; +} + +#custom-media.custom-vlc { + background-color: #ffa000; +} + +#temperature { + background-color: #f0932b; +} + +#temperature.critical { + background-color: #eb4d4b; +} + +#tray { + background-color: #2980b9; +} + +#tray > .passive { + -gtk-icon-effect: dim; +} + +#tray > .needs-attention { + -gtk-icon-effect: highlight; + background-color: #eb4d4b; +} + +#idle_inhibitor { + background-color: #2d3436; +} + +#idle_inhibitor.activated { + background-color: #ecf0f1; + color: #2d3436; +} + +#mpd { + background-color: #66cc99; + color: #2a5c45; +} + +#mpd.disconnected { + background-color: #f53c3c; +} + +#mpd.stopped { + background-color: #90b1b1; +} + +#mpd.paused { + background-color: #51a37a; +} + +#language { + background: #00b093; + color: #740864; + padding: 0 5px; + margin: 0 5px; + min-width: 16px; +} + +#keyboard-state { + background: #97e1ad; + color: #000000; + padding: 0 0px; + margin: 0 5px; + min-width: 16px; +} + +#keyboard-state > label { + padding: 0 5px; +} + +#keyboard-state > label.locked { + background: rgba(0, 0, 0, 0.2); +} -- cgit v1.2.3