lazy_customs.py 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. from datetime import datetime
  2. from libqtile.lazy import lazy
  3. # Toggles the clipboard manager descriptor between "CE" and "CD"
  4. @lazy.function
  5. def toggle_clipboard(qtile, clipboard):
  6. if clipboard[0] == False :
  7. clipboard[0] = True
  8. qtile.widgets_map["clipboard"].update(' CE ')
  9. qtile.cmd_spawn("clipctl enable")
  10. qtile.cmd_spawn('dunstify -h string:x-dunst-stack-tag:clipboard_state "Qtile" "Enabled clipboard recording"')
  11. else :
  12. clipboard[0] = False
  13. qtile.widgets_map["clipboard"].update(' CD ')
  14. qtile.cmd_spawn("clipctl disable")
  15. qtile.cmd_spawn('dunstify -h string:x-dunst-stack-tag:clipboard_state "Qtile" "Disabled clipboard recording"')
  16. @lazy.function
  17. def take_screenshot(qtile, fullscreen, select, directory, dateformat, fileformat, bzipcompression):
  18. now = datetime.now()
  19. screenshot_name=directory+"/"+now.strftime(dateformat)+"."+fileformat
  20. command="screenshot '" + screenshot_name + "'"
  21. if fullscreen:
  22. command = command + " True False"
  23. elif select:
  24. command = command + " False True"
  25. else:
  26. command = command + " False False"
  27. if bzipcompression:
  28. command = command + " True"
  29. else:
  30. command = command + " False"
  31. qtile.cmd_spawn(command)
  32. @lazy.function
  33. def record(qtile, directory, format, widget_color):
  34. now = datetime.now()
  35. recordname=directory + "/" + now.strftime(format)+".mkv"
  36. qtile.cmd_spawn("record '" + recordname + "'")
  37. if qtile.widgets_map["record"].cmd_get() == '':
  38. qtile.widgets_map["record"].update(' <span foreground="' + widget_color + '">REC</span> ')
  39. else:
  40. qtile.widgets_map["record"].update('')
  41. @lazy.function
  42. def change_pulse_volume(qtile, amount):
  43. qtile.cmd_spawn('pactl set-sink-volume @DEFAULT_SINK@ ' + amount)
  44. qtile.cmd_spawn("volume-notification Qtile")
  45. @lazy.function
  46. def toggle_pulse_mute(qtile):
  47. qtile.cmd_spawn('pactl set-sink-mute @DEFAULT_SINK@ toggle')
  48. qtile.cmd_spawn("mute-notification Qtile")
  49. # Rotates between the input methods specified in the inputs array
  50. @lazy.function
  51. def change_input(qtile, inputs, current):
  52. current[0]=(current[0]+1)%len(inputs)
  53. qtile.cmd_spawn('ibus engine ' + inputs[current[0]])
  54. qtile.cmd_spawn("ibus-notification Qtile")
  55. @lazy.function
  56. def my_shutdown(qtile, target):
  57. target_dict = dict (
  58. reboot="loginctl reboot",
  59. shutdown="loginctl poweroff",
  60. logout="loginctl kill-session self",
  61. lock="dm-tool lock",
  62. change_user="dm-tool switch-to-greeter",
  63. )
  64. qtile.cmd_spawn(target_dict[target])
  65. @lazy.function
  66. def toggle_bars(qtile):
  67. qtile.cmd_hide_show_bar()