_monitor.tcl 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. namespace eval monitor {
  2. variable monitors
  3. set_help_text monitor_type \
  4. {Select a monitor color profile.
  5. Usage:
  6. monitor_type Shows the current profile
  7. monitor_type -list Show all possible types
  8. monitor_type <type> Select new type
  9. }
  10. set_tabcompletion_proc monitor_type [namespace code tab_monitor_type]
  11. proc tab_monitor_type {args} {
  12. variable monitors
  13. set result [dict keys $monitors]
  14. lappend result "-list"
  15. }
  16. dict set monitors normal {{ 1 0 0 } { 0 1 0 } { 0 0 1 }}
  17. dict set monitors red {{ 1 0 0 } { 0 0 0 } { 0 0 0 }}
  18. dict set monitors green {{ 0 0 0 } { 0 1 0 } { 0 0 0 }}
  19. dict set monitors blue {{ 0 0 0 } { 0 0 0 } { 0 0 1 }}
  20. dict set monitors monochrome_amber {{ .257 .504 .098 } { .193 .378 .073 } { 0 0 0 }}
  21. dict set monitors monochrome_amber_bright {{ .333 .333 .333 } { .249 .249 .249 } { 0 0 0 }}
  22. dict set monitors monochrome_green {{ .129 .252 .049 } { .257 .504 .098 } { .129 .252 .049 }}
  23. dict set monitors monochrome_green_bright {{ .167 .167 .167 } { .333 .333 .333 } { .167 .167 .167 }}
  24. dict set monitors monochrome_white {{ .257 .504 .098 } { .257 .504 .098 } { .257 .504 .098 }}
  25. dict set monitors monochrome_white_bright {{ .333 .333 .333 } { .333 .333 .333 } { .333 .333 .333 }}
  26. proc monitor_type {{monitor ""}} {
  27. variable monitors
  28. if {$monitor eq ""} {
  29. dict for {type matrix} $monitors {
  30. if {$matrix eq $::color_matrix} {
  31. return $type
  32. }
  33. }
  34. return "Custom monitor type: $::color_matrix"
  35. } elseif {$monitor eq "-list"} {
  36. return [dict keys $monitors]
  37. } else {
  38. if {[dict exists $monitors $monitor]} {
  39. set ::color_matrix [dict get $monitors $monitor]
  40. } else {
  41. error "No such monitor type: $monitor"
  42. }
  43. }
  44. }
  45. namespace export monitor_type
  46. } ;# namespace monitor
  47. namespace import monitor::*