diff --git a/files/.config/sway/config b/files/.config/sway/config new file mode 100644 index 0000000..e838ee5 --- /dev/null +++ b/files/.config/sway/config @@ -0,0 +1,274 @@ +### Vars +set $terminal termite + +### Color configuration +set $bg #383838 +set $fg #b7bbb7 +set $border #383838 +set $active #f0544c + +# class border backgr. text indicator child_border +client.focused $active $bg $fg $border $active +client.focused_inactive $bg $bg $fg $border $border +client.unfocused $bg $bg $fg $border $border +client.urgent $bg $bg $active $border $border +client.placeholder $bg $bg $fg $border $border +client.background $bg + +# Font for window titles. Will also be used by the bar unless a different font +# is used in the bar {} block below. +set $font Hack Nerd Font +font pango:$font 8 + +set $ws1 "1: 1 " +set $ws2 "2: 2 " +set $ws3 "3: 3 " +set $ws4 "4: 4 " +set $ws5 "5: 5 " +set $ws6 "6: 6 " +set $ws7 "7: 7 " +set $ws8 "8: 8 " +set $ws9 "9: 9 " +set $ws10 "10: 10 " + +# window title +#for_window [class="^.*"] border pixel 2 title_format " %title" +default_border pixel 2 +for_window [floating] default_border pixel 1 +smart_borders on + +# Gaps +gaps inner 16 +gaps outer -8 +smart_gaps on + +# Floating mod +for_window [class="^Pavucontrol$"] floating enable +for_window [class="^Pulseeffects$"] floating enable +for_window [class="Remmina" title="Remmina Remote Desktop Client"] floating enable +for_window [class="feh" title="pinned screenshot"] floating enable sticky enable +for_window [class="TeamViewer"] floating enable + +# https://github.com/ValveSoftware/steam-for-linux/issues/1040 +for_window [class="^Steam$" title="^Friends$"] floating enable +for_window [class="^Steam$" title="Steam - News"] floating enable +for_window [class="^Steam$" title=".* - Chat"] floating enable +for_window [class="^Steam$" title="^Settings$"] floating enable +for_window [class="^Steam$" title=".* - event started"] floating enable +for_window [class="^Steam$" title=".* CD key"] floating enable +for_window [class="^Steam$" title="^Steam - Self Updater$"] floating enable +for_window [class="^Steam$" title="^Screenshot Uploader$"] floating enable +for_window [class="^Steam$" title="^Steam Guard - Computer Authorization Required$"] floating enable +for_window [title="^Steam Keyboard$"] floating enable + +### Output configuration +output "*" { + background ~/.local/share/wallpaper.jpg fill +} + +### Input configuration +# mod key +set $mod Mod4 +# caps lock is rebinded to mod key + +# Use Mouse+$mod to drag floating windows to their wanted position +floating_modifier $mod + +# disable focus follow mouse +#focus_follows_mouse no + +input "2:18:FocalTechPS/2_FocalTech_Touchpad" { + tap enabled + tap_button_map lrm + middle_emulation enabled +} + +input "*" { + xkb_layout us + xkb_variant altgr-intl + xkb_options caps:super +} + +### Key bindings +# start a terminal +bindsym $mod+Return exec $terminal + +# thunar +bindsym $mod+Mod1+Return exec thunar + +# kill focused window +bindsym $mod+Shift+q kill + +# start rofi (a program launcher) +bindsym $mod+Control+Return exec /bin/bash ~/.config/sway/rofi.bash +# start rofi-pass for password autotype +bindsym $mod+Shift+Return exec rofi-pass +# start rofi-radio +bindsym $mod+p exec ~/.config/sway/rofi-radio.py + +# change focus +bindsym $mod+h focus left +bindsym $mod+j focus down +bindsym $mod+k focus up +bindsym $mod+l focus right + +# alternatively, you can use the cursor keys: +#bindsym $mod+Left focus left +#bindsym $mod+Down focus down +#bindsym $mod+Up focus up +#bindsym $mod+Right focus right + +# move focused window +bindsym $mod+Shift+h move left +bindsym $mod+Shift+j move down +bindsym $mod+Shift+k move up +bindsym $mod+Shift+l move right + +# alternatively, you can use the cursor keys: +bindsym $mod+Shift+Left move left +bindsym $mod+Shift+Down move down +bindsym $mod+Shift+Up move up +bindsym $mod+Shift+Right move right + +# split in horizontal orientation +bindsym $mod+Shift+backslash split h # | +bindsym $mod+backslash split h + +# split in vertical orientation +bindsym $mod+minus split v + +# enter fullscreen mode for the focused container +bindsym $mod+f fullscreen toggle + +# change container layout (stacked, tabbed, toggle split) +bindsym $mod+s layout stacking +bindsym $mod+w layout tabbed +bindsym $mod+e layout toggle split + +# toggle tiling / floating +bindsym $mod+Shift+space exec center-float + +# toggle sticky +bindsym $mod+Ctrl+space sticky toggle + +# change focus between tiling / floating windows +bindsym $mod+space focus mode_toggle + +# focus the parent container +bindsym $mod+a focus parent + +# focus the child container +bindsym $mod+d focus child + +# switch to workspace +bindsym $mod+q workspace back_and_forth +bindsym $mod+1 workspace $ws1 +bindsym $mod+2 workspace $ws2 +bindsym $mod+3 workspace $ws3 +bindsym $mod+4 workspace $ws4 +bindsym $mod+5 workspace $ws5 +bindsym $mod+6 workspace $ws6 +bindsym $mod+7 workspace $ws7 +bindsym $mod+8 workspace $ws8 +bindsym $mod+9 workspace $ws9 +bindsym $mod+0 workspace $ws10 + +#bindsym $mod+Ctrl+Up workspace next +#bindsym $mod+Ctrl+Down workspace prev + +# move focused container to workspace +bindsym $mod+Shift+1 move container to workspace $ws1 +bindsym $mod+Shift+2 move container to workspace $ws2 +bindsym $mod+Shift+3 move container to workspace $ws3 +bindsym $mod+Shift+4 move container to workspace $ws4 +bindsym $mod+Shift+5 move container to workspace $ws5 +bindsym $mod+Shift+6 move container to workspace $ws6 +bindsym $mod+Shift+7 move container to workspace $ws7 +bindsym $mod+Shift+8 move container to workspace $ws8 +bindsym $mod+Shift+9 move container to workspace $ws9 +bindsym $mod+Shift+0 move container to workspace $ws10 + +# Assignation +assign [class="^Slack$"] $ws1 +assign [class="^discord$"] $ws1 +assign [class="^looking-glass-client$"] $ws3 + +# screen +workspace $ws1 output HDMI-2 +workspace $ws2 output HDMI-2 +workspace $ws3 output HDMI-1 +workspace $ws4 output HDMI-1 +workspace $ws5 output HDMI-1 +workspace $ws6 output HDMI-1 +workspace $ws7 output HDMI-1 +workspace $ws8 output HDMI-1 +workspace $ws9 output HDMI-1 +workspace $ws10 output HDMI-1 + +# reload the configuration file +bindsym $mod+Shift+r reload +# exit +bindsym $mod+Shift+e exec "swaynag -t warning -m 'Do you really want to exit sway?' -b 'Yes, exit sway' 'swaymsg exit'" +# lock the screen +bindsym $mod+Pause exec lock +# suspend +bindsym $mod+Shift+Pause exec systemctl suspend + +# resize window (you can also use the mouse for that) +mode "resize" { + # These bindings trigger as soon as you enter the resize mode + + # Pressing left will shrink the window’s width. + # Pressing right will grow the window’s width. + # Pressing up will shrink the window’s height. + # Pressing down will grow the window’s height. + bindsym h resize shrink width 10 px or 10 ppt + bindsym j resize grow height 10 px or 10 ppt + bindsym k resize shrink height 10 px or 10 ppt + bindsym l resize grow width 10 px or 10 ppt + + # same bindings, but for the arrow keys + #bindsym Left resize shrink width 10 px or 10 ppt + #bindsym Down resize grow height 10 px or 10 ppt + #bindsym Up resize shrink height 10 px or 10 ppt + #bindsym Right resize grow width 10 px or 10 ppt + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} + +bindsym $mod+r mode "resize" + +### Startup +# reach systemd target +exec /bin/systemctl --user import-environment +exec /bin/systemctl --user start user-graphical-login.target + +# autorun .desktop +exec /bin/dex -a + +# run a terminal +exec $terminal + +bar { + status_command i3status --config ~/.config/sway/i3status.conf + + font pango:$font 10 + height 30 + tray_padding 7 + position top + separator_symbol " ▏" + strip_workspace_numbers yes + + colors { + background #000000 + statusline $fg + + focused_workspace #2c2f33 #2c2f33 $fg + active_workspace #000000 #000000 $fg + inactive_workspace #000000 #000000 #4b5056 + urgent_workspace #000000 #000000 #e27c77 + } +} + diff --git a/files/.config/sway/i3status.conf b/files/.config/sway/i3status.conf new file mode 100644 index 0000000..234d5a1 --- /dev/null +++ b/files/.config/sway/i3status.conf @@ -0,0 +1,90 @@ +# i3status configuration file. +# see "man i3status" for documentation. + +# It is important that this file is edited as UTF-8. +# The following line should contain a sharp s: +# ß +# If the above line is not correctly displayed, fix your editor first! + +general { + colors = true + color_good = "#B7BBB7" + color_degraded = "#E2995C" + color_bad = "#B04C50" + + output_format = "i3bar" + interval = 5 +} + +order += "tztime local" +order += "wireless _first_" +order += "ethernet _first_" +order += "cpu_usage" +order += "memory" +order += "battery all" +order += "volume master" +order += "path_exists vpn" +order += "path_exists empty" + +tztime local { + format = " %Y-%m-%d %H:%M" +} + +wireless _first_ { + format_up = "直 <%essid> %ip" + format_down = "睊" + color_bad = "#4B5056" +} + +ethernet _first_ { + # if you use %speed, i3status requires root privileges + format_up = " %ip" + format_down = "" + color_bad = "#4B5056" +} + +cpu_usage { + format = " %usage" + degraded_threshold = 90 + max_threshold = 98 +} + +memory { + format = " %percentage_used" + memory_used_method = "memavailable" + threshold_degraded = "20%" + threshold_degraded = "5%" +} + +battery all { + format = "%status %percentage" + format_down = "" + status_chr = "" + status_bat = "" + status_unk = "" + status_full = "ﮣ" + integer_battery_capacity = true + last_full_capacity = true + hide_seconds = true + + threshold_type = "percentage" + low_threshold = 15 +} + +volume master { + device = "pulse" + format = "墳 %volume" + format_muted = "婢" + color_degraded = "#4B5056" +} + +path_exists vpn { + format = "" + format_down = "" + path = "/proc/sys/net/ipv4/conf/tun0" +} + +path_exists empty { + format = "" + path = "/" +} diff --git a/files/.config/sway/rofi-radio.py b/files/.config/sway/rofi-radio.py new file mode 100755 index 0000000..d9a9d4b --- /dev/null +++ b/files/.config/sway/rofi-radio.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python3 +import json +import os +from subprocess import Popen, PIPE, check_output, check_call + +import yaml + + +station_name_file = '/run/user/%s/rofi-radio-name' % os.getuid() + +def mpv_ipc(*args): + try: + j = json.loads(check_output(['mpv-ipc'] + list(args))) + if j: + return j['data'] + except: + pass + return '' + +with open(os.path.expanduser("~/.local/share/rofi-radio/playlists.yaml")) as f: + stations = yaml.load(f) + +rofi_command = ['rofi', '-i', '-selected-row', '0', '-dmenu', '-p', 'mpv'] + +current_song = mpv_ipc('get_property_string', 'media-title') +if current_song: + try: + with open(station_name_file) as f: + station_name = f.readline() + except: + station_name = '' + rofi_command += ['-mesg', station_name] + commands = b"Play/Pause\nStop\nShuffle\nNext\nPrevious" + +else: + commands = bytes('\n'.join([s["name"] for s in stations]), 'utf8') + +rofi = Popen(rofi_command, stdout=PIPE, stdin=PIPE) +choice = rofi.communicate(input=commands)[0].decode('utf8').rstrip() + +if current_song: + if choice == "Play/Pause": + mpv_ipc('cycle', 'pause') + elif choice == "Stop": + mpv_ipc('stop') + elif choice == "Shuffle": + mpv_ipc('playlist-shuffle') + elif choice == "Next": + mpv_ipc('playlist-next') + elif choice == "Previous": + mpv_ipc('playlist-prev') +else: + s = [s for s in stations if s["name"] == choice] + if s: + # Load the selected playlist + loc = s[0]["loc"] + station_name = s[0]["name"] + if loc.startswith('http') or loc.startswith('ytdl'): + # Load the url + mpv_ipc('loadfile', loc) + else: + # Load the file + workdir = mpv_ipc('get_property_string', 'working-directory') + mpv_ipc('loadfile', os.path.expanduser(loc)) + station_name = loc + with open(station_name_file, 'w') as f: + f.write(station_name) + else: + # Try to load the user input + mpv_ipc('loadfile', choice) + mpv_ipc('set_property_string', 'pause', 'no') + + +# force update of i3status +check_call(['killall', '-USR1', 'i3status']) diff --git a/files/.config/sway/rofi.bash b/files/.config/sway/rofi.bash new file mode 100755 index 0000000..53625e6 --- /dev/null +++ b/files/.config/sway/rofi.bash @@ -0,0 +1,3 @@ +#!/bin/bash +rofi -combi drun -show drun -modi drun,window +